use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class StorageUnitDaoTest method testGetStorageUnitByKeyNoSubPartitionValues.
@Test
public void testGetStorageUnitByKeyNoSubPartitionValues() {
// Create and persist the relative database entities.
StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, STORAGE_UNIT_STATUS, STORAGE_DIRECTORY_PATH);
// Get a storage unit.
assertEquals(storageUnitEntity, storageUnitDao.getStorageUnitByKey(new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME)));
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class BusinessObjectDataStorageUnitRestControllerTest method testCreateBusinessObjectDataStorageUnit.
@Test
public void testCreateBusinessObjectDataStorageUnit() {
// 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 = Collections.singletonList(new StorageFile(FILE_NAME, FILE_SIZE, ROW_COUNT));
// Create a business object data storage unit request.
BusinessObjectDataStorageUnitCreateRequest request = new BusinessObjectDataStorageUnitCreateRequest(businessObjectDataStorageUnitKey, storageDirectory, storageFiles, DISCOVER_STORAGE_FILES);
// Create a business object data storage unit response.
BusinessObjectDataStorageUnitCreateResponse response = new BusinessObjectDataStorageUnitCreateResponse(businessObjectDataStorageUnitKey, storageDirectory, storageFiles);
// Mock the external calls.
when(businessObjectDataStorageUnitService.createBusinessObjectDataStorageUnit(request)).thenReturn(response);
// Call the method under test.
BusinessObjectDataStorageUnitCreateResponse result = businessObjectDataStorageUnitRestController.createBusinessObjectDataStorageUnit(request);
// Verify the external calls.
verify(businessObjectDataStorageUnitService).createBusinessObjectDataStorageUnit(request);
verifyNoMoreInteractions(businessObjectDataStorageUnitService);
// Validate the results.
assertEquals(response, result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class BusinessObjectDataServiceTestHelper method getBusinessObjectDataStorageUnitCreateRequest.
public BusinessObjectDataStorageUnitCreateRequest getBusinessObjectDataStorageUnitCreateRequest() {
// Create business object data and storage entities.
BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(false);
BusinessObjectDataStatusEntity businessObjectDataStatusEntity = businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(AbstractServiceTest.BDATA_STATUS, AbstractServiceTest.DESCRIPTION, AbstractServiceTest.BDATA_STATUS_PRE_REGISTRATION_FLAG_SET);
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, AbstractServiceTest.PARTITION_VALUE, AbstractServiceTest.DATA_VERSION, AbstractServiceTest.LATEST_VERSION_FLAG_SET, businessObjectDataStatusEntity.getCode());
StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity();
// Create a business object data storage unit key.
BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(businessObjectFormatEntity.getBusinessObjectDefinition().getNamespace().getCode(), businessObjectFormatEntity.getBusinessObjectDefinition().getName(), businessObjectFormatEntity.getUsage(), businessObjectFormatEntity.getFileType().getCode(), businessObjectFormatEntity.getBusinessObjectFormatVersion(), businessObjectDataEntity.getPartitionValue(), AbstractServiceTest.NO_SUBPARTITION_VALUES, businessObjectDataEntity.getVersion(), storageEntity.getName());
// Create and return a business object data storage unit create request.
return new BusinessObjectDataStorageUnitCreateRequest(businessObjectDataStorageUnitKey, AbstractServiceTest.NO_STORAGE_DIRECTORY, getStorageFiles(), AbstractServiceTest.NO_DISCOVER_STORAGE_FILES);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class StorageUnitHelper method createStorageUnitKeyFromEntity.
/**
* Creates a storage unit key from a storage unit entity.
*
* @param storageUnitEntity the storage unit entity
*
* @return the storage unit key
*/
public BusinessObjectDataStorageUnitKey createStorageUnitKeyFromEntity(StorageUnitEntity storageUnitEntity) {
// Get the business object data entity.
BusinessObjectDataEntity businessObjectDataEntity = storageUnitEntity.getBusinessObjectData();
// Create and initialize the storage unit key.
BusinessObjectDataStorageUnitKey storageUnitKey = new BusinessObjectDataStorageUnitKey();
storageUnitKey.setNamespace(businessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition().getNamespace().getCode());
storageUnitKey.setBusinessObjectDefinitionName(businessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition().getName());
storageUnitKey.setBusinessObjectFormatUsage(businessObjectDataEntity.getBusinessObjectFormat().getUsage());
storageUnitKey.setBusinessObjectFormatFileType(businessObjectDataEntity.getBusinessObjectFormat().getFileType().getCode());
storageUnitKey.setBusinessObjectFormatVersion(businessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectFormatVersion());
storageUnitKey.setPartitionValue(businessObjectDataEntity.getPartitionValue());
storageUnitKey.setSubPartitionValues(businessObjectDataHelper.getSubPartitionValues(businessObjectDataEntity));
storageUnitKey.setBusinessObjectDataVersion(businessObjectDataEntity.getVersion());
storageUnitKey.setStorageName(storageUnitEntity.getStorage().getName());
return storageUnitKey;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey in project herd by FINRAOS.
the class GetBusinessObjectDataTest method testGetBusinessObjectDataIncludeStorageUnitStatusHistory.
@Test
public void testGetBusinessObjectDataIncludeStorageUnitStatusHistory() throws Exception {
// 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 entity.
StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, businessObjectDataKey, StorageUnitStatusEntity.DISABLED);
// Execute a storage unit status change.
businessObjectDataStorageUnitStatusService.updateBusinessObjectDataStorageUnitStatus(businessObjectDataStorageUnitKey, new BusinessObjectDataStorageUnitStatusUpdateRequest(StorageUnitStatusEntity.ENABLED));
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
fieldExtensionList.add(buildFieldExtension("subPartitionValues", "${subPartitionValues}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataStatus", "${businessObjectDataStatus}"));
fieldExtensionList.add(buildFieldExtension("includeBusinessObjectDataStatusHistory", "${includeBusinessObjectDataStatusHistory}"));
fieldExtensionList.add(buildFieldExtension("includeStorageUnitStatusHistory", "${includeStorageUnitStatusHistory}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
parameters.add(buildParameter("subPartitionValues", herdStringHelper.buildStringWithDefaultDelimiter(SUBPARTITION_VALUES)));
parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
parameters.add(buildParameter("businessObjectDataStatus", BusinessObjectDataStatusEntity.VALID));
parameters.add(buildParameter("includeBusinessObjectDataStatusHistory", NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY.toString()));
parameters.add(buildParameter("includeStorageUnitStatusHistory", INCLUDE_STORAGE_UNIT_STATUS_HISTORY.toString()));
// Build the expected response object. The storage unit history record is expected to have system username for the createdBy auditable field.
BusinessObjectData expectedBusinessObjectData = new BusinessObjectData(storageUnitEntity.getBusinessObjectData().getId(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, Arrays.asList(new StorageUnit(new Storage(STORAGE_NAME, StoragePlatformEntity.S3, null), NO_STORAGE_DIRECTORY, null, StorageUnitStatusEntity.ENABLED, Arrays.asList(new StorageUnitStatusChangeEvent(StorageUnitStatusEntity.ENABLED, HerdDateUtils.getXMLGregorianCalendarValue(IterableUtils.get(storageUnitEntity.getHistoricalStatuses(), 0).getCreatedOn()), HerdDaoSecurityHelper.SYSTEM_USER)), NO_STORAGE_POLICY_TRANSITION_FAILED_ATTEMPTS, NO_RESTORE_EXPIRATION_ON)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_BUSINESS_OBJECT_DATA_CHILDREN, NO_BUSINESS_OBJECT_DATA_STATUS_HISTORY);
// Run the activiti task and validate the returned response object.
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GetBusinessObjectDataStatus.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectData));
testActivitiServiceTaskSuccess(GetBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Aggregations