/** * Gets a property value and validates that it is not blank or null. * * @param configurationValue {@link ConfigurationValue} * * @return the string value */ public String getRequiredProperty(ConfigurationValue configurationValue) { return getRequiredProperty(configurationValue, environment); }
/** * Gets a property value and validates that it is not blank or null. * * @param configurationValue {@link ConfigurationValue} * * @return the string value */ public String getRequiredProperty(ConfigurationValue configurationValue) { return getRequiredProperty(configurationValue, environment); }
/** * Gets a property value as a {@link BigDecimal}. * * @param configurationValue the {@link BigDecimal} configuration value * @param environment the environment containing the property * * @return the {@link BigDecimal} property value */ public BigDecimal getBigDecimalRequiredProperty(ConfigurationValue configurationValue, Environment environment) { String bigDecimalStringValue = getRequiredProperty(configurationValue, environment); BigDecimal bigDecimalValue = null; try { // Converts the string value to BigDecimal bigDecimalValue = new BigDecimal(bigDecimalStringValue); } catch (NumberFormatException numberFormatException) { logErrorAndThrowIllegalStateException(configurationValue, "BigDecimal", bigDecimalStringValue, numberFormatException); } return bigDecimalValue; }
/** * Gets a property value as a {@link BigDecimal}. * * @param configurationValue the {@link BigDecimal} configuration value * @param environment the environment containing the property * * @return the {@link BigDecimal} property value */ public BigDecimal getBigDecimalRequiredProperty(ConfigurationValue configurationValue, Environment environment) { String bigDecimalStringValue = getRequiredProperty(configurationValue, environment); BigDecimal bigDecimalValue = null; try { // Converts the string value to BigDecimal bigDecimalValue = new BigDecimal(bigDecimalStringValue); } catch (NumberFormatException numberFormatException) { logErrorAndThrowIllegalStateException(configurationValue, "BigDecimal", bigDecimalStringValue, numberFormatException); } return bigDecimalValue; }
@Test public void testGetRequiredProperty() { ConfigurationValue configurationValue = ConfigurationValue.HERD_ENVIRONMENT; String value = configurationHelper.getRequiredProperty(configurationValue); assertEquals(configurationValue.getDefaultValue(), value); }
@Test public void testGetRequiredPropertyIllegalStateException() { ConfigurationValue configurationValue = ConfigurationValue.HERD_ENVIRONMENT; MockEnvironment environment = new MockEnvironment(); environment.setProperty(configurationValue.getKey(), BLANK_TEXT); try { configurationHelper.getRequiredProperty(configurationValue, environment); fail(); } catch (IllegalStateException e) { assertEquals(String.format("Configuration \"%s\" must have a value.", ConfigurationValue.HERD_ENVIRONMENT.getKey()), e.getMessage()); } } }
when(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME)).thenReturn(S3_ATTRIBUTE_NAME_BUCKET_NAME); when(storageHelper.getStorageAttributeValueByName(S3_ATTRIBUTE_NAME_BUCKET_NAME, storageEntity, true)).thenReturn(S3_BUCKET_NAME); when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_TAG_KEY)).thenReturn(S3_OBJECT_TAG_KEY); when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_TAG_VALUE)).thenReturn(S3_OBJECT_TAG_VALUE); when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_ARN)).thenReturn(S3_OBJECT_TAGGER_ROLE_ARN); when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_SESSION_NAME)) .thenReturn(S3_OBJECT_TAGGER_ROLE_SESSION_NAME); when(storageUnitDaoHelper.getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity)).thenReturn(storageUnitEntity); verify(configurationHelper).getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME); verify(storageHelper).getStorageAttributeValueByName(S3_ATTRIBUTE_NAME_BUCKET_NAME, storageEntity, true); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_TAG_KEY); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_TAG_VALUE); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_ARN); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_SESSION_NAME); verify(storageUnitDaoHelper).getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity); verify(s3KeyPrefixHelper).buildS3KeyPrefix(storageEntity, businessObjectFormatEntity, businessObjectDataKey);
when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_TAG_KEY)).thenReturn(S3_OBJECT_TAG_KEY); when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_TAG_VALUE)).thenReturn(S3_OBJECT_TAG_VALUE); when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_ARN)).thenReturn(S3_OBJECT_TAGGER_ROLE_ARN); when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_SESSION_NAME)).thenReturn(S3_OBJECT_TAGGER_ROLE_SESSION_NAME); when(herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS)) .thenReturn(BDATA_FINAL_DESTROY_DELAY_IN_DAYS); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_TAG_KEY); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_TAG_VALUE); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_ARN); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_SESSION_NAME); verify(herdStringHelper).getConfigurationValueAsInteger(ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS); verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey);
String s3ObjectTagKey = configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_TAG_KEY); String s3ObjectTagValue = configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_TAG_VALUE); String s3ObjectTaggerRoleArn = configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_ARN); String s3ObjectTaggerRoleSessionName = configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_SESSION_NAME);
String s3ObjectTagKey = configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_TAG_KEY); String s3ObjectTagValue = configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_TAG_VALUE); String s3ObjectTaggerRoleArn = configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_ARN); String s3ObjectTaggerRoleSessionName = configurationHelper.getRequiredProperty(ConfigurationValue.S3_ARCHIVE_TO_GLACIER_ROLE_SESSION_NAME);
String s3ObjectTagKey = configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_TAG_KEY); String s3ObjectTagValue = configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_TAG_VALUE); String s3ObjectTaggerRoleArn = configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_ARN); String s3ObjectTaggerRoleSessionName = configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_SESSION_NAME);
String s3ObjectTagKey = configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_TAG_KEY); String s3ObjectTagValue = configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_TAG_VALUE); String s3ObjectTaggerRoleArn = configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_ARN); String s3ObjectTaggerRoleSessionName = configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_SESSION_NAME);