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());
}
}
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());
}
}
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();
}
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);
}
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);
}
Aggregations