Search in sources :

Example 51 with BusinessObjectData

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

the class UploadDownloadServiceTest method testInitiateDownloadSingleBusinessObjectDataNoExists.

@Test
public void testInitiateDownloadSingleBusinessObjectDataNoExists() {
    String INVALID_PARTITION_VALUE = "DOES_NOT_EXIST";
    // Create the upload data.
    UploadSingleInitiationResponse uploadSingleInitiationResponse = uploadDownloadServiceTestHelper.createUploadedFileData(BusinessObjectDataStatusEntity.VALID);
    // Change the target business object data partition value to something invalid.
    uploadSingleInitiationResponse.getTargetBusinessObjectData().setPartitionValue(INVALID_PARTITION_VALUE);
    // Try to initiate a single file download when business object data does not exist (i.e. the partition value doesn't match).
    try {
        // Initiate the download against the uploaded data (i.e. the target business object data).
        initiateDownload(uploadSingleInitiationResponse.getTargetBusinessObjectData());
        fail("Suppose to throw an ObjectNotFoundException when business object data does not exist.");
    } catch (ObjectNotFoundException e) {
        BusinessObjectData businessObjectData = uploadSingleInitiationResponse.getTargetBusinessObjectData();
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(businessObjectData.getNamespace(), businessObjectData.getBusinessObjectDefinitionName(), businessObjectData.getBusinessObjectFormatUsage(), businessObjectData.getBusinessObjectFormatFileType(), businessObjectData.getBusinessObjectFormatVersion(), INVALID_PARTITION_VALUE, NO_SUBPARTITION_VALUES, businessObjectData.getVersion(), null), e.getMessage());
    }
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) Test(org.junit.Test)

Example 52 with BusinessObjectData

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

the class UploadDownloadServiceTest method testExtendUploadSingleCredentialsBusinessObjectDataNoExists.

@Test
public void testExtendUploadSingleCredentialsBusinessObjectDataNoExists() {
    String INVALID_PARTITION_VALUE = "DOES_NOT_EXIST";
    // Create the upload data.
    UploadSingleInitiationResponse uploadSingleInitiationResponse = uploadDownloadServiceTestHelper.createUploadedFileData(BusinessObjectDataStatusEntity.VALID);
    // Change the source business object data partition value to something invalid.
    uploadSingleInitiationResponse.getSourceBusinessObjectData().setPartitionValue(INVALID_PARTITION_VALUE);
    // Try to initiate a single file download when business object data does not exist (i.e. the partition value doesn't match).
    try {
        extendUploadSingleCredentials(uploadSingleInitiationResponse.getSourceBusinessObjectData());
        fail("Suppose to throw an ObjectNotFoundException when business object data does not exist.");
    } catch (ObjectNotFoundException e) {
        BusinessObjectData businessObjectData = uploadSingleInitiationResponse.getSourceBusinessObjectData();
        assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(businessObjectData.getNamespace(), businessObjectData.getBusinessObjectDefinitionName(), businessObjectData.getBusinessObjectFormatUsage(), businessObjectData.getBusinessObjectFormatFileType(), businessObjectData.getBusinessObjectFormatVersion(), INVALID_PARTITION_VALUE, NO_SUBPARTITION_VALUES, businessObjectData.getVersion(), null), e.getMessage());
    }
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) UploadSingleInitiationResponse(org.finra.herd.model.api.xml.UploadSingleInitiationResponse) Test(org.junit.Test)

Example 53 with BusinessObjectData

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

the class BusinessObjectDataRestControllerTest method testUpdateBusinessObjectDataAttributes.

@Test
public void testUpdateBusinessObjectDataAttributes() {
    // Create a list of business object data keys with all possible number of sub-partition values.
    List<BusinessObjectDataKey> businessObjectDataKeys = new ArrayList<>();
    for (int subPartitionValuesCount = 0; subPartitionValuesCount <= SUBPARTITION_VALUES.size(); subPartitionValuesCount++) {
        businessObjectDataKeys.add(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.subList(0, subPartitionValuesCount), DATA_VERSION));
    }
    // Create a business object data attributes update request.
    BusinessObjectDataAttributesUpdateRequest businessObjectDataAttributesUpdateRequest = new BusinessObjectDataAttributesUpdateRequest(Collections.singletonList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE)));
    // Create a list of business object data instances one per business object data key.
    List<BusinessObjectData> businessObjectDataList = new ArrayList<>();
    for (BusinessObjectDataKey businessObjectDataKey : businessObjectDataKeys) {
        BusinessObjectData businessObjectData = new BusinessObjectData();
        businessObjectData.setNamespace(businessObjectDataKey.getNamespace());
        businessObjectData.setBusinessObjectDefinitionName(businessObjectDataKey.getBusinessObjectDefinitionName());
        businessObjectData.setBusinessObjectFormatUsage(businessObjectDataKey.getBusinessObjectFormatUsage());
        businessObjectData.setBusinessObjectFormatFileType(businessObjectDataKey.getBusinessObjectFormatFileType());
        businessObjectData.setBusinessObjectFormatVersion(businessObjectDataKey.getBusinessObjectFormatVersion());
        businessObjectData.setPartitionValue(businessObjectDataKey.getPartitionValue());
        businessObjectData.setSubPartitionValues(businessObjectDataKey.getSubPartitionValues());
        businessObjectData.setVersion(businessObjectDataKey.getBusinessObjectDataVersion());
        businessObjectDataList.add(businessObjectData);
    }
    // Mock the external calls.
    for (int subPartitionValuesCount = 0; subPartitionValuesCount <= SUBPARTITION_VALUES.size(); subPartitionValuesCount++) {
        when(businessObjectDataService.updateBusinessObjectDataAttributes(businessObjectDataKeys.get(subPartitionValuesCount), businessObjectDataAttributesUpdateRequest)).thenReturn(businessObjectDataList.get(subPartitionValuesCount));
    }
    // Call the methods under test and validate the results.
    assertEquals(businessObjectDataList.get(0), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, businessObjectDataAttributesUpdateRequest));
    assertEquals(businessObjectDataList.get(1), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.get(0), DATA_VERSION, businessObjectDataAttributesUpdateRequest));
    assertEquals(businessObjectDataList.get(2), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), DATA_VERSION, businessObjectDataAttributesUpdateRequest));
    assertEquals(businessObjectDataList.get(3), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), SUBPARTITION_VALUES.get(2), DATA_VERSION, businessObjectDataAttributesUpdateRequest));
    assertEquals(businessObjectDataList.get(4), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), SUBPARTITION_VALUES.get(2), SUBPARTITION_VALUES.get(3), DATA_VERSION, businessObjectDataAttributesUpdateRequest));
    // Verify the external calls.
    for (BusinessObjectDataKey businessObjectDataKey : businessObjectDataKeys) {
        verify(businessObjectDataService).updateBusinessObjectDataAttributes(businessObjectDataKey, businessObjectDataAttributesUpdateRequest);
    }
    verifyNoMoreInteractionsHelper();
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ArrayList(java.util.ArrayList) BusinessObjectDataAttributesUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDataAttributesUpdateRequest) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 54 with BusinessObjectData

use of org.finra.herd.model.api.xml.BusinessObjectData 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 55 with BusinessObjectData

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

the class BusinessObjectDataRestControllerTest method testDestroyBusinessObjectData.

@Test
public void testDestroyBusinessObjectData() {
    // 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.
    BusinessObjectData businessObjectData = new BusinessObjectData();
    // Mock the external calls.
    when(businessObjectDataService.destroyBusinessObjectData(businessObjectDataKey)).thenReturn(businessObjectData);
    // Call the method under test.
    BusinessObjectData result = businessObjectDataRestController.destroyBusinessObjectData(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, getDelimitedFieldValues(SUBPARTITION_VALUES));
    // Verify the external calls.
    verify(businessObjectDataService).destroyBusinessObjectData(businessObjectDataKey);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(businessObjectData, result);
}
Also used : BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)150 Test (org.junit.Test)121 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)64 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)57 ArrayList (java.util.ArrayList)39 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)29 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)25 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)19 Storage (org.finra.herd.model.api.xml.Storage)19 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)16 Attribute (org.finra.herd.model.api.xml.Attribute)15 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)14 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)12 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)11 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)9 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)8 UploaderInputManifestDto (org.finra.herd.model.dto.UploaderInputManifestDto)8 IOException (java.io.IOException)7 BusinessObjectDataRetryStoragePolicyTransitionRequest (org.finra.herd.model.api.xml.BusinessObjectDataRetryStoragePolicyTransitionRequest)7 BusinessObjectDataSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)7