ConfigurationHelper { public BigDecimal getBigDecimalRequiredProperty(ConfigurationValue configurationValue) { return getBigDecimalRequiredProperty(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 testGetBigDecimalRequiredPropertyValue() { ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE; MockEnvironment environment = new MockEnvironment(); environment.setProperty(configurationValue.getKey(), "0.05"); assertEquals(new BigDecimal("0.05"), configurationHelper.getBigDecimalRequiredProperty(configurationValue, environment)); }
@Test public void testGetBigDecimalRequiredPropertyValueConversionFail() { ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE; MockEnvironment environment = new MockEnvironment(); environment.setProperty(configurationValue.getKey(), "INVALID_BigDecimal_VALUE"); try { configurationHelper.getBigDecimalRequiredProperty(configurationValue, environment); fail("Should throw an IllegalStatueException when property value is not BigDecimal."); } catch (IllegalStateException e) { assertEquals(String.format("Configuration \"%s\" has an invalid BigDecimal value: \"INVALID_BigDecimal_VALUE\".", configurationValue.getKey()), e.getMessage()); } }
@Test public void testGetBigDecimalRequiredPropertyValueBlankStringValue() { ConfigurationValue configurationValue = ConfigurationValue.EMR_CLUSTER_LOWEST_CORE_INSTANCE_PRICE_PERCENTAGE; MockEnvironment environment = new MockEnvironment(); environment.setProperty(configurationValue.getKey(), " "); try { configurationHelper.getBigDecimalRequiredProperty(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()); } }
@Test public void testGetBigDecimalRequiredPropertyValidationThrowsWhenConfigurationValueIsNull() { try { configurationHelper.getBigDecimalRequiredProperty(null); fail("Should throw an IllegalStateException when configuration value is null."); } catch (IllegalStateException e) { assertEquals("configurationValue is required", e.getMessage()); } }