Search in sources :

Example 31 with BusinessObjectFormatKey

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatDuplicateAttributes.

@Test
public void testUpdateBusinessObjectFormatDuplicateAttributes() {
    // Try to update a business object format instance when duplicate attributes are specified.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, Arrays.asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3), new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_3)), businessObjectFormatServiceTestHelper.getTestSchema2()));
        fail("Should throw an IllegalArgumentException when duplicate attributes are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Duplicate attribute name found: %s", ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase()), e.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) Test(org.junit.Test)

Example 32 with BusinessObjectFormatKey

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

the class BusinessObjectFormatServiceTest method testGetBusinessObjectFormatTrimParameters.

@Test
public void testGetBusinessObjectFormatTrimParameters() {
    // 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);
    // Perform a get using input parameters with leading and trailing empty spaces.
    BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService.getBusinessObjectFormat(new BusinessObjectFormatKey(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(FORMAT_USAGE_CODE), addWhitespace(FORMAT_FILE_TYPE_CODE), INITIAL_FORMAT_VERSION));
    // Validate the returned object.
    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, NO_ATTRIBUTES, NO_ATTRIBUTE_DEFINITIONS, NO_SCHEMA, resultBusinessObjectFormat);
}
Also used : 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) Test(org.junit.Test)

Example 33 with BusinessObjectFormatKey

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatParentsValidation.

@Test
public void testUpdateBusinessObjectFormatParentsValidation() {
    List<BusinessObjectFormatKey> businessObjectFormatParents = null;
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null);
    BusinessObjectFormatParentsUpdateRequest request = null;
    try {
        businessObjectFormatService.updateBusinessObjectFormatParents(businessObjectFormatKey, request);
    } catch (IllegalArgumentException ex) {
        Assert.assertEquals("A Business Object Format Parents Update Request is required.", ex.getMessage());
    }
    businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 1);
    request = new BusinessObjectFormatParentsUpdateRequest();
    try {
        businessObjectFormatService.updateBusinessObjectFormatParents(businessObjectFormatKey, request);
    } catch (IllegalArgumentException ex) {
        Assert.assertEquals("Business object format version must not be specified.", ex.getMessage());
    }
}
Also used : BusinessObjectFormatParentsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatParentsUpdateRequest) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) Test(org.junit.Test)

Example 34 with BusinessObjectFormatKey

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatInitialVersionExistsWithSchemaHavingNullRowFormatValuesNonAdditiveSchemaChanges.

@Test
public void testCreateBusinessObjectFormatInitialVersionExistsWithSchemaHavingNullRowFormatValuesNonAdditiveSchemaChanges() {
    // Create relative database entities.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting();
    // Create an initial version of the business object format with a schema having null row format values.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
    request.getSchema().setDelimiter(null);
    request.getSchema().setEscapeCharacter(null);
    businessObjectFormatService.createBusinessObjectFormat(request);
    // Get business object format entity.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION));
    assertNotNull(businessObjectFormatEntity);
    // Schema null value is a required parameter, so we update business object format entity directly to set it to null.
    businessObjectFormatEntity.setNullValue(null);
    businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity);
    Schema newSchema;
    // Try to create a second version of the business object format with a schema that has a different null value.
    try {
        newSchema = businessObjectFormatServiceTestHelper.getTestSchema();
        newSchema.setNullValue(SCHEMA_NULL_VALUE_NULL_WORD);
        businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), newSchema));
        fail("Should throw an IllegalArgumentException when the new format version is not \"additive\" to the previous format version.");
    } catch (IllegalArgumentException e) {
        assertEquals("New format version schema is not \"additive\" to the previous format version schema. " + "New format version null value does not match to the previous format version null value.", e.getMessage());
    }
    // Try to create a second version of the business object format with a schema that has a different schema delimiter.
    try {
        newSchema = businessObjectFormatServiceTestHelper.getTestSchema();
        // This is a required parameter, so it cannot be set to null.
        newSchema.setNullValue(EMPTY_STRING);
        newSchema.setDelimiter(SCHEMA_DELIMITER_COMMA);
        newSchema.setEscapeCharacter(null);
        businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), newSchema));
        fail("Should throw an IllegalArgumentException when the new format version is not \"additive\" to the previous format version.");
    } catch (IllegalArgumentException e) {
        assertEquals("New format version schema is not \"additive\" to the previous format version schema. " + "New format version delimiter character does not match to the previous format version delimiter character.", e.getMessage());
    }
    // Try to create a second version of the business object format with a schema that has a different schema escape character.
    try {
        newSchema = businessObjectFormatServiceTestHelper.getTestSchema();
        // This is a required parameter, so it cannot be set to null.
        newSchema.setNullValue(EMPTY_STRING);
        newSchema.setDelimiter(null);
        newSchema.setEscapeCharacter(SCHEMA_ESCAPE_CHARACTER_TILDE);
        businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), newSchema));
        fail("Should throw an IllegalArgumentException when the new format version is not \"additive\" to the previous format version.");
    } catch (IllegalArgumentException e) {
        assertEquals("New format version schema is not \"additive\" to the previous format version schema. " + "New format version escape character does not match to the previous format version escape character.", e.getMessage());
    }
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) Schema(org.finra.herd.model.api.xml.Schema) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test)

Example 35 with BusinessObjectFormatKey

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsMissingRequiredParameters.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsMissingRequiredParameters() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    // Null as required parameter
    List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition(null, AbstractServiceTest.NO_PUBLISH_ATTRIBUTE));
    // Perform an update by changing the attribute definition to null.
    BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
    try {
        businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException.");
    } catch (IllegalArgumentException ex) {
        assertEquals(String.format("An attribute definition name must be specified."), ex.getMessage());
    }
    // Blank string as required parameter
    attributeDefinitions = new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition("", AbstractServiceTest.NO_PUBLISH_ATTRIBUTE));
    // Perform an update by changing the attribute definition to null.
    request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
    try {
        businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException.");
    } catch (IllegalArgumentException ex) {
        assertEquals(String.format("An attribute definition name must be specified."), ex.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) BusinessObjectFormatAttributeDefinitionsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Aggregations

BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)166 Test (org.junit.Test)126 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)71 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)62 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)47 Attribute (org.finra.herd.model.api.xml.Attribute)24 ArrayList (java.util.ArrayList)23 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)20 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)17 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)15 BusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatUpdateRequest)15 DescriptiveBusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest)15 StorageEntity (org.finra.herd.model.jpa.StorageEntity)14 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)13 NotificationMessageDefinitions (org.finra.herd.model.api.xml.NotificationMessageDefinitions)10 ConfigurationEntity (org.finra.herd.model.jpa.ConfigurationEntity)10 AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)9 BusinessObjectFormatAttributeDefinitionsUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest)9 BusinessObjectFormatCreateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest)9 NotificationMessageDefinition (org.finra.herd.model.api.xml.NotificationMessageDefinition)9