1 package net.pterodactylus.sone.core;
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;
8 import net.pterodactylus.sone.utils.Option;
10 import org.junit.Test;
13 * Unit test for {@link Options}.
15 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
17 public class OptionsTest {
19 private final Options options = new Options();
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());
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());
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());
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());
53 private enum TestEnum {TEST, NOT_TEST}