use of org.finra.herd.model.api.xml.BusinessObjectDataStatusInformation in project herd by FINRAOS.
the class GetBusinessObjectDataStatusTest method testGetBusinessObjectDataStatusMissingOptionalParameters.
@Test
public void testGetBusinessObjectDataStatusMissingOptionalParameters() throws Exception {
// Create a business object data key without sub-partition values.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION);
// Create a business object data entity.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
// Build the expected response object.
BusinessObjectDataStatusInformation expectedBusinessObjectDataStatusInformation = new BusinessObjectDataStatusInformation(businessObjectDataKey, BDATA_STATUS);
// Run the activiti task and validate the returned response object.
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GetBusinessObjectDataStatus.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectDataStatusInformation));
testActivitiServiceTaskSuccess(GetBusinessObjectDataStatus.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusInformation in project herd by FINRAOS.
the class BusinessObjectDataStatusServiceImpl method getBusinessObjectDataStatusImpl.
/**
* Retrieves status information for an existing business object data.
*
* @param businessObjectDataKey the business object data key
* @param businessObjectFormatPartitionKey the business object format partition key
*
* @return the retrieved business object data status information
*/
protected BusinessObjectDataStatusInformation getBusinessObjectDataStatusImpl(BusinessObjectDataKey businessObjectDataKey, String businessObjectFormatPartitionKey) {
String businessObjectFormatPartitionKeyLocal = businessObjectFormatPartitionKey;
// Validate and trim the business object data key.
businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, false, false);
// If specified, trim the partition key parameter.
if (businessObjectFormatPartitionKeyLocal != null) {
businessObjectFormatPartitionKeyLocal = businessObjectFormatPartitionKeyLocal.trim();
}
// Get the business object data based on the specified parameters.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey);
// If specified, ensure that partition key matches what's configured within the business object format.
if (StringUtils.isNotBlank(businessObjectFormatPartitionKeyLocal)) {
String configuredPartitionKey = businessObjectDataEntity.getBusinessObjectFormat().getPartitionKey();
Assert.isTrue(configuredPartitionKey.equalsIgnoreCase(businessObjectFormatPartitionKeyLocal), String.format("Partition key \"%s\" doesn't match configured business object format partition key \"%s\".", businessObjectFormatPartitionKeyLocal, configuredPartitionKey));
}
// Create and return the business object data status information object.
BusinessObjectDataStatusInformation businessObjectDataStatusInformation = new BusinessObjectDataStatusInformation();
businessObjectDataStatusInformation.setBusinessObjectDataKey(businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity));
businessObjectDataStatusInformation.setStatus(businessObjectDataEntity.getStatus().getCode());
return businessObjectDataStatusInformation;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusInformation in project herd by FINRAOS.
the class BusinessObjectDataStatusServiceTest method testGetBusinessObjectDataStatusTrimParameters.
@Test
public void testGetBusinessObjectDataStatusTrimParameters() {
// Create and persist database entities required for testing.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
// Get the business object data status information using input parameters with leading and trailing empty spaces.
BusinessObjectDataStatusInformation resultBusinessObjectDataStatusInformation = businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), FORMAT_VERSION, addWhitespace(PARTITION_VALUE), addWhitespace(SUBPARTITION_VALUES), DATA_VERSION), addWhitespace(PARTITION_KEY));
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectDataStatusInformation(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), BDATA_STATUS, resultBusinessObjectDataStatusInformation);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusInformation in project herd by FINRAOS.
the class BusinessObjectDataStatusServiceTest method testGetBusinessObjectDataStatusInvalidParameters.
@Test
public void testGetBusinessObjectDataStatusInvalidParameters() {
// Create and persist a valid business object data.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
// Get the business object data status information.
BusinessObjectDataStatusInformation resultBusinessObjectDataStatusInformation = businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY);
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectDataStatusInformation(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), BDATA_STATUS, resultBusinessObjectDataStatusInformation);
// Try to perform a get business object data status using invalid business object definition name.
try {
businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a get business object data status using invalid format usage.
try {
businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a get business object data status using invalid format file type.
try {
businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a get business object data status using invalid partition key.
try {
businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), "I_DO_NOT_EXIST");
fail("Should throw an IllegalArgumentException when using an invalid partition key.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Partition key \"%s\" doesn't match configured business object format partition key \"%s\".", "I_DO_NOT_EXIST", PARTITION_KEY), e.getMessage());
}
// Try to perform a get business object data status using invalid partition value.
try {
businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, "I_DO_NOT_EXIST", SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a get business object data status using invalid subpartition value.
for (int i = 0; i < SUBPARTITION_VALUES.size(); i++) {
List<String> testSubPartitionValues = new ArrayList<>();
try {
testSubPartitionValues = new ArrayList<>(SUBPARTITION_VALUES);
testSubPartitionValues.set(i, "I_DO_NOT_EXIST");
businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION), PARTITION_KEY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION, null), e.getMessage());
}
}
// Try to perform a get business object data status using too many subpartition values.
try {
List<String> testSubPartitionValues = new ArrayList<>(SUBPARTITION_VALUES);
testSubPartitionValues.add("EXTRA_SUBPARTITION_VALUE");
businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, testSubPartitionValues, DATA_VERSION), PARTITION_KEY);
fail("Should throw an IllegalArgumentException when passing too many subpartition values.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Exceeded maximum number of allowed subpartitions: %d.", BusinessObjectDataEntity.MAX_SUBPARTITIONS), e.getMessage());
}
// Try to perform a get business object data status using invalid business object format version.
try {
businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INVALID_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, null), e.getMessage());
}
// Try to perform a get business object data status using invalid business object data version.
try {
businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INVALID_DATA_VERSION), PARTITION_KEY);
fail("Should throw an ObjectNotFoundException when not able to find business object data.");
} catch (ObjectNotFoundException e) {
assertEquals(businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INVALID_DATA_VERSION, null), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataStatusInformation in project herd by FINRAOS.
the class BusinessObjectDataStatusServiceTest method testGetBusinessObjectDataStatusUpperCaseParameters.
@Test
public void testGetBusinessObjectDataStatusUpperCaseParameters() {
// Create and persist database entities required for testing.
businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, BDATA_STATUS);
// Get the business object data status using upper case input parameters (except for case-sensitive partition values).
BusinessObjectDataStatusInformation resultBusinessObjectDataStatusInformation = businessObjectDataStatusService.getBusinessObjectDataStatus(new BusinessObjectDataKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY.toUpperCase());
// Validate the returned object.
businessObjectDataServiceTestHelper.validateBusinessObjectDataStatusInformation(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), BDATA_STATUS, resultBusinessObjectDataStatusInformation);
}
Aggregations