4ddf3ae30c94695604076217e506bb2c436e8bc1
[rhynodge.git] / src / test / java / net / pterodactylus / rhynodge / ReactionTest.java
1 package net.pterodactylus.rhynodge;
2
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;
9
10 import org.junit.Test;
11
12 /**
13  * Unit test for {@link Reaction}.
14  *
15  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
16  */
17 public class ReactionTest {
18
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);
25
26         @Test
27         public void reactionStoresNameCorrectly() {
28                 assertThat(reactionWithoutFilters.name(), is("without"));
29                 assertThat(reactionWithFilters.name(), is("with"));
30         }
31
32         @Test
33         public void reactionStoresQueryCorrectly() {
34                 assertThat(reactionWithoutFilters.query(), is(query));
35                 assertThat(reactionWithFilters.query(), is(query));
36         }
37
38         @Test
39         public void reactionStoresFiltersCorrectly() {
40                 assertThat(reactionWithoutFilters.filters(), emptyIterable());
41                 assertThat(reactionWithFilters.filters(), contains(filter));
42         }
43
44         @Test
45         public void reactionStoresTriggerCorrectly() {
46                 assertThat(reactionWithoutFilters.trigger(), is(trigger));
47                 assertThat(reactionWithFilters.trigger(), is(trigger));
48         }
49
50         @Test
51         public void reactionStoresActionCorrectly() {
52                 assertThat(reactionWithoutFilters.action(), is(action));
53                 assertThat(reactionWithFilters.action(), is(action));
54         }
55
56         @Test
57         public void reactionStoresUpdateIntervalCorrectly() {
58                 reactionWithoutFilters.setUpdateInterval(1);
59                 assertThat(reactionWithoutFilters.updateInterval(), is(1L));
60                 reactionWithFilters.setUpdateInterval(2);
61                 assertThat(reactionWithFilters.updateInterval(), is(2L));
62         }
63
64 }