Search in sources :

Example 11 with BusinessObjectFormatUpdateRequest

use of org.finra.herd.model.api.xml.BusinessObjectFormatUpdateRequest 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)

Example 12 with BusinessObjectFormatUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatMissingRequiredParameters.

@Test
public void testUpdateBusinessObjectFormatMissingRequiredParameters() {
    // Create a business object format update request.
    BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema2());
    // Try to perform an update without specifying business object definition name.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException when business object definition is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying business object format usage.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, BLANK_TEXT, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException when business object format usage is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format usage must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying business object format file type.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, BLANK_TEXT, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException when business object format file type is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format file type must be specified.", e.getMessage());
    }
    // Try to perform an update without specifying business object format version.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException when business object format version is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format version must be specified.", e.getMessage());
    }
    // Try to update a business object format instance when attribute name is not specified.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, Arrays.asList(new Attribute(BLANK_TEXT, ATTRIBUTE_VALUE_1)), businessObjectFormatServiceTestHelper.getTestSchema2()));
        fail("Should throw an IllegalArgumentException when attribute name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An attribute name must be specified.", e.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatUpdateRequest) DescriptiveBusinessObjectFormatUpdateRequest(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest) Test(org.junit.Test)

Example 13 with BusinessObjectFormatUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatNoChangesToDescriptionAndSchema.

@Test
public void testUpdateBusinessObjectFormatNoChangesToDescriptionAndSchema() {
    // Create an initial version of a business object format with format description and schema information.
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat();
    // Perform an update without making any changes to format description and schema information.
    BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema());
    BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
    // Validate the returned object.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(originalBusinessObjectFormat.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat);
}
Also used : BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) 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)

Example 14 with BusinessObjectFormatUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatTrimParameters.

@Test
public void testUpdateBusinessObjectFormatTrimParameters() {
    // Create an initial version of a business object format.
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(businessObjectDefinitionServiceTestHelper.getNewAttributes());
    // Create a new partition key group for the update request.
    partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2);
    // Perform an update by changing the description and using input parameters with leading and trailing empty spaces.
    BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(addWhitespace(FORMAT_DESCRIPTION_2), Arrays.asList(new Attribute(addWhitespace(ATTRIBUTE_NAME_1_MIXED_CASE), addWhitespace(ATTRIBUTE_VALUE_1))), addWhitespace(businessObjectFormatServiceTestHelper.getTestSchema2()));
    BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), INITIAL_FORMAT_VERSION), request);
    // Validate the returned object.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(originalBusinessObjectFormat.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, addWhitespace(FORMAT_DESCRIPTION_2), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, addWhitespace(ATTRIBUTE_VALUE_1))), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema2(), updatedBusinessObjectFormat);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) 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)

Example 15 with BusinessObjectFormatUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatInvalidParameters.

@Test
public void testUpdateBusinessObjectFormatInvalidParameters() {
    // Create and persist a valid business object format.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
    // Create a business object format update request.
    BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema2());
    // Create a new partition key group for the update request.
    partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2);
    // Perform an update on our business object format.
    BusinessObjectFormat businessObjectFormat = businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
    // Validate the results.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(businessObjectFormatEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), NO_ATTRIBUTE_DEFINITIONS, businessObjectFormatServiceTestHelper.getTestSchema2(), businessObjectFormat);
    // Try to perform an update using invalid namespace code.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey("I_DO_NOT_EXIST", BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage("I_DO_NOT_EXIST", BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), e.getMessage());
    }
    // Try to perform an update using invalid business object definition name.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), e.getMessage());
    }
    // Try to perform a get using invalid business object definition name
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, "I_DO_NOT_EXIST", FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals("Business object format with namespace \"" + NAMESPACE + "\", business object definition name \"I_DO_NOT_EXIST\", format usage \"" + FORMAT_USAGE_CODE + "\", format file type \"" + FORMAT_FILE_TYPE_CODE + "\", and format version \"" + INITIAL_FORMAT_VERSION + "\" doesn't exist.", e.getMessage());
    }
    // Try to perform an update using invalid format usage.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), e.getMessage());
    }
    // Try to perform an update using invalid format file type.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", INITIAL_FORMAT_VERSION), request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, "I_DO_NOT_EXIST", INITIAL_FORMAT_VERSION), e.getMessage());
    }
    // Try to perform an update using invalid format version.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 999), request);
        fail("Should throw an ObjectNotFoundException when not able to find business object format.");
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatNotFoundErrorMessage(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 999), e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) 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

BusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatUpdateRequest)16 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)15 Test (org.junit.Test)15 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)14 DescriptiveBusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest)14 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)13 Attribute (org.finra.herd.model.api.xml.Attribute)7 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)6 Schema (org.finra.herd.model.api.xml.Schema)3 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1