Search in sources :

Example 56 with BusinessObjectFormat

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);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 57 with BusinessObjectFormat

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);
}
Also used : HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 58 with BusinessObjectFormat

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);
}
Also used : BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 59 with BusinessObjectFormat

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());
    }
}
Also used : BusinessObjectFormatRetentionInformationUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatRetentionInformationUpdateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 60 with BusinessObjectFormat

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);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) Schema(org.finra.herd.model.api.xml.Schema) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) BusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatUpdateRequest) DescriptiveBusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest) Test(org.junit.Test)

Aggregations

BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)95 Test (org.junit.Test)84 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)72 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)62 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)31 Attribute (org.finra.herd.model.api.xml.Attribute)27 BusinessObjectFormatCreateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest)25 Schema (org.finra.herd.model.api.xml.Schema)22 BusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatUpdateRequest)14 DescriptiveBusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest)13 ArrayList (java.util.ArrayList)9 AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)9 BusinessObjectFormatAttributeDefinitionsUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest)8 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)7 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)7 BusinessObjectFormatRetentionInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatRetentionInformationUpdateRequest)5 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)4 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)4 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)4 GlobalAttributeDefinitionEntity (org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity)4