1 package net.pterodactylus.rhynodge;
3 import static java.util.Arrays.asList;
4 import static org.hamcrest.MatcherAssert.assertThat;
5 import static org.hamcrest.Matchers.contains;
6 import static org.hamcrest.Matchers.emptyIterable;
7 import static org.hamcrest.Matchers.is;
8 import static org.mockito.Mockito.mock;
10 import org.junit.Test;
13 * Unit test for {@link Reaction}.
15 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
17 public class ReactionTest {
19 private final Query query = mock(Query.class);
20 private final Filter filter = mock(Filter.class);
21 private final Trigger trigger = mock(Trigger.class);
22 private final Action action = mock(Action.class);
23 private final Reaction reactionWithoutFilters = new Reaction("without", query, trigger, action);
24 private final Reaction reactionWithFilters = new Reaction("with", query, asList(filter), trigger, action);
27 public void reactionStoresNameCorrectly() {
28 assertThat(reactionWithoutFilters.name(), is("without"));
29 assertThat(reactionWithFilters.name(), is("with"));
33 public void reactionStoresQueryCorrectly() {
34 assertThat(reactionWithoutFilters.query(), is(query));
35 assertThat(reactionWithFilters.query(), is(query));
39 public void reactionStoresFiltersCorrectly() {
40 assertThat(reactionWithoutFilters.filters(), emptyIterable());
41 assertThat(reactionWithFilters.filters(), contains(filter));
45 public void reactionStoresTriggerCorrectly() {
46 assertThat(reactionWithoutFilters.trigger(), is(trigger));
47 assertThat(reactionWithFilters.trigger(), is(trigger));
51 public void reactionStoresActionCorrectly() {
52 assertThat(reactionWithoutFilters.action(), is(action));
53 assertThat(reactionWithFilters.action(), is(action));
57 public void reactionStoresUpdateIntervalCorrectly() {
58 reactionWithoutFilters.setUpdateInterval(1);
59 assertThat(reactionWithoutFilters.updateInterval(), is(1L));
60 reactionWithFilters.setUpdateInterval(2);
61 assertThat(reactionWithFilters.updateInterval(), is(2L));