Add unit test for options.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 7 Jul 2014 19:11:46 +0000 (21:11 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 7 Jul 2014 19:11:46 +0000 (21:11 +0200)
src/test/java/net/pterodactylus/sone/core/OptionsTest.java [new file with mode: 0644]

diff --git a/src/test/java/net/pterodactylus/sone/core/OptionsTest.java b/src/test/java/net/pterodactylus/sone/core/OptionsTest.java
new file mode 100644 (file)
index 0000000..46b2ad5
--- /dev/null
@@ -0,0 +1,55 @@
+package net.pterodactylus.sone.core;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.mockito.Mockito.mock;
+
+import net.pterodactylus.sone.core.Options.Option;
+
+import org.junit.Test;
+
+/**
+ * Unit test for {@link Options}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class OptionsTest {
+
+       private final Options options = new Options();
+
+       @Test
+       public void booleanOptionIsAdded() {
+               Option<Boolean> booleanOption = mock(Option.class);
+               options.addBooleanOption("test", booleanOption);
+               assertThat(options.getBooleanOption("test"), is(booleanOption));
+               assertThat(options.getBooleanOption("not-test"), nullValue());
+       }
+
+       @Test
+       public void integerOptionIsAdded() {
+               Option<Integer> integerOption = mock(Option.class);
+               options.addIntegerOption("test", integerOption);
+               assertThat(options.getIntegerOption("test"), is(integerOption));
+               assertThat(options.getIntegerOption("not-test"), nullValue());
+       }
+
+       @Test
+       public void stringOptionIsAdded() {
+               Option<String> stringOption = mock(Option.class);
+               options.addStringOption("test", stringOption);
+               assertThat(options.getStringOption("test"), is(stringOption));
+               assertThat(options.getStringOption("not-test"), nullValue());
+       }
+
+       @Test
+       public void enumOptionIsAdded() {
+               Option<TestEnum> enumOption = mock(Option.class);
+               options.addEnumOption("test", enumOption);
+               assertThat(options.<TestEnum>getEnumOption("test"), is(enumOption));
+               assertThat(options.<TestEnum>getEnumOption("not-test"), nullValue());
+       }
+
+       private enum TestEnum {TEST, NOT_TEST}
+
+}