test_class.file: herd-code/herd-service/src/test/java/org/finra/herd/service/helper/BusinessObjectDataRetryStoragePolicyTransitionHelperTest.java
test_class.identifier: BusinessObjectDataRetryStoragePolicyTransitionHelperTest
test_class.superclass: extends AbstractServiceTest
test_case.body: @Test
      public void testRetryStoragePolicyTransitionStoragePolicyNoExists()
      {
          // Create a business object data key.
          BusinessObjectDataKey businessObjectDataKey =
              new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES,
                  DATA_VERSION);
  
          // Create a storage policy key.
          StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
  
          // Create a business object data entity.
          businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
  
          // Try to execute a before step for the retry storage policy transition for a non-existing storage policy.
          try
          {
              businessObjectDataRetryStoragePolicyTransitionHelper
                  .retryStoragePolicyTransition(businessObjectDataKey, new BusinessObjectDataRetryStoragePolicyTransitionRequest(storagePolicyKey));
              fail();
          }
          catch (ObjectNotFoundException e)
          {
              assertEquals(storagePolicyServiceTestHelper.getExpectedStoragePolicyNotFoundErrorMessage(storagePolicyKey), e.getMessage());
          }
      }
test_case.class_method_signature: BusinessObjectDataRetryStoragePolicyTransitionHelperTest.testRetryStoragePolicyTransitionStoragePolicyNoExists()
test_case.full_signature: @Test public void testRetryStoragePolicyTransitionStoragePolicyNoExists()
test_case.identifier: testRetryStoragePolicyTransitionStoragePolicyNoExists
test_case.invocations: createBusinessObjectDataEntity retryStoragePolicyTransition fail assertEquals getExpectedStoragePolicyNotFoundErrorMessage getMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRetryStoragePolicyTransitionStoragePolicyNoExists()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(BusinessObjectDataRetryStoragePolicyTransitionHelper.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(BusinessObjectDataRetryStoragePolicyTransitionHelper.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: awsHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private AwsHelper awsHelper;
focal_class.type: AwsHelper
focal_class.var_name: awsHelper
focal_class.declarator: businessObjectDataDaoHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private BusinessObjectDataDaoHelper businessObjectDataDaoHelper;
focal_class.type: BusinessObjectDataDaoHelper
focal_class.var_name: businessObjectDataDaoHelper
focal_class.declarator: businessObjectDataHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private BusinessObjectDataHelper businessObjectDataHelper;
focal_class.type: BusinessObjectDataHelper
focal_class.var_name: businessObjectDataHelper
focal_class.declarator: configurationHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ConfigurationHelper configurationHelper;
focal_class.type: ConfigurationHelper
focal_class.var_name: configurationHelper
focal_class.declarator: jsonHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private JsonHelper jsonHelper;
focal_class.type: JsonHelper
focal_class.var_name: jsonHelper
focal_class.declarator: s3KeyPrefixHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private S3KeyPrefixHelper s3KeyPrefixHelper;
focal_class.type: S3KeyPrefixHelper
focal_class.var_name: s3KeyPrefixHelper
focal_class.declarator: sqsDao
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private SqsDao sqsDao;
focal_class.type: SqsDao
focal_class.var_name: sqsDao
focal_class.declarator: storagePolicyDaoHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private StoragePolicyDaoHelper storagePolicyDaoHelper;
focal_class.type: StoragePolicyDaoHelper
focal_class.var_name: storagePolicyDaoHelper
focal_class.declarator: storagePolicyHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private StoragePolicyHelper storagePolicyHelper;
focal_class.type: StoragePolicyHelper
focal_class.var_name: storagePolicyHelper
focal_class.declarator: storageUnitDao
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private StorageUnitDao storageUnitDao;
focal_class.type: StorageUnitDao
focal_class.var_name: storageUnitDao
focal_class.declarator: storageUnitDaoHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private StorageUnitDaoHelper storageUnitDaoHelper;
focal_class.type: StorageUnitDaoHelper
focal_class.var_name: storageUnitDaoHelper
focal_class.file: herd-code/herd-service/src/main/java/org/finra/herd/service/helper/BusinessObjectDataRetryStoragePolicyTransitionHelper.java
focal_class.identifier: BusinessObjectDataRetryStoragePolicyTransitionHelper
focal_class.class_method_signature: BusinessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(BusinessObjectDataKey businessObjectDataKey,
          BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_class.full_signature: public BusinessObjectData retryStoragePolicyTransition(BusinessObjectDataKey businessObjectDataKey,
          BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_class.identifier: retryStoragePolicyTransition
focal_class.modifiers: public
focal_class.parameters: (BusinessObjectDataKey businessObjectDataKey,
          BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_class.return: BusinessObjectData
focal_class.signature: BusinessObjectData retryStoragePolicyTransition(BusinessObjectDataKey businessObjectDataKey,
          BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_class.class_method_signature: BusinessObjectDataRetryStoragePolicyTransitionHelper.sendStoragePolicySelectionSqsMessage(String sqsQueueName, StoragePolicySelection storagePolicySelection)
focal_class.full_signature: protected void sendStoragePolicySelectionSqsMessage(String sqsQueueName, StoragePolicySelection storagePolicySelection)
focal_class.identifier: sendStoragePolicySelectionSqsMessage
focal_class.modifiers: protected
focal_class.parameters: (String sqsQueueName, StoragePolicySelection storagePolicySelection)
focal_class.return: void
focal_class.signature: void sendStoragePolicySelectionSqsMessage(String sqsQueueName, StoragePolicySelection storagePolicySelection)
focal_class.class_method_signature: BusinessObjectDataRetryStoragePolicyTransitionHelper.getStorageUnit(BusinessObjectDataEntity businessObjectDataEntity, StorageEntity storageEntity)
focal_class.full_signature: private StorageUnitEntity getStorageUnit(BusinessObjectDataEntity businessObjectDataEntity, StorageEntity storageEntity)
focal_class.identifier: getStorageUnit
focal_class.modifiers: private
focal_class.parameters: (BusinessObjectDataEntity businessObjectDataEntity, StorageEntity storageEntity)
focal_class.return: StorageUnitEntity
focal_class.signature: StorageUnitEntity getStorageUnit(BusinessObjectDataEntity businessObjectDataEntity, StorageEntity storageEntity)
focal_class.class_method_signature: BusinessObjectDataRetryStoragePolicyTransitionHelper.validateBusinessObjectDataRetryStoragePolicyTransitionRequest(BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_class.full_signature: private void validateBusinessObjectDataRetryStoragePolicyTransitionRequest(BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_class.identifier: validateBusinessObjectDataRetryStoragePolicyTransitionRequest
focal_class.modifiers: private
focal_class.parameters: (BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_class.return: void
focal_class.signature: void validateBusinessObjectDataRetryStoragePolicyTransitionRequest(BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_method.body: public BusinessObjectData retryStoragePolicyTransition(BusinessObjectDataKey businessObjectDataKey,
          BusinessObjectDataRetryStoragePolicyTransitionRequest request)
      {
          // Validate and trim the business object data key.
          businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, true, true);
  
          // Validate and trim the request.
          validateBusinessObjectDataRetryStoragePolicyTransitionRequest(request);
  
          // Retrieve the business object data and ensure it exists.
          BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey);
  
          // Retrieve and ensure that a storage policy exists with the specified key.
          StoragePolicyEntity storagePolicyEntity = storagePolicyDaoHelper.getStoragePolicyEntityByKey(request.getStoragePolicyKey());
  
          // Validate that storage policy filter matches this business object data, except for the storage.
          Assert.isTrue((storagePolicyEntity.getBusinessObjectDefinition() == null ||
              storagePolicyEntity.getBusinessObjectDefinition().equals(businessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition())) &&
              (StringUtils.isBlank(storagePolicyEntity.getUsage()) ||
                  storagePolicyEntity.getUsage().equalsIgnoreCase(businessObjectDataEntity.getBusinessObjectFormat().getUsage())) &&
              (storagePolicyEntity.getFileType() == null ||
                  storagePolicyEntity.getFileType().equals(businessObjectDataEntity.getBusinessObjectFormat().getFileType())), String
              .format("Business object data does not match storage policy filter. " + "Storage policy: {%s}, business object data: {%s}",
                  storagePolicyHelper.storagePolicyKeyAndVersionToString(request.getStoragePolicyKey(), storagePolicyEntity.getVersion()),
                  businessObjectDataHelper.businessObjectDataEntityAltKeyToString(businessObjectDataEntity)));
  
          // Validate the storage policy filter storage.
          storagePolicyDaoHelper.validateStoragePolicyFilterStorage(storagePolicyEntity.getStorage());
  
          // Retrieve and validate a storage unit for this business object data.
          StorageUnitEntity storageUnitEntity = getStorageUnit(businessObjectDataEntity, storagePolicyEntity.getStorage());
  
          // Get S3 key prefix for this business object data.
          String s3KeyPrefix = s3KeyPrefixHelper
              .buildS3KeyPrefix(storagePolicyEntity.getStorage(), storageUnitEntity.getBusinessObjectData().getBusinessObjectFormat(), businessObjectDataKey);
  
          // Validate that we have storage files registered in the storage.
          Assert.isTrue(CollectionUtils.isNotEmpty(storageUnitEntity.getStorageFiles()), String
              .format("Business object data has no storage files registered in \"%s\" storage. Business object data: {%s}",
                  storageUnitEntity.getStorage().getName(), businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey)));
  
          // Validate that this storage does not have any other registered storage files that
          // start with the S3 key prefix, but belong to other business object data instances.
          storageUnitDaoHelper.validateNoExplicitlyRegisteredSubPartitionInStorageForBusinessObjectData(storageUnitEntity.getStorage(),
              businessObjectDataEntity.getBusinessObjectFormat(), businessObjectDataKey, s3KeyPrefix);
  
          // Get the SQS queue name from the system configuration.
          String sqsQueueName = configurationHelper.getProperty(ConfigurationValue.STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE_NAME);
  
          // Throw IllegalStateException if SQS queue name is not defined.
          if (StringUtils.isBlank(sqsQueueName))
          {
              throw new IllegalStateException(String.format("SQS queue name not found. Ensure the \"%s\" configuration entry is configured.",
                  ConfigurationValue.STORAGE_POLICY_SELECTOR_JOB_SQS_QUEUE_NAME.getKey()));
          }
  
          // Create a storage policy selection.
          StoragePolicySelection storagePolicySelection =
              new StoragePolicySelection(businessObjectDataKey, storagePolicyHelper.getStoragePolicyKey(storagePolicyEntity), storagePolicyEntity.getVersion());
  
          // Executes SQS specific steps needed to retry a storage policy transition.
          sendStoragePolicySelectionSqsMessage(sqsQueueName, storagePolicySelection);
  
          // Create and return the business object data object from the entity.
          return businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity);
      }
focal_method.class_method_signature: BusinessObjectDataRetryStoragePolicyTransitionHelper.retryStoragePolicyTransition(BusinessObjectDataKey businessObjectDataKey,
          BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_method.full_signature: public BusinessObjectData retryStoragePolicyTransition(BusinessObjectDataKey businessObjectDataKey,
          BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_method.identifier: retryStoragePolicyTransition
focal_method.invocations: validateBusinessObjectDataKey validateBusinessObjectDataRetryStoragePolicyTransitionRequest getBusinessObjectDataEntity getStoragePolicyEntityByKey getStoragePolicyKey isTrue getBusinessObjectDefinition equals getBusinessObjectDefinition getBusinessObjectDefinition getBusinessObjectFormat isBlank getUsage equalsIgnoreCase getUsage getUsage getBusinessObjectFormat getFileType equals getFileType getFileType getBusinessObjectFormat format storagePolicyKeyAndVersionToString getStoragePolicyKey getVersion businessObjectDataEntityAltKeyToString validateStoragePolicyFilterStorage getStorage getStorageUnit getStorage buildS3KeyPrefix getStorage getBusinessObjectFormat getBusinessObjectData isTrue isNotEmpty getStorageFiles format getName getStorage businessObjectDataKeyToString validateNoExplicitlyRegisteredSubPartitionInStorageForBusinessObjectData getStorage getBusinessObjectFormat getProperty isBlank format getKey getStoragePolicyKey getVersion sendStoragePolicySelectionSqsMessage createBusinessObjectDataFromEntity
focal_method.modifiers: public
focal_method.parameters: (BusinessObjectDataKey businessObjectDataKey,
          BusinessObjectDataRetryStoragePolicyTransitionRequest request)
focal_method.return: BusinessObjectData
focal_method.signature: BusinessObjectData retryStoragePolicyTransition(BusinessObjectDataKey businessObjectDataKey,
          BusinessObjectDataRetryStoragePolicyTransitionRequest request)