Search in sources :

Example 11 with BusinessObjectDataStatusUpdateRequest

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

the class UploadDownloadServiceTest method testPerformCompleteUploadSingleMessageSourceBusinessObjectDataStatusNotUploading.

@Test
public void testPerformCompleteUploadSingleMessageSourceBusinessObjectDataStatusNotUploading() {
    uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
    UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, FILE_NAME));
    String filePath = resultUploadSingleInitiationResponse.getTargetBusinessObjectData().getStorageUnits().get(0).getStorageFiles().get(0).getFilePath();
    // Create a business object data status.
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
    // Update the status of the source business object data so it would not be "UPLOADING".
    businessObjectDataStatusService.updateBusinessObjectDataStatus(businessObjectDataHelper.getBusinessObjectDataKey(resultUploadSingleInitiationResponse.getSourceBusinessObjectData()), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
    // Try to complete the upload, when source business object data status is not "UPLOADING".
    UploadDownloadServiceImpl.CompleteUploadSingleMessageResult result = uploadDownloadService.performCompleteUploadSingleMessage(filePath);
    assertEquals(BDATA_STATUS, result.getSourceOldBusinessObjectDataStatus());
    assertNull(result.getSourceNewBusinessObjectDataStatus());
    assertEquals(BusinessObjectDataStatusEntity.UPLOADING, result.getTargetOldBusinessObjectDataStatus());
    assertNull(result.getTargetNewBusinessObjectDataStatus());
}
Also used : UploadDownloadServiceImpl(org.finra.herd.service.impl.UploadDownloadServiceImpl) UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) Test(org.junit.Test)

Example 12 with BusinessObjectDataStatusUpdateRequest

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

the class UploadDownloadServiceTest method testPerformCompleteUploadSingleMessageTargetBusinessObjectDataStatusNotUploading.

@Test
public void testPerformCompleteUploadSingleMessageTargetBusinessObjectDataStatusNotUploading() {
    uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
    UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, FILE_NAME));
    String filePath = resultUploadSingleInitiationResponse.getTargetBusinessObjectData().getStorageUnits().get(0).getStorageFiles().get(0).getFilePath();
    // Create a business object data status.
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
    // Update the status of the target business object data so it would not be "UPLOADING".
    businessObjectDataStatusService.updateBusinessObjectDataStatus(businessObjectDataHelper.getBusinessObjectDataKey(resultUploadSingleInitiationResponse.getTargetBusinessObjectData()), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
    // Try to complete the upload, when target business object data status is not "UPLOADING".
    UploadDownloadServiceImpl.CompleteUploadSingleMessageResult result = uploadDownloadService.performCompleteUploadSingleMessage(filePath);
    assertEquals(BusinessObjectDataStatusEntity.UPLOADING, result.getSourceOldBusinessObjectDataStatus());
    assertNull(result.getSourceNewBusinessObjectDataStatus());
    assertEquals(BDATA_STATUS, result.getTargetOldBusinessObjectDataStatus());
    assertNull(result.getTargetNewBusinessObjectDataStatus());
}
Also used : UploadDownloadServiceImpl(org.finra.herd.service.impl.UploadDownloadServiceImpl) UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) Test(org.junit.Test)

Example 13 with BusinessObjectDataStatusUpdateRequest

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

the class BusinessObjectDataStatusServiceTest method testUpdateBusinessObjectDataStatusLowerCaseParameters.

@Test
public void testUpdateBusinessObjectDataStatusLowerCaseParameters() {
    // Create and persist relative test entities.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS.toUpperCase());
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS_2.toUpperCase());
    // Update the business object data status using lower case input parameters (except for case-sensitive partition values).
    BusinessObjectDataStatusUpdateResponse response = businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS_2.toLowerCase()));
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectDataStatusUpdateResponse(new BusinessObjectDataKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), BDATA_STATUS_2.toUpperCase(), BDATA_STATUS.toUpperCase(), response);
}
Also used : BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 14 with BusinessObjectDataStatusUpdateRequest

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

the class BusinessObjectDataStatusServiceTest method testUpdateBusinessObjectDataStatusBusinessObjectDataNoExists.

@Test
public void testUpdateBusinessObjectDataStatusBusinessObjectDataNoExists() {
    // Try to update a business object data status using non-existing business object data.
    businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
    try {
        businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
        fail("Should throw an ObjectNotFoundException when business object data does not exist.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 15 with BusinessObjectDataStatusUpdateRequest

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

the class BusinessObjectDataStatusServiceTest method testUpdateBusinessObjectDataStatusNoStatusChange.

@Test
public void testUpdateBusinessObjectDataStatusNoStatusChange() {
    // Create and persist relative test entities.
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
    // Update the business object data status.
    BusinessObjectDataStatusUpdateResponse response = businessObjectDataStatusService.updateBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), new BusinessObjectDataStatusUpdateRequest(BDATA_STATUS));
    // Validate the returned object.
    businessObjectDataServiceTestHelper.validateBusinessObjectDataStatusUpdateResponse(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), BDATA_STATUS, BDATA_STATUS, response);
}
Also used : BusinessObjectDataStatusUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest) BusinessObjectDataStatusUpdateResponse(org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectDataStatusUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateRequest)16 Test (org.junit.Test)14 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)13 BusinessObjectDataStatusUpdateResponse (org.finra.herd.model.api.xml.BusinessObjectDataStatusUpdateResponse)10 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3 UploadSingleInitiationResponse (org.finra.herd.model.api.xml.UploadSingleInitiationResponse)2 UploadDownloadServiceImpl (org.finra.herd.service.impl.UploadDownloadServiceImpl)2 StringWriter (java.io.StringWriter)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 HttpPut (org.apache.http.client.methods.HttpPut)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 StringEntity (org.apache.http.entity.StringEntity)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1