Search in sources :

Example 1 with BusinessObjectDataStorageUnitCreateResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse 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);
}
Also used : BusinessObjectDataStorageUnitKey(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey) StorageFileEntity(org.finra.herd.model.jpa.StorageFileEntity) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) BusinessObjectDataStorageUnitCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest) BusinessObjectDataStorageUnitCreateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse) StorageFile(org.finra.herd.model.api.xml.StorageFile) StorageEntity(org.finra.herd.model.jpa.StorageEntity) StorageDirectory(org.finra.herd.model.api.xml.StorageDirectory) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 2 with BusinessObjectDataStorageUnitCreateResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse in project herd by FINRAOS.

the class AddBusinessObjectDataStorageUnit method executeImpl.

@Override
public void executeImpl(DelegateExecution execution) throws Exception {
    // Get expression variables from the execution.
    String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim();
    String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectDataStorageUnitCreateRequest, execution, "BusinessObjectDataStorageUnitCreateRequest").trim();
    // Create a business object data storage unit create request.
    BusinessObjectDataStorageUnitCreateRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectDataStorageUnitCreateRequest.class);
    // Call the business object data storage unit service.
    BusinessObjectDataStorageUnitCreateResponse businessObjectDataStorageUnitCreateResponse = businessObjectDataStorageUnitService.createBusinessObjectDataStorageUnit(request);
    // Set the JSON response as a workflow variable.
    setJsonResponseAsWorkflowVariable(businessObjectDataStorageUnitCreateResponse, execution);
}
Also used : BusinessObjectDataStorageUnitCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest) BusinessObjectDataStorageUnitCreateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse)

Example 3 with BusinessObjectDataStorageUnitCreateResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse in project herd by FINRAOS.

the class BusinessObjectDataStorageUnitServiceImpl method createBusinessObjectDataStorageUnitCreateResponse.

/**
 * Creates and populates a business object data storage unit create response.
 *
 * @param storageUnitEntity the storage unit entity
 *
 * @return the business object data storage unit create response
 */
protected BusinessObjectDataStorageUnitCreateResponse createBusinessObjectDataStorageUnitCreateResponse(StorageUnitEntity storageUnitEntity) {
    // Get business object data key from the business object data entity.
    BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper.createBusinessObjectDataKeyFromEntity(storageUnitEntity.getBusinessObjectData());
    // Create a business object data storage unit create response.
    BusinessObjectDataStorageUnitCreateResponse response = new BusinessObjectDataStorageUnitCreateResponse();
    // Add business object data storage unit key.
    response.setBusinessObjectDataStorageUnitKey(storageUnitHelper.createBusinessObjectDataStorageUnitKey(businessObjectDataKey, storageUnitEntity.getStorage().getName()));
    // Add storage directory.
    if (storageUnitEntity.getDirectoryPath() != null) {
        response.setStorageDirectory(new StorageDirectory(storageUnitEntity.getDirectoryPath()));
    }
    // Add storage files.
    if (CollectionUtils.isNotEmpty(storageUnitEntity.getStorageFiles())) {
        response.setStorageFiles(storageFileHelper.createStorageFilesFromEntities(storageUnitEntity.getStorageFiles()));
    }
    // Return the response.
    return response;
}
Also used : BusinessObjectDataStorageUnitCreateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse) StorageDirectory(org.finra.herd.model.api.xml.StorageDirectory) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Example 4 with BusinessObjectDataStorageUnitCreateResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse 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);
}
Also used : BusinessObjectDataStorageUnitKey(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey) BusinessObjectDataStorageUnitCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest) BusinessObjectDataStorageUnitCreateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse) StorageFile(org.finra.herd.model.api.xml.StorageFile) StorageDirectory(org.finra.herd.model.api.xml.StorageDirectory) Test(org.junit.Test)

Example 5 with BusinessObjectDataStorageUnitCreateResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse in project herd by FINRAOS.

the class BusinessObjectDataStorageUnitServiceImplTest method testCreateBusinessObjectDataStorageUnitCreateResponseDirectoryOnlyRegistration.

@Test
public void testCreateBusinessObjectDataStorageUnitCreateResponseDirectoryOnlyRegistration() {
    // 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(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS);
    storageUnitEntity.setDirectoryPath(STORAGE_DIRECTORY_PATH);
    // Create an expected business object data storage unit response.
    BusinessObjectDataStorageUnitCreateResponse expectedResponse = new BusinessObjectDataStorageUnitCreateResponse(businessObjectDataStorageUnitKey, new StorageDirectory(STORAGE_DIRECTORY_PATH), null);
    // Mock the external calls.
    when(businessObjectDataHelper.createBusinessObjectDataKeyFromEntity(storageUnitEntity.getBusinessObjectData())).thenReturn(businessObjectDataKey);
    when(storageUnitHelper.createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME)).thenReturn(businessObjectDataStorageUnitKey);
    // Call the method under test.
    BusinessObjectDataStorageUnitCreateResponse result = businessObjectDataStorageUnitServiceImpl.createBusinessObjectDataStorageUnitCreateResponse(storageUnitEntity);
    // Verify the external calls.
    verify(businessObjectDataHelper).createBusinessObjectDataKeyFromEntity(storageUnitEntity.getBusinessObjectData());
    verify(storageUnitHelper).createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(expectedResponse, result);
}
Also used : BusinessObjectDataStorageUnitKey(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) BusinessObjectDataStorageUnitCreateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse) StorageDirectory(org.finra.herd.model.api.xml.StorageDirectory) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Aggregations

BusinessObjectDataStorageUnitCreateResponse (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateResponse)5 StorageDirectory (org.finra.herd.model.api.xml.StorageDirectory)4 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)3 BusinessObjectDataStorageUnitCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest)3 BusinessObjectDataStorageUnitKey (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey)3 Test (org.junit.Test)3 StorageFile (org.finra.herd.model.api.xml.StorageFile)2 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)2 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)2 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)1 StorageEntity (org.finra.herd.model.jpa.StorageEntity)1 StorageFileEntity (org.finra.herd.model.jpa.StorageFileEntity)1