use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class UpdateBusinessObjectDataStorageUnitStatus method executeImpl.
@Override
public void executeImpl(DelegateExecution execution) throws Exception {
String namespace = activitiHelper.getExpressionVariableAsString(this.namespace, execution);
String businessObjectDefinitionName = activitiHelper.getExpressionVariableAsString(this.businessObjectDefinitionName, execution);
String businessObjectFormatUsage = activitiHelper.getExpressionVariableAsString(this.businessObjectFormatUsage, execution);
String businessObjectFormatFileType = activitiHelper.getExpressionVariableAsString(this.businessObjectFormatFileType, execution);
Integer businessObjectFormatVersion = activitiHelper.getExpressionVariableAsInteger(this.businessObjectFormatVersion, execution, "businessObjectFormatVersion", true);
String partitionValue = activitiHelper.getExpressionVariableAsString(this.partitionValue, execution);
String subPartitionValuesString = activitiHelper.getExpressionVariableAsString(this.subPartitionValues, execution);
List<String> subPartitionValues = daoHelper.splitStringWithDefaultDelimiterEscaped(subPartitionValuesString);
String storageName = activitiHelper.getExpressionVariableAsString(this.storageName, execution);
Integer businessObjectDataVersion = activitiHelper.getExpressionVariableAsInteger(this.businessObjectDataVersion, execution, "businessObjectDataVersion", true);
String businessObjectDataStorageUnitStatus = activitiHelper.getExpressionVariableAsString(this.businessObjectDataStorageUnitStatus, execution);
BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey();
businessObjectDataStorageUnitKey.setNamespace(namespace);
businessObjectDataStorageUnitKey.setBusinessObjectDefinitionName(businessObjectDefinitionName);
businessObjectDataStorageUnitKey.setBusinessObjectFormatUsage(businessObjectFormatUsage);
businessObjectDataStorageUnitKey.setBusinessObjectFormatFileType(businessObjectFormatFileType);
businessObjectDataStorageUnitKey.setBusinessObjectFormatVersion(businessObjectFormatVersion);
businessObjectDataStorageUnitKey.setPartitionValue(partitionValue);
businessObjectDataStorageUnitKey.setSubPartitionValues(subPartitionValues);
businessObjectDataStorageUnitKey.setBusinessObjectDataVersion(businessObjectDataVersion);
businessObjectDataStorageUnitKey.setStorageName(storageName);
BusinessObjectDataStorageUnitStatusUpdateResponse businessObjectDataStorageUnitStatusUpdateResponse = businessObjectDataStorageUnitStatusService.updateBusinessObjectDataStorageUnitStatus(businessObjectDataStorageUnitKey, new BusinessObjectDataStorageUnitStatusUpdateRequest(businessObjectDataStorageUnitStatus));
// Create a storage unit notification.
notificationEventService.processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG, storageUnitHelper.getBusinessObjectDataKey(businessObjectDataStorageUnitStatusUpdateResponse.getBusinessObjectDataStorageUnitKey()), businessObjectDataStorageUnitStatusUpdateResponse.getBusinessObjectDataStorageUnitKey().getStorageName(), businessObjectDataStorageUnitStatusUpdateResponse.getStatus(), businessObjectDataStorageUnitStatusUpdateResponse.getPreviousStatus());
setJsonResponseAsWorkflowVariable(businessObjectDataStorageUnitStatusUpdateResponse, execution);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class BusinessObjectDataStorageUnitServiceImplTest method testValidateBusinessObjectDataStorageUnitCreateRequestInvalidParameters.
@Test
public void testValidateBusinessObjectDataStorageUnitCreateRequestInvalidParameters() {
// Try to call the method under test when create request is not specified.
try {
businessObjectDataStorageUnitServiceImpl.validateBusinessObjectDataStorageUnitCreateRequest(null);
fail();
} catch (IllegalArgumentException e) {
assertEquals("A business object data storage unit create request must be specified.", e.getMessage());
}
// Try to call the method under test when auto-discovery is enabled and storage directory is not specified.
try {
businessObjectDataStorageUnitServiceImpl.validateBusinessObjectDataStorageUnitCreateRequest(new BusinessObjectDataStorageUnitCreateRequest(new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME), NO_STORAGE_DIRECTORY, NO_STORAGE_FILES, DISCOVER_STORAGE_FILES));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A storage directory must be specified when discovery of storage files is enabled.", e.getMessage());
}
// Try to call the method under test when auto-discovery is enabled and storage files are specified.
try {
businessObjectDataStorageUnitServiceImpl.validateBusinessObjectDataStorageUnitCreateRequest(new BusinessObjectDataStorageUnitCreateRequest(new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME), new StorageDirectory(STORAGE_DIRECTORY_PATH), Collections.singletonList(new StorageFile(FILE_NAME, FILE_SIZE, ROW_COUNT)), DISCOVER_STORAGE_FILES));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Storage files cannot be specified when discovery of storage files is enabled.", e.getMessage());
}
// Try to call the method under test when auto-discovery is not enabled and no storage directory or files are specified.
try {
businessObjectDataStorageUnitServiceImpl.validateBusinessObjectDataStorageUnitCreateRequest(new BusinessObjectDataStorageUnitCreateRequest(new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME), NO_STORAGE_DIRECTORY, NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A storage directory or at least one storage file must be specified when discovery of storage files is not enabled.", e.getMessage());
}
// Try to call the method under test when storage directory is specified with a blank storage directory path.
try {
businessObjectDataStorageUnitServiceImpl.validateBusinessObjectDataStorageUnitCreateRequest(new BusinessObjectDataStorageUnitCreateRequest(new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME), new StorageDirectory(BLANK_TEXT), NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A storage directory path must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class BusinessObjectDataStorageUnitServiceImplTest method testValidateBusinessObjectDataStorageUnitCreateRequestDirectoryOnlyRegistration.
@Test
public void testValidateBusinessObjectDataStorageUnitCreateRequestDirectoryOnlyRegistration() {
// 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);
// Call the method under test.
businessObjectDataStorageUnitServiceImpl.validateBusinessObjectDataStorageUnitCreateRequest(new BusinessObjectDataStorageUnitCreateRequest(businessObjectDataStorageUnitKey, new StorageDirectory(STORAGE_DIRECTORY_PATH), NO_STORAGE_FILES, DISCOVER_STORAGE_FILES));
// Verify the external calls.
verify(storageUnitHelper).validateBusinessObjectDataStorageUnitKey(businessObjectDataStorageUnitKey);
verifyNoMoreInteractionsHelper();
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class BusinessObjectDataStorageUnitServiceImplTest method testCreateBusinessObjectDataStorageUnit.
@Test
public void testCreateBusinessObjectDataStorageUnit() {
// 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 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 unit directory.
StorageDirectory storageDirectory = new StorageDirectory(STORAGE_DIRECTORY_PATH);
// Create a list of storage files.
List<StorageFile> storageFiles = Arrays.asList(new StorageFile(FILE_NAME, FILE_SIZE, ROW_COUNT), new StorageFile(FILE_NAME_2, FILE_SIZE_2, ROW_COUNT_2));
// Create a business object data storage unit request.
BusinessObjectDataStorageUnitCreateRequest request = new BusinessObjectDataStorageUnitCreateRequest(businessObjectDataStorageUnitKey, storageDirectory, storageFiles, NO_DISCOVER_STORAGE_FILES);
// Create a business object data entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
businessObjectDataEntity.setId(ID);
// Create a storage entity.
StorageEntity storageEntity = new StorageEntity();
storageEntity.setName(STORAGE_NAME);
// Create a list of storage file entities.
List<StorageFileEntity> storageFileEntities = Arrays.asList(new StorageFileEntity(), new StorageFileEntity());
// Create a storage unit entity.
StorageUnitEntity storageUnitEntity = new StorageUnitEntity();
storageUnitEntity.setBusinessObjectData(businessObjectDataEntity);
storageUnitEntity.setStorage(storageEntity);
storageUnitEntity.setDirectoryPath(STORAGE_DIRECTORY_PATH);
storageUnitEntity.setStorageFiles(storageFileEntities);
// Create an expected business object data storage unit response.
BusinessObjectDataStorageUnitCreateResponse expectedResponse = new BusinessObjectDataStorageUnitCreateResponse(businessObjectDataStorageUnitKey, storageDirectory, storageFiles);
// Mock the external calls.
when(storageUnitHelper.getBusinessObjectDataKey(businessObjectDataStorageUnitKey)).thenReturn(businessObjectDataKey);
when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity);
when(storageDaoHelper.getStorageEntity(STORAGE_NAME)).thenReturn(storageEntity);
when(businessObjectDataDaoHelper.createStorageUnitEntity(businessObjectDataEntity, storageEntity, storageDirectory, storageFiles, NO_DISCOVER_STORAGE_FILES)).thenReturn(storageUnitEntity);
when(businessObjectDataHelper.createBusinessObjectDataKeyFromEntity(businessObjectDataEntity)).thenReturn(businessObjectDataKey);
when(storageUnitHelper.createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME)).thenReturn(businessObjectDataStorageUnitKey);
when(storageFileHelper.createStorageFilesFromEntities(storageFileEntities)).thenReturn(storageFiles);
// Call the method under test.
BusinessObjectDataStorageUnitCreateResponse result = businessObjectDataStorageUnitServiceImpl.createBusinessObjectDataStorageUnit(request);
// Verify the external calls.
verify(storageUnitHelper).validateBusinessObjectDataStorageUnitKey(businessObjectDataStorageUnitKey);
verify(storageFileHelper).validateCreateRequestStorageFiles(storageFiles);
verify(storageUnitHelper).getBusinessObjectDataKey(businessObjectDataStorageUnitKey);
verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey);
verify(storageDaoHelper).getStorageEntity(STORAGE_NAME);
verify(businessObjectDataDaoHelper).createStorageUnitEntity(businessObjectDataEntity, storageEntity, storageDirectory, storageFiles, NO_DISCOVER_STORAGE_FILES);
verify(businessObjectDataHelper).createBusinessObjectDataKeyFromEntity(businessObjectDataEntity);
verify(storageUnitHelper).createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME);
verify(storageFileHelper).createStorageFilesFromEntities(storageFileEntities);
verify(storageUnitDao).saveAndRefresh(storageUnitEntity);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(expectedResponse, result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class CleanupDestroyedBusinessObjectDataServiceImplTest method testCleanupS3StorageUnitWithIllegalArgumentException.
@Test
public void testCleanupS3StorageUnitWithIllegalArgumentException() {
// 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 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 mocks
BusinessObjectDataEntity businessObjectDataEntity = mock(BusinessObjectDataEntity.class);
// Create storage units
StoragePlatformEntity storagePlatformEntity = new StoragePlatformEntity();
storagePlatformEntity.setName(StoragePlatformEntity.S3);
StorageEntity storageEntity = new StorageEntity();
storageEntity.setStoragePlatform(storagePlatformEntity);
StorageUnitEntity storageUnitEntity1 = new StorageUnitEntity();
storageUnitEntity1.setStorage(storageEntity);
StorageUnitEntity storageUnitEntity2 = new StorageUnitEntity();
storageUnitEntity2.setStorage(storageEntity);
Collection<StorageUnitEntity> storageUnitEntities = Lists.newArrayList();
storageUnitEntities.add(storageUnitEntity1);
storageUnitEntities.add(storageUnitEntity2);
// Mock the external calls.
when(mockBusinessObjectDataHelper.createBusinessObjectDataKeyFromStorageUnitKey(businessObjectDataStorageUnitKey)).thenReturn(businessObjectDataKey);
when(mockBusinessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity);
when(businessObjectDataEntity.getStorageUnits()).thenReturn(storageUnitEntities);
when(mockBusinessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey)).thenReturn(businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey));
// Call the method under test.
try {
cleanupDestroyedBusinessObjectDataService.cleanupS3StorageUnit(businessObjectDataStorageUnitKey);
} catch (IllegalArgumentException illegalArgumentException) {
assertThat(illegalArgumentException.getMessage(), is(equalTo("Business object data has multiple (2) S3 storage units. Business object data: {" + businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey) + "}")));
}
// Verify the external calls.
verify(mockBusinessObjectDataHelper).createBusinessObjectDataKeyFromStorageUnitKey(businessObjectDataStorageUnitKey);
verify(mockBusinessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey);
verify(businessObjectDataEntity).getStorageUnits();
verify(mockBusinessObjectDataHelper).businessObjectDataKeyToString(businessObjectDataKey);
verifyNoMoreInteractions(businessObjectDataEntity);
verifyNoMoreInteractionsHelper();
}
Aggregations