From df7b7a133b6e5b7afe457dd8cc66ec9b94328214 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 17 Mar 2014 21:07:12 +0100 Subject: [PATCH] Add unit test for reaction. --- .../net/pterodactylus/rhynodge/ReactionTest.java | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/test/java/net/pterodactylus/rhynodge/ReactionTest.java 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)); + } + +} -- 2.7.4