ConfigurationHelper { public BigDecimal getNonNegativeBigDecimalRequiredProperty(ConfigurationValue configurationValue) { return getNonNegativeBigDecimalRequiredProperty(configurationValue, environment); }  static String getProperty(ConfigurationValue configurationValue, Environment environment); static T getProperty(ConfigurationValue configurationValue, Class<T> targetType, Environment environment); BigDecimal getBigDecimalRequiredProperty(ConfigurationValue configurationValue); BigDecimal getBigDecimalRequiredProperty(ConfigurationValue configurationValue, Environment environment); Boolean getBooleanProperty(ConfigurationValue configurationValue); Boolean getBooleanProperty(ConfigurationValue configurationValue, Environment environment); BigDecimal getNonNegativeBigDecimalRequiredProperty(ConfigurationValue configurationValue); BigDecimal getNonNegativeBigDecimalRequiredProperty(ConfigurationValue configurationValue, Environment environment); String getProperty(ConfigurationValue configurationValue); T getProperty(ConfigurationValue configurationValue, Class<T> targetType); String getPropertyAsString(ConfigurationValue configurationValue); String getRequiredProperty(ConfigurationValue configurationValue); String getRequiredProperty(ConfigurationValue configurationValue, Environment environment);  }
@Test public void testGetNonNegativeBigDecimalRequiredPropertyValuePositiveValue() { ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE; MockEnvironment environment = new MockEnvironment(); environment.setProperty(configurationValue.getKey(), "1.00"); assertEquals(new BigDecimal("1.00"), configurationHelper.getNonNegativeBigDecimalRequiredProperty(configurationValue, environment)); }
@Test public void testGetNonNegativeBigDecimalRequiredPropertyValueZeroValue() { ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE; MockEnvironment environment = new MockEnvironment(); environment.setProperty(configurationValue.getKey(), "0"); assertEquals(new BigDecimal("0"), configurationHelper.getNonNegativeBigDecimalRequiredProperty(configurationValue, environment)); }
@Test public void testGetNonNegativeBigDecimalRequiredPropertyValueNegativeValueFail() { ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE; MockEnvironment environment = new MockEnvironment(); environment.setProperty(configurationValue.getKey(), "-1.00"); try { configurationHelper.getNonNegativeBigDecimalRequiredProperty(configurationValue, environment); fail("Should throw an IllegalStatueException when property value is not BigDecimal."); } catch (IllegalStateException e) { assertEquals(String.format("Configuration \"%s\" has an invalid non-negative BigDecimal value: \"-1.00\".", configurationValue.getKey()), e.getMessage()); } }
@Test public void testGetNonNegativeBigDecimalRequiredPropertyValidationThrowsWhenConfigurationValueIsNull() { try { configurationHelper.getNonNegativeBigDecimalRequiredProperty(null); fail("Should throw an IllegalStateException when configuration value is null."); } catch (IllegalStateException e) { assertEquals("configurationValue is required", e.getMessage()); } }
@Test public void testGetNonNegativeBigDecimalRequiredPropertyValueBlankStringValue() { ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE; MockEnvironment environment = new MockEnvironment(); environment.setProperty(configurationValue.getKey(), " "); try { configurationHelper.getNonNegativeBigDecimalRequiredProperty(configurationValue, environment); fail("Should throw an IllegalStatueException when property value is not BigDecimal."); } catch (IllegalStateException e) { assertEquals(String.format("Configuration \"%s\" must have a value.", configurationValue.getKey()), e.getMessage()); } }