Search in sources :

Example 26 with BusinessObjectDataCreateRequest

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));
}
Also used : BusinessObjectDataKeyComparator(org.finra.herd.service.helper.BusinessObjectDataKeyComparator) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) StorageUnitCreateRequest(org.finra.herd.model.api.xml.StorageUnitCreateRequest) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 27 with BusinessObjectDataCreateRequest

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);
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) Test(org.junit.Test)

Example 28 with BusinessObjectDataCreateRequest

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;
}
Also used : BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) ArrayList(java.util.ArrayList) StorageEntity(org.finra.herd.model.jpa.StorageEntity) StorageDirectory(org.finra.herd.model.api.xml.StorageDirectory) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) StorageFile(org.finra.herd.model.api.xml.StorageFile) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) StorageUnitCreateRequest(org.finra.herd.model.api.xml.StorageUnitCreateRequest) BusinessObjectDataStorageUnitCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest)

Example 29 with 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;
}
Also used : BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) ArrayList(java.util.ArrayList) StorageDirectory(org.finra.herd.model.api.xml.StorageDirectory) StorageUnitCreateRequest(org.finra.herd.model.api.xml.StorageUnitCreateRequest) BusinessObjectDataStorageUnitCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest)

Example 30 with 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);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Aggregations

BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)56 Test (org.junit.Test)50 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)18 ArrayList (java.util.ArrayList)16 StorageUnitCreateRequest (org.finra.herd.model.api.xml.StorageUnitCreateRequest)14 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)11 StorageFile (org.finra.herd.model.api.xml.StorageFile)11 Attribute (org.finra.herd.model.api.xml.Attribute)10 StorageDirectory (org.finra.herd.model.api.xml.StorageDirectory)9 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)6 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)6 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)5 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)4 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)3 StorageEntity (org.finra.herd.model.jpa.StorageEntity)3 HashMap (java.util.HashMap)2 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 BusinessObjectDataStorageUnitCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 Storage (org.finra.herd.model.api.xml.Storage)2