use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceGetBusinessObjectDataTest method testGetBusinessObjectDataUsingCreateRequest.
@Test
public void testGetBusinessObjectDataUsingCreateRequest() {
BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest();
StorageUnitCreateRequest storageUnit = request.getStorageUnits().get(0);
// Create the business object data.
businessObjectDataService.createBusinessObjectData(request);
// Retrieve the business object data.
BusinessObjectData businessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(request.getNamespace(), request.getBusinessObjectDefinitionName(), request.getBusinessObjectFormatUsage(), request.getBusinessObjectFormatFileType(), request.getBusinessObjectFormatVersion(), request.getPartitionValue(), request.getSubPartitionValues(), INITIAL_DATA_VERSION), request.getPartitionKey(), NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
// Verify the results.
assertNotNull(businessObjectData);
assertNotNull(businessObjectData.getId());
assertTrue(businessObjectData.getBusinessObjectDefinitionName().equals(request.getBusinessObjectDefinitionName()));
assertTrue(businessObjectData.getBusinessObjectFormatUsage().equals(request.getBusinessObjectFormatUsage()));
assertTrue(businessObjectData.getBusinessObjectFormatFileType().equals(request.getBusinessObjectFormatFileType()));
assertTrue(businessObjectData.getBusinessObjectFormatVersion() == request.getBusinessObjectFormatVersion());
assertTrue(businessObjectData.getPartitionValue().equals(request.getPartitionValue()));
assertTrue(businessObjectData.getSubPartitionValues().equals(request.getSubPartitionValues()));
assertTrue(businessObjectData.getVersion() == INITIAL_DATA_VERSION);
assertTrue(businessObjectData.isLatestVersion());
List<StorageUnit> storageUnits = businessObjectData.getStorageUnits();
assertTrue(storageUnits.size() == 1);
StorageUnit resultStorageUnit = storageUnits.get(0);
assertTrue(resultStorageUnit.getStorage().getName().equals(storageUnit.getStorageName()));
// Check if result storage directory path matches to the directory path from the request.
assertEquals(storageUnit.getStorageDirectory(), resultStorageUnit.getStorageDirectory());
// Check if result list of storage files matches to the list from the create request.
businessObjectDataServiceTestHelper.validateStorageFiles(resultStorageUnit.getStorageFiles(), storageUnit.getStorageFiles());
// Check if result list of attributes matches to the list from the create request.
businessObjectDefinitionServiceTestHelper.validateAttributes(request.getAttributes(), businessObjectData.getAttributes());
// Validate the parents.
assertTrue(businessObjectData.getBusinessObjectDataParents().size() == 2);
Collections.sort(request.getBusinessObjectDataParents(), new BusinessObjectDataKeyComparator());
assertEquals(request.getBusinessObjectDataParents(), businessObjectData.getBusinessObjectDataParents());
// Ensure no children exist since the entity is new.
assertTrue(businessObjectData.getBusinessObjectDataChildren().size() == 0);
// Get one of the parents.
BusinessObjectDataKey businessObjectDataParentKey = request.getBusinessObjectDataParents().get(0);
// Retrieve the business object data for the parent.
BusinessObjectData businessObjectDataParent = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(businessObjectDataParentKey.getNamespace(), businessObjectDataParentKey.getBusinessObjectDefinitionName(), businessObjectDataParentKey.getBusinessObjectFormatUsage(), businessObjectDataParentKey.getBusinessObjectFormatFileType(), businessObjectDataParentKey.getBusinessObjectFormatVersion(), businessObjectDataParentKey.getPartitionValue(), businessObjectDataParentKey.getSubPartitionValues(), businessObjectDataParentKey.getBusinessObjectDataVersion()), request.getPartitionKey(), NO_BDATA_STATUS, NO_INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
// Ensure that the parent contains a single child record and that it is equal to our original business object data we created.
assertTrue(businessObjectDataParent.getBusinessObjectDataChildren().size() == 1);
assertEquals(businessObjectDataHelper.createBusinessObjectDataKey(businessObjectData), businessObjectDataParent.getBusinessObjectDataChildren().get(0));
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataRestControllerTest method testCreateBusinessObjectData.
@Test
public void testCreateBusinessObjectData() {
// Create a business object data create request.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = new BusinessObjectDataCreateRequest();
// Create a business object data.
BusinessObjectData businessObjectData = new BusinessObjectData();
// Mock the external calls.
when(businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest)).thenReturn(businessObjectData);
// Call the method under test.
BusinessObjectData result = businessObjectDataRestController.createBusinessObjectData(businessObjectDataCreateRequest);
// Verify the external calls.
verify(businessObjectDataService).createBusinessObjectData(businessObjectDataCreateRequest);
verify(businessObjectDataDaoHelper).triggerNotificationsForCreateBusinessObjectData(businessObjectData);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(businessObjectData, result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceTestHelper method getNewBusinessObjectDataCreateRequest.
/**
* Gets a newly created business object data create request.
*
* @param includeAttributes If true, attribute definitions and attributes will be included. Otherwise, not.
*
* @return the business object create request.
*/
public BusinessObjectDataCreateRequest getNewBusinessObjectDataCreateRequest(boolean includeAttributes) {
// Crete a test business object format (and associated data).
BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(includeAttributes);
StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity();
// Create a request to create business object data.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = new BusinessObjectDataCreateRequest();
businessObjectDataCreateRequest.setNamespace(businessObjectFormatEntity.getBusinessObjectDefinition().getNamespace().getCode());
businessObjectDataCreateRequest.setBusinessObjectDefinitionName(businessObjectFormatEntity.getBusinessObjectDefinition().getName());
businessObjectDataCreateRequest.setBusinessObjectFormatUsage(businessObjectFormatEntity.getUsage());
businessObjectDataCreateRequest.setBusinessObjectFormatFileType(businessObjectFormatEntity.getFileType().getCode());
businessObjectDataCreateRequest.setBusinessObjectFormatVersion(businessObjectFormatEntity.getBusinessObjectFormatVersion());
businessObjectDataCreateRequest.setPartitionKey(businessObjectFormatEntity.getPartitionKey());
businessObjectDataCreateRequest.setPartitionValue(AbstractServiceTest.PARTITION_VALUE);
businessObjectDataCreateRequest.setSubPartitionValues(AbstractServiceTest.SUBPARTITION_VALUES);
List<StorageUnitCreateRequest> storageUnits = new ArrayList<>();
businessObjectDataCreateRequest.setStorageUnits(storageUnits);
StorageUnitCreateRequest storageUnit = new StorageUnitCreateRequest();
storageUnits.add(storageUnit);
storageUnit.setStorageName(storageEntity.getName());
StorageDirectory storageDirectory = new StorageDirectory();
storageUnit.setStorageDirectory(storageDirectory);
storageDirectory.setDirectoryPath("Folder");
List<StorageFile> storageFiles = new ArrayList<>();
storageUnit.setStorageFiles(storageFiles);
StorageFile storageFile1 = new StorageFile();
storageFiles.add(storageFile1);
storageFile1.setFilePath("Folder/file1.gz");
storageFile1.setFileSizeBytes(0L);
storageFile1.setRowCount(0L);
StorageFile storageFile2 = new StorageFile();
storageFiles.add(storageFile2);
storageFile2.setFilePath("Folder/file2.gz");
storageFile2.setFileSizeBytes(2999L);
storageFile2.setRowCount(1000L);
StorageFile storageFile3 = new StorageFile();
storageFiles.add(storageFile3);
storageFile3.setFilePath("Folder/file3.gz");
storageFile3.setFileSizeBytes(Long.MAX_VALUE);
storageFile3.setRowCount(Long.MAX_VALUE);
if (includeAttributes) {
businessObjectDataCreateRequest.setAttributes(businessObjectDefinitionServiceTestHelper.getNewAttributes());
}
List<BusinessObjectDataKey> businessObjectDataParents = new ArrayList<>();
businessObjectDataCreateRequest.setBusinessObjectDataParents(businessObjectDataParents);
// Create 2 parents.
for (int i = 0; i < 2; i++) {
BusinessObjectDataEntity parentBusinessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity();
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey();
businessObjectDataKey.setNamespace(parentBusinessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition().getNamespace().getCode());
businessObjectDataKey.setBusinessObjectDefinitionName(parentBusinessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition().getName());
businessObjectDataKey.setBusinessObjectFormatUsage(parentBusinessObjectDataEntity.getBusinessObjectFormat().getUsage());
businessObjectDataKey.setBusinessObjectFormatFileType(parentBusinessObjectDataEntity.getBusinessObjectFormat().getFileType().getCode());
businessObjectDataKey.setBusinessObjectFormatVersion(parentBusinessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectFormatVersion());
businessObjectDataKey.setPartitionValue(parentBusinessObjectDataEntity.getPartitionValue());
businessObjectDataKey.setBusinessObjectDataVersion(parentBusinessObjectDataEntity.getVersion());
businessObjectDataKey.setSubPartitionValues(businessObjectDataHelper.getSubPartitionValues(parentBusinessObjectDataEntity));
businessObjectDataParents.add(businessObjectDataKey);
}
return businessObjectDataCreateRequest;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceTestHelper method createBusinessObjectDataCreateRequest.
/**
* Returns a newly created business object data create request.
*
* @param namespaceCode the namespace code
* @param businessObjectDefinitionName the business object definition name
* @param businessObjectFormatUsage the business object format usage
* @param businessObjectFormatFileType the business object format file type
* @param businessObjectFormatVersion the business object format version
* @param partitionKey the partition key
* @param partitionValue the partition value
* @param storageName the storage name
* @param storageDirectoryPath the storage directory path
* @param storageFiles the list of storage files
*
* @return the business object create request
*/
public BusinessObjectDataCreateRequest createBusinessObjectDataCreateRequest(String namespaceCode, String businessObjectDefinitionName, String businessObjectFormatUsage, String businessObjectFormatFileType, Integer businessObjectFormatVersion, String partitionKey, String partitionValue, String businessObjectDataStatusCode, String storageName, String storageDirectoryPath, List<StorageFile> storageFiles) {
// Create a business object data create request.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = new BusinessObjectDataCreateRequest();
businessObjectDataCreateRequest.setNamespace(namespaceCode);
businessObjectDataCreateRequest.setBusinessObjectDefinitionName(businessObjectDefinitionName);
businessObjectDataCreateRequest.setBusinessObjectFormatUsage(businessObjectFormatUsage);
businessObjectDataCreateRequest.setBusinessObjectFormatFileType(businessObjectFormatFileType);
businessObjectDataCreateRequest.setBusinessObjectFormatVersion(businessObjectFormatVersion);
businessObjectDataCreateRequest.setPartitionKey(partitionKey);
businessObjectDataCreateRequest.setPartitionValue(partitionValue);
businessObjectDataCreateRequest.setStatus(businessObjectDataStatusCode);
List<StorageUnitCreateRequest> storageUnits = new ArrayList<>();
businessObjectDataCreateRequest.setStorageUnits(storageUnits);
StorageUnitCreateRequest storageUnit = new StorageUnitCreateRequest();
storageUnits.add(storageUnit);
storageUnit.setStorageName(storageName);
if (storageDirectoryPath != null) {
StorageDirectory storageDirectory = new StorageDirectory();
storageUnit.setStorageDirectory(storageDirectory);
storageDirectory.setDirectoryPath(storageDirectoryPath);
}
storageUnit.setStorageFiles(storageFiles);
return businessObjectDataCreateRequest;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class RegisterBusinessObjectDataTest method testRegisterBusinessObjectDataXml.
@Test
public void testRegisterBusinessObjectDataXml() throws Exception {
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest();
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataCreateRequest", "${businessObjectDataCreateRequest}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("contentType", "xml"));
parameters.add(buildParameter("businessObjectDataCreateRequest", xmlHelper.objectToXml(businessObjectDataCreateRequest)));
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(RegisterBusinessObjectData.VARIABLE_ID, VARIABLE_VALUE_NOT_NULL);
variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, VARIABLE_VALUE_NOT_NULL);
testActivitiServiceTaskSuccess(RegisterBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Aggregations