@Test public void testSetPreferences() { XenonConfiguration g = new XenonConfiguration(); ImmutableMap<String, String> prefs = ImmutableMap.of("mykey", "myval"); g.setPreferences(prefs); assertThat(g.getPreferences()).isEqualTo(prefs); }
@Test public void testToString() throws URISyntaxException { XenonConfiguration config = sampleConfig(); String expected = "XenonConfiguration{SchedulerConfiguration{local, multi, null, null}, SandboxConfiguration{file, /tmp/sandboxes, null, null}, {xenon.adaptors.local.queue.multi.maxConcurrentJobs=1}, PollConfiguration{30000, 3600000, 43200000}}"; assertThat(config.toString()).isEqualTo(expected); }
@Test public void testGetPreferences_Filled() throws URISyntaxException { ImmutableMap<String, String> prefs = ImmutableMap.of("xenon.adaptors.local.queue.multi.maxConcurrentJobs", "1"); XenonConfiguration config = sampleConfig(); assertThat(config.getPreferences()).isEqualTo(prefs); }
@Test public void deserializesFromJson() throws IOException, URISyntaxException { XenonConfiguration actual = fromJson(jsonFixture("fixtures/xenon.json"), XenonConfiguration.class); ImmutableMap<String, String> emptyProps = ImmutableMap.of(); SchedulerConfiguration expectedScheduler = new SchedulerConfiguration("local", null, "multi", emptyProps); assertThat(actual.getScheduler()).isEqualTo(expectedScheduler); SandboxConfiguration expectedSandbox = new SandboxConfiguration("file", "/", "/tmp/sandboxes", emptyProps); assertThat(actual.getSandbox()).isEqualTo(expectedSandbox); ImmutableMap<String, String> prefs = ImmutableMap.of("xenon.adaptors.local.queue.multi.maxConcurrentJobs", "4"); assertThat(actual.getPreferences()).isEqualTo(prefs); PollConfiguration expected_poll = new PollConfiguration(500, 3600000, 43200000); assertThat(actual.getPoll()).isEqualTo(expected_poll); }
@Test public void testGetPreferences_Empty() { XenonConfiguration g = new XenonConfiguration(); ImmutableMap<String, String> expected = ImmutableMap.of(); assertThat(g.getPreferences()).isEqualTo(expected); }
@Test public void testEquals_SameContent_equal() throws URISyntaxException { XenonConfiguration config1 = sampleConfig(); XenonConfiguration config2 = sampleConfig(); assertThat(config1.equals(config2)).isTrue(); }
@Test public void testEquals_DiffClass_unequal() throws URISyntaxException { XenonConfiguration config = sampleConfig(); URI uri = new URI("local:///"); assertThat(config.equals(uri)).isFalse(); }
@Test public void testEquals_SameObj_equal() throws URISyntaxException { XenonConfiguration config = sampleConfig(); assertThat(config.equals(config)).isTrue(); }
@Test public void testHashCode() throws URISyntaxException { XenonConfiguration config = sampleConfig(); int expected = -318369353; assertThat(config.hashCode()).isEqualTo(expected); }