test_class.declarator: alternateKeyHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private AlternateKeyHelper alternateKeyHelper;
test_class.type: AlternateKeyHelper
test_class.var_name: alternateKeyHelper
test_class.declarator: businessObjectDataHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private BusinessObjectDataHelper businessObjectDataHelper;
test_class.type: BusinessObjectDataHelper
test_class.var_name: businessObjectDataHelper
test_class.declarator: storageFileHelper
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private StorageFileHelper storageFileHelper;
test_class.type: StorageFileHelper
test_class.var_name: storageFileHelper
test_class.declarator: storageUnitHelper
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private StorageUnitHelper storageUnitHelper;
test_class.type: StorageUnitHelper
test_class.var_name: storageUnitHelper
test_class.file: herd-code/herd-service/src/test/java/org/finra/herd/service/helper/StorageUnitHelperTest.java
test_class.identifier: StorageUnitHelperTest
test_class.superclass: extends AbstractServiceTest
test_case.body: @Test
      public void testCreateStorageUnitsFromEntities()
      {
          // Create a business object data storage unit key.
          BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey =
              new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE,
                  SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME);
  
          // Create a storage file entity with a file path that does not start with storage unit directory path.
          StorageFileEntity storageFileOneEntity = new StorageFileEntity();
          storageFileOneEntity.setStorageUnit(null);
          storageFileOneEntity.setPath(FILE_NAME);
          storageFileOneEntity.setFileSizeBytes(FILE_SIZE);
          storageFileOneEntity.setRowCount(ROW_COUNT);
  
          // Create a storage file entity with a file path that starts with the storage unit directory path.
          StorageFileEntity storageFileTwoEntity = new StorageFileEntity();
          storageFileTwoEntity.setStorageUnit(null);
          storageFileTwoEntity.setPath(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME_2);
          storageFileTwoEntity.setFileSizeBytes(FILE_SIZE_2);
          storageFileTwoEntity.setRowCount(ROW_COUNT_2);
  
          // Create an expiration timestamp for restoration.
          final Timestamp restoredExpirationOn = new Timestamp(new Date().getTime());
  
          // Create a storage unit entity.
          StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS);
          storageUnitEntity.setDirectoryPath(STORAGE_DIRECTORY_PATH);
          storageUnitEntity.setStorageFiles(Lists.newArrayList(storageFileOneEntity, storageFileTwoEntity));
          storageUnitEntity.setStoragePolicyTransitionFailedAttempts(STORAGE_POLICY_TRANSITION_FAILED_ATTEMPTS);
          storageUnitEntity.setRestoreExpirationOn(restoredExpirationOn);
  
          // Mock the external calls.
          when(storageFileHelper.createStorageFileFromEntity(any(StorageFileEntity.class), eq(STORAGE_DIRECTORY_PATH))).thenCallRealMethod();
  
          // Call the method under test.
          List<StorageUnit> result =
              storageUnitHelper.createStorageUnitsFromEntities(Collections.singletonList(storageUnitEntity), NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY,
                      NO_EXCLUDE_BUSINESS_OBJECT_DATA_STORAGE_FILES);
  
          // Verify the external calls.
          verify(storageFileHelper).createStorageFileFromEntity(storageFileOneEntity, STORAGE_DIRECTORY_PATH);
          verify(storageFileHelper).createStorageFileFromEntity(storageFileTwoEntity, STORAGE_DIRECTORY_PATH);
          verifyNoMoreInteractionsHelper();
  
          // Validate the results.
          assertEquals(Collections.singletonList(
              new StorageUnit(new Storage(STORAGE_NAME, StoragePlatformEntity.S3, null), new StorageDirectory(STORAGE_DIRECTORY_PATH), Lists
                  .newArrayList(new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT),
                      new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME_2, FILE_SIZE_2, ROW_COUNT_2)), STORAGE_UNIT_STATUS, NO_STORAGE_UNIT_STATUS_HISTORY,
                  STORAGE_POLICY_TRANSITION_FAILED_ATTEMPTS, HerdDateUtils.getXMLGregorianCalendarValue(restoredExpirationOn))), result);
      }
test_case.class_method_signature: StorageUnitHelperTest.testCreateStorageUnitsFromEntities()
test_case.full_signature: @Test public void testCreateStorageUnitsFromEntities()
test_case.identifier: testCreateStorageUnitsFromEntities
test_case.invocations: setStorageUnit setPath setFileSizeBytes setRowCount setStorageUnit setPath setFileSizeBytes setRowCount getTime createStorageUnitEntity setDirectoryPath setStorageFiles newArrayList setStoragePolicyTransitionFailedAttempts setRestoreExpirationOn thenCallRealMethod when createStorageFileFromEntity any eq createStorageUnitsFromEntities singletonList createStorageFileFromEntity verify createStorageFileFromEntity verify verifyNoMoreInteractionsHelper assertEquals singletonList newArrayList getXMLGregorianCalendarValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCreateStorageUnitsFromEntities()
focal_class.declarator: alternateKeyHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private AlternateKeyHelper alternateKeyHelper;
focal_class.type: AlternateKeyHelper
focal_class.var_name: alternateKeyHelper
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: storageFileHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private StorageFileHelper storageFileHelper;
focal_class.type: StorageFileHelper
focal_class.var_name: storageFileHelper
focal_class.file: herd-code/herd-service/src/main/java/org/finra/herd/service/helper/StorageUnitHelper.java
focal_class.identifier: StorageUnitHelper
focal_class.class_method_signature: StorageUnitHelper.createBusinessObjectDataStorageUnitKey(BusinessObjectDataKey businessObjectDataKey, String storageName)
focal_class.full_signature: public BusinessObjectDataStorageUnitKey createBusinessObjectDataStorageUnitKey(BusinessObjectDataKey businessObjectDataKey, String storageName)
focal_class.identifier: createBusinessObjectDataStorageUnitKey
focal_class.modifiers: public
focal_class.parameters: (BusinessObjectDataKey businessObjectDataKey, String storageName)
focal_class.return: BusinessObjectDataStorageUnitKey
focal_class.signature: BusinessObjectDataStorageUnitKey createBusinessObjectDataStorageUnitKey(BusinessObjectDataKey businessObjectDataKey, String storageName)
focal_class.class_method_signature: StorageUnitHelper.createStorageUnitKey(BusinessObjectDataKey businessObjectDataKey, String storageName)
focal_class.full_signature: public BusinessObjectDataStorageUnitKey createStorageUnitKey(BusinessObjectDataKey businessObjectDataKey, String storageName)
focal_class.identifier: createStorageUnitKey
focal_class.modifiers: public
focal_class.parameters: (BusinessObjectDataKey businessObjectDataKey, String storageName)
focal_class.return: BusinessObjectDataStorageUnitKey
focal_class.signature: BusinessObjectDataStorageUnitKey createStorageUnitKey(BusinessObjectDataKey businessObjectDataKey, String storageName)
focal_class.class_method_signature: StorageUnitHelper.createStorageUnitKeyFromEntity(StorageUnitEntity storageUnitEntity)
focal_class.full_signature: public BusinessObjectDataStorageUnitKey createStorageUnitKeyFromEntity(StorageUnitEntity storageUnitEntity)
focal_class.identifier: createStorageUnitKeyFromEntity
focal_class.modifiers: public
focal_class.parameters: (StorageUnitEntity storageUnitEntity)
focal_class.return: BusinessObjectDataStorageUnitKey
focal_class.signature: BusinessObjectDataStorageUnitKey createStorageUnitKeyFromEntity(StorageUnitEntity storageUnitEntity)
focal_class.class_method_signature: StorageUnitHelper.createStorageUnitsFromEntities(Collection<StorageUnitEntity> storageUnitEntities, Boolean includeStorageUnitStatusHistory,
          Boolean excludeBusinessObjectDataStorageFiles)
focal_class.full_signature:  List<StorageUnit> createStorageUnitsFromEntities(Collection<StorageUnitEntity> storageUnitEntities, Boolean includeStorageUnitStatusHistory,
          Boolean excludeBusinessObjectDataStorageFiles)
focal_class.identifier: createStorageUnitsFromEntities
focal_class.parameters: (Collection<StorageUnitEntity> storageUnitEntities, Boolean includeStorageUnitStatusHistory,
          Boolean excludeBusinessObjectDataStorageFiles)
focal_class.return: List<StorageUnit>
focal_class.signature: List<StorageUnit> createStorageUnitsFromEntities(Collection<StorageUnitEntity> storageUnitEntities, Boolean includeStorageUnitStatusHistory,
          Boolean excludeBusinessObjectDataStorageFiles)
focal_class.class_method_signature: StorageUnitHelper.excludeBusinessObjectDataStatus(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
          String excludedBusinessObjectDataStatus)
focal_class.full_signature: public List<StorageUnitAvailabilityDto> excludeBusinessObjectDataStatus(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
          String excludedBusinessObjectDataStatus)
focal_class.identifier: excludeBusinessObjectDataStatus
focal_class.modifiers: public
focal_class.parameters: (List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
          String excludedBusinessObjectDataStatus)
focal_class.return: List<StorageUnitAvailabilityDto>
focal_class.signature: List<StorageUnitAvailabilityDto> excludeBusinessObjectDataStatus(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
          String excludedBusinessObjectDataStatus)
focal_class.class_method_signature: StorageUnitHelper.excludePartitions(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
          List<List<String>> excludedPartitions)
focal_class.full_signature: public List<StorageUnitAvailabilityDto> excludePartitions(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
          List<List<String>> excludedPartitions)
focal_class.identifier: excludePartitions
focal_class.modifiers: public
focal_class.parameters: (List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
          List<List<String>> excludedPartitions)
focal_class.return: List<StorageUnitAvailabilityDto>
focal_class.signature: List<StorageUnitAvailabilityDto> excludePartitions(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos,
          List<List<String>> excludedPartitions)
focal_class.class_method_signature: StorageUnitHelper.getBusinessObjectDataKey(BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey)
focal_class.full_signature: public BusinessObjectDataKey getBusinessObjectDataKey(BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey)
focal_class.identifier: getBusinessObjectDataKey
focal_class.modifiers: public
focal_class.parameters: (BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey)
focal_class.return: BusinessObjectDataKey
focal_class.signature: BusinessObjectDataKey getBusinessObjectDataKey(BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey)
focal_class.class_method_signature: StorageUnitHelper.getStorageUnitIds(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos)
focal_class.full_signature: public List<Integer> getStorageUnitIds(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos)
focal_class.identifier: getStorageUnitIds
focal_class.modifiers: public
focal_class.parameters: (List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos)
focal_class.return: List<Integer>
focal_class.signature: List<Integer> getStorageUnitIds(List<StorageUnitAvailabilityDto> storageUnitAvailabilityDtos)
focal_class.class_method_signature: StorageUnitHelper.validateBusinessObjectDataStorageUnitKey(BusinessObjectDataStorageUnitKey key)
focal_class.full_signature: public void validateBusinessObjectDataStorageUnitKey(BusinessObjectDataStorageUnitKey key)
focal_class.identifier: validateBusinessObjectDataStorageUnitKey
focal_class.modifiers: public
focal_class.parameters: (BusinessObjectDataStorageUnitKey key)
focal_class.return: void
focal_class.signature: void validateBusinessObjectDataStorageUnitKey(BusinessObjectDataStorageUnitKey key)
focal_method.body: List<StorageUnit> createStorageUnitsFromEntities(Collection<StorageUnitEntity> storageUnitEntities, Boolean includeStorageUnitStatusHistory,
          Boolean excludeBusinessObjectDataStorageFiles)
      {
          List<StorageUnit> storageUnits = new ArrayList<>();
  
          for (StorageUnitEntity storageUnitEntity : storageUnitEntities)
          {
              StorageUnit storageUnit = new StorageUnit();
              storageUnits.add(storageUnit);
  
              Storage storage = new Storage();
              storageUnit.setStorage(storage);
  
              StorageEntity storageEntity = storageUnitEntity.getStorage();
              storage.setName(storageEntity.getName());
              storage.setStoragePlatformName(storageEntity.getStoragePlatform().getName());
  
              // Add the storage attributes.
              if (!CollectionUtils.isEmpty(storageEntity.getAttributes()))
              {
                  List<Attribute> storageAttributes = new ArrayList<>();
                  storage.setAttributes(storageAttributes);
                  for (StorageAttributeEntity storageAttributeEntity : storageEntity.getAttributes())
                  {
                      Attribute attribute = new Attribute();
                      storageAttributes.add(attribute);
                      attribute.setName(storageAttributeEntity.getName());
                      attribute.setValue(storageAttributeEntity.getValue());
                  }
              }
  
              // Add the storage directory.
              if (storageUnitEntity.getDirectoryPath() != null)
              {
                  StorageDirectory storageDirectory = new StorageDirectory();
                  storageUnit.setStorageDirectory(storageDirectory);
                  storageDirectory.setDirectoryPath(storageUnitEntity.getDirectoryPath());
              }
  
              // Add the storage files, is they are not excluded and present in the database.
              if (BooleanUtils.isNotTrue(excludeBusinessObjectDataStorageFiles) && CollectionUtils.isNotEmpty(storageUnitEntity.getStorageFiles()))
              {
                  List<StorageFile> storageFiles = new ArrayList<>();
                  storageUnit.setStorageFiles(storageFiles);
  
                  for (StorageFileEntity storageFileEntity : storageUnitEntity.getStorageFiles())
                  {
                      storageFiles.add(storageFileHelper.createStorageFileFromEntity(storageFileEntity, storageUnitEntity.getDirectoryPath()));
                  }
              }
  
              // Set the storage unit status.
              storageUnit.setStorageUnitStatus(storageUnitEntity.getStatus().getCode());
  
              // If specified, add storage unit status history.
              if (BooleanUtils.isTrue(includeStorageUnitStatusHistory))
              {
                  List<StorageUnitStatusChangeEvent> storageUnitStatusChangeEvents = new ArrayList<>();
                  storageUnit.setStorageUnitStatusHistory(storageUnitStatusChangeEvents);
                  for (StorageUnitStatusHistoryEntity storageUnitStatusHistoryEntity : storageUnitEntity.getHistoricalStatuses())
                  {
                      storageUnitStatusChangeEvents.add(new StorageUnitStatusChangeEvent(storageUnitStatusHistoryEntity.getStatus().getCode(),
                          HerdDateUtils.getXMLGregorianCalendarValue(storageUnitStatusHistoryEntity.getCreatedOn()),
                          storageUnitStatusHistoryEntity.getCreatedBy()));
                  }
              }
  
              // Set the number of failed attempts to execute a storage policy transition.
              storageUnit.setStoragePolicyTransitionFailedAttempts(storageUnitEntity.getStoragePolicyTransitionFailedAttempts());
  
              if (storageUnitEntity.getRestoreExpirationOn() != null)
              {
                  storageUnit.setRestoreExpirationOn(HerdDateUtils.getXMLGregorianCalendarValue(storageUnitEntity.getRestoreExpirationOn()));
              }
          }
  
          return storageUnits;
      }
focal_method.class_method_signature: StorageUnitHelper.createStorageUnitsFromEntities(Collection<StorageUnitEntity> storageUnitEntities, Boolean includeStorageUnitStatusHistory,
          Boolean excludeBusinessObjectDataStorageFiles)
focal_method.full_signature:  List<StorageUnit> createStorageUnitsFromEntities(Collection<StorageUnitEntity> storageUnitEntities, Boolean includeStorageUnitStatusHistory,
          Boolean excludeBusinessObjectDataStorageFiles)
focal_method.identifier: createStorageUnitsFromEntities
focal_method.invocations: add setStorage getStorage setName getName setStoragePlatformName getName getStoragePlatform isEmpty getAttributes setAttributes getAttributes add setName getName setValue getValue getDirectoryPath setStorageDirectory setDirectoryPath getDirectoryPath isNotTrue isNotEmpty getStorageFiles setStorageFiles getStorageFiles add createStorageFileFromEntity getDirectoryPath setStorageUnitStatus getCode getStatus isTrue setStorageUnitStatusHistory getHistoricalStatuses add getCode getStatus getXMLGregorianCalendarValue getCreatedOn getCreatedBy setStoragePolicyTransitionFailedAttempts getStoragePolicyTransitionFailedAttempts getRestoreExpirationOn setRestoreExpirationOn getXMLGregorianCalendarValue getRestoreExpirationOn
focal_method.parameters: (Collection<StorageUnitEntity> storageUnitEntities, Boolean includeStorageUnitStatusHistory,
          Boolean excludeBusinessObjectDataStorageFiles)
focal_method.return: List<StorageUnit>
focal_method.signature: List<StorageUnit> createStorageUnitsFromEntities(Collection<StorageUnitEntity> storageUnitEntities, Boolean includeStorageUnitStatusHistory,
          Boolean excludeBusinessObjectDataStorageFiles)