Add tasks for cloc
[Sone.git] / src / test / java / net / pterodactylus / sone / core / OptionsTest.java
1 package net.pterodactylus.sone.core;
2
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.Matchers.is;
5 import static org.hamcrest.Matchers.nullValue;
6 import static org.mockito.Mockito.mock;
7
8 import net.pterodactylus.sone.utils.Option;
9
10 import org.junit.Test;
11
12 /**
13  * Unit test for {@link Options}.
14  *
15  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
16  */
17 public class OptionsTest {
18
19         private final Options options = new Options();
20
21         @Test
22         public void booleanOptionIsAdded() {
23                 Option<Boolean> booleanOption = mock(Option.class);
24                 options.addBooleanOption("test", booleanOption);
25                 assertThat(options.getBooleanOption("test"), is(booleanOption));
26                 assertThat(options.getBooleanOption("not-test"), nullValue());
27         }
28
29         @Test
30         public void integerOptionIsAdded() {
31                 Option<Integer> integerOption = mock(Option.class);
32                 options.addIntegerOption("test", integerOption);
33                 assertThat(options.getIntegerOption("test"), is(integerOption));
34                 assertThat(options.getIntegerOption("not-test"), nullValue());
35         }
36
37         @Test
38         public void stringOptionIsAdded() {
39                 Option<String> stringOption = mock(Option.class);
40                 options.addStringOption("test", stringOption);
41                 assertThat(options.getStringOption("test"), is(stringOption));
42                 assertThat(options.getStringOption("not-test"), nullValue());
43         }
44
45         @Test
46         public void enumOptionIsAdded() {
47                 Option<TestEnum> enumOption = mock(Option.class);
48                 options.addEnumOption("test", enumOption);
49                 assertThat(options.<TestEnum>getEnumOption("test"), is(enumOption));
50                 assertThat(options.<TestEnum>getEnumOption("not-test"), nullValue());
51         }
52
53         private enum TestEnum {TEST, NOT_TEST}
54
55 }