@Test public void testGetPropertyAsFloatExists() { final Configuration configuration = TestConfiguration.create("foo", "1.23"); final Optional<Float> value = configuration.getPropertyAsFloat("foo"); Assert.assertTrue(value.isPresent()); Assert.assertEquals(1.23f, value.get(), 0.001); }
@Test(expected = NumberFormatException.class) public void testGetPropertyAsFloatWithDefaultInvalid() { final Configuration configuration = TestConfiguration.create("foo", "ABC"); configuration.getPropertyAsFloat("foo", 2.46f); }
@Test public void testGetPropertyAsFloatWithDefaultMissing() { final Configuration configuration = TestConfiguration.create(); final float value = configuration.getPropertyAsFloat("foo", 2.46f); Assert.assertEquals(2.46f, value, 0.001); }
@Test public void testGetPropertyAsFloatWithDefaultExists() { final Configuration configuration = TestConfiguration.create("foo", "1.23"); final float value = configuration.getPropertyAsFloat("foo", 2.46f); Assert.assertEquals(1.23f, value, 0.001); }
@Test public void testGetPropertyAsFloatMissing() { final Configuration configuration = TestConfiguration.create(); final Optional<Float> value = configuration.getPropertyAsFloat("foo"); Assert.assertFalse(value.isPresent()); }