From: David ‘Bombe’ Roden Date: Mon, 17 Mar 2014 20:07:12 +0000 (+0100) Subject: Add unit test for reaction. X-Git-Tag: v2~256 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=df7b7a133b6e5b7afe457dd8cc66ec9b94328214;p=rhynodge.git Add unit test for reaction. --- diff --git a/src/test/java/net/pterodactylus/rhynodge/ReactionTest.java b/src/test/java/net/pterodactylus/rhynodge/ReactionTest.java new file mode 100644 index 0000000..4ddf3ae --- /dev/null +++ b/src/test/java/net/pterodactylus/rhynodge/ReactionTest.java @@ -0,0 +1,64 @@ +package net.pterodactylus.rhynodge; + +import static java.util.Arrays.asList; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.emptyIterable; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.mock; + +import org.junit.Test; + +/** + * Unit test for {@link Reaction}. + * + * @author David ‘Bombe’ Roden + */ +public class ReactionTest { + + private final Query query = mock(Query.class); + private final Filter filter = mock(Filter.class); + private final Trigger trigger = mock(Trigger.class); + private final Action action = mock(Action.class); + private final Reaction reactionWithoutFilters = new Reaction("without", query, trigger, action); + private final Reaction reactionWithFilters = new Reaction("with", query, asList(filter), trigger, action); + + @Test + public void reactionStoresNameCorrectly() { + assertThat(reactionWithoutFilters.name(), is("without")); + assertThat(reactionWithFilters.name(), is("with")); + } + + @Test + public void reactionStoresQueryCorrectly() { + assertThat(reactionWithoutFilters.query(), is(query)); + assertThat(reactionWithFilters.query(), is(query)); + } + + @Test + public void reactionStoresFiltersCorrectly() { + assertThat(reactionWithoutFilters.filters(), emptyIterable()); + assertThat(reactionWithFilters.filters(), contains(filter)); + } + + @Test + public void reactionStoresTriggerCorrectly() { + assertThat(reactionWithoutFilters.trigger(), is(trigger)); + assertThat(reactionWithFilters.trigger(), is(trigger)); + } + + @Test + public void reactionStoresActionCorrectly() { + assertThat(reactionWithoutFilters.action(), is(action)); + assertThat(reactionWithFilters.action(), is(action)); + } + + @Test + public void reactionStoresUpdateIntervalCorrectly() { + reactionWithoutFilters.setUpdateInterval(1); + assertThat(reactionWithoutFilters.updateInterval(), is(1L)); + reactionWithFilters.setUpdateInterval(2); + assertThat(reactionWithFilters.updateInterval(), is(2L)); + } + +}