use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class GetBusinessObjectFormatTest method testGetBusinessObjectFormatMissingOptionalParameters.
/**
* This unit test does not pass optional parameters.
*/
@Test
public void testGetBusinessObjectFormatMissingOptionalParameters() throws Exception {
// Create and persist a business object format.
BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat();
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}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("namespace", NAMESPACE));
parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
// Retrieve the business object format without specifying the business object format value.
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GetBusinessObjectFormat.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(businessObjectFormat));
testActivitiServiceTaskSuccess(GetBusinessObjectFormat.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class GetBusinessObjectFormatTest method testGetBusinessObjectFormat.
/**
* This unit test passes all required and optional parameters.
*/
@Test
public void testGetBusinessObjectFormat() throws Exception {
// Create and persist a business object format.
BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat();
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("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("namespace", 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("businessObjectFormatVersion", INITIAL_FORMAT_VERSION.toString()));
// Retrieve the business object format and validate the returned object.
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GetBusinessObjectFormat.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(businessObjectFormat));
testActivitiServiceTaskSuccess(GetBusinessObjectFormat.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class BusinessObjectFormatRestControllerTest method testDeleteBusinessObjectFormat.
@Test
public void testDeleteBusinessObjectFormat() throws Exception {
BusinessObjectFormat businessObjectFormat = new BusinessObjectFormat(ID, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, true, PARTITION_KEY, FORMAT_DESCRIPTION, NO_ATTRIBUTES, businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), null, null, NO_RECORDFLAG, NO_RETENTIONPERIODINDAYS, NO_RETENTIONTYPE);
BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION);
when(businessObjectFormatService.deleteBusinessObjectFormat(businessObjectFormatKey)).thenReturn(businessObjectFormat);
// Create an initial version of a business object format.
businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat();
BusinessObjectFormat deletedBusinessObjectFormat = businessObjectFormatRestController.deleteBusinessObjectFormat(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION);
// Verify the external calls.
verify(businessObjectFormatService).deleteBusinessObjectFormat(businessObjectFormatKey);
verifyNoMoreInteractions(businessObjectFormatService);
// Validate the returned object.
assertEquals(businessObjectFormat, deletedBusinessObjectFormat);
}
use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatRetentionWithWrongRetentionType.
@Test
public void testUpdateBusinessObjectFormatRetentionWithWrongRetentionType() {
// Create an initial version of a business object format with format description and schema information.
BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(businessObjectDefinitionServiceTestHelper.getNewAttributes());
boolean recordFlag = true;
Integer retentionPeriodInDays = new Integer(180);
String retentionType = "NOTFOUND";
BusinessObjectFormatRetentionInformationUpdateRequest updateRequest = new BusinessObjectFormatRetentionInformationUpdateRequest();
updateRequest.setRetentionType(retentionType);
updateRequest.setRecordFlag(recordFlag);
updateRequest.setRetentionPeriodInDays(retentionPeriodInDays);
try {
businessObjectFormatService.updateBusinessObjectFormatRetentionInformation(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null), updateRequest);
fail("should throw ObjectNotFoundException before");
} catch (ObjectNotFoundException ex) {
assertEquals(String.format("Record retention type with code \"%s\" doesn't exist.", retentionType), ex.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatUpperCaseParameters.
@Test
public void testUpdateBusinessObjectFormatUpperCaseParameters() {
// Create an initial version of the format using lower case input parameters.
BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION.toLowerCase(), LATEST_VERSION_FLAG_SET, PARTITION_KEY.toLowerCase(), NO_PARTITION_KEY_GROUP, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1.toLowerCase())));
// Create a new partition key group for the update request.
partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2.toLowerCase());
// Perform an update by changing the format description and schema.
Schema testSchema = businessObjectFormatServiceTestHelper.getTestSchema2();
testSchema.setPartitionKeyGroup(testSchema.getPartitionKeyGroup().toUpperCase());
BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2.toUpperCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_1.toUpperCase())), testSchema);
BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), INITIAL_FORMAT_VERSION), request);
// Validate the returned object.
Schema expectedSchema = businessObjectFormatServiceTestHelper.getTestSchema2();
expectedSchema.setPartitionKeyGroup(expectedSchema.getPartitionKeyGroup().toLowerCase());
businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(businessObjectFormatEntity.getId(), NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY.toLowerCase(), FORMAT_DESCRIPTION_2.toUpperCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1.toUpperCase())), null, expectedSchema, updatedBusinessObjectFormat);
}
Aggregations