@Test public void testGetPropertyAsIntegerExists() { final Configuration configuration = TestConfiguration.create("foo", "1"); final Optional<Integer> value = configuration.getPropertyAsInteger("foo"); Assert.assertTrue(value.isPresent()); Assert.assertEquals(1L, value.get().longValue()); }
@Test(expected = NumberFormatException.class) public void testGetPropertyAsIntegerWithDefaultInvalid() { final Configuration configuration = TestConfiguration.create("foo", "ABC"); configuration.getPropertyAsInteger("foo", 2); }
@Test public void testGetPropertyAsIntegerWithDefaultMissing() { final Configuration configuration = TestConfiguration.create(); final int value = configuration.getPropertyAsInteger("foo", 2); Assert.assertEquals(2, value); }
@Test public void testGetPropertyAsIntegerMissing() { final Configuration configuration = TestConfiguration.create(); final Optional<Integer> value = configuration.getPropertyAsInteger("foo"); Assert.assertFalse(value.isPresent()); }