@Test public void testGetPropertyAsDoubleExists() { final Configuration configuration = TestConfiguration.create("foo", "1.23"); final Optional<Double> value = configuration.getPropertyAsDouble("foo"); Assert.assertTrue(value.isPresent()); Assert.assertEquals(1.23d, value.get(), 0.001); }
@Test(expected = NumberFormatException.class) public void testGetPropertyAsDoubleWithDefaultInvalid() { final Configuration configuration = TestConfiguration.create("foo", "ABC"); configuration.getPropertyAsDouble("foo", 2.46d); }
@Test public void testGetPropertyAsDoubleWithDefaultMissing() { final Configuration configuration = TestConfiguration.create(); final double value = configuration.getPropertyAsDouble("foo", 2.46d); Assert.assertEquals(2.46d, value, 0.001); }
@Test public void testGetPropertyAsDoubleMissing() { final Configuration configuration = TestConfiguration.create(); final Optional<Double> value = configuration.getPropertyAsDouble("foo"); Assert.assertFalse(value.isPresent()); }