Search in sources :

Example 46 with BusinessObjectFormatCreateRequest

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatInitialVersionExistsWithSchemaNonAdditiveSchemaChangesColumnSizeIncreasedForNotAllowedDataType.

@Test
public void testCreateBusinessObjectFormatInitialVersionExistsWithSchemaNonAdditiveSchemaChangesColumnSizeIncreasedForNotAllowedDataType() {
    // Create relative database entities.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting();
    // Create an initial format schema.
    Schema initialSchema = new Schema(Arrays.asList(new SchemaColumn(COLUMN_NAME, COLUMN_DATA_TYPE, COLUMN_SIZE, NO_COLUMN_REQUIRED, NO_COLUMN_DEFAULT_VALUE, COLUMN_DESCRIPTION)), NO_PARTITION_COLUMNS, SCHEMA_NULL_VALUE_BACKSLASH_N, SCHEMA_DELIMITER_PIPE, SCHEMA_ESCAPE_CHARACTER_BACKSLASH, PARTITION_KEY_GROUP);
    // Create an initial version of the business object format.
    businessObjectFormatService.createBusinessObjectFormat(new BusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, NO_ATTRIBUTES, NO_ATTRIBUTE_DEFINITIONS, initialSchema));
    // Create an updated schema having a regular column size increased.
    Schema updatedSchema = (Schema) initialSchema.clone();
    updatedSchema.getColumns().get(0).setSize(COLUMN_SIZE_2);
    try {
        // Try to create a second version of the business object format with a new schema
        // having regular column size increased but for a non-allowed column data type.
        businessObjectFormatService.createBusinessObjectFormat(new BusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, NO_ATTRIBUTES, NO_ATTRIBUTE_DEFINITIONS, updatedSchema));
        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. " + "Non-additive changes detected to the previously defined regular (non-partitioning) columns.", e.getMessage());
    }
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) Schema(org.finra.herd.model.api.xml.Schema) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) Test(org.junit.Test)

Example 47 with BusinessObjectFormatCreateRequest

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatWithParentsNotExisting.

@Test
public void testCreateBusinessObjectFormatWithParentsNotExisting() {
    // Create relative database entities including a business object definition.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting(NAMESPACE, DATA_PROVIDER_NAME, BDEF_NAME, FORMAT_FILE_TYPE_CODE, PARTITION_KEY_GROUP);
    List<BusinessObjectFormatKey> businessObjectFormatParents = Arrays.asList(new BusinessObjectFormatKey(NAMESPACE_2, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null));
    // Perform a create without specifying optional parameters.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, NO_FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), NO_ATTRIBUTE_DEFINITIONS, NO_SCHEMA);
    try {
        businessObjectFormatService.createBusinessObjectFormat(request);
    } catch (IllegalArgumentException ex) {
        Assert.assertEquals(ex.getMessage(), "Parent business object format not found.");
    }
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) Test(org.junit.Test)

Example 48 with BusinessObjectFormatCreateRequest

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatCreateSecondVersion.

@Test
public void testCreateBusinessObjectFormatCreateSecondVersion() {
    // Create an initial version of a business object format.
    businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat();
    // Create a second version of the business object format.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
    BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
    // Validate the returned object.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), resultBusinessObjectFormat);
    // Check if we now have only one latest format version - our first version is not marked as latest anymore.
    // Please note that we do not have to validate if the first format version is not marked as "latest" now, since having more that one
    // format versions with the latestVersion flag set to Yes produces exception in herdDao.getBusinessObjectFormatByAltKey() method.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null));
    assertEquals(SECOND_FORMAT_VERSION, businessObjectFormatEntity.getBusinessObjectFormatVersion());
    assertEquals(true, businessObjectFormatEntity.getLatestVersion());
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test)

Aggregations

BusinessObjectFormatCreateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest)48 Test (org.junit.Test)44 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)25 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)24 Schema (org.finra.herd.model.api.xml.Schema)21 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)14 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)9 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)7 Attribute (org.finra.herd.model.api.xml.Attribute)4 AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)2 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)2 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)2 PersistenceException (javax.persistence.PersistenceException)1 Command (org.finra.herd.core.Command)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)1 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)1 BusinessObjectDefinitionDescriptiveInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest)1 BusinessObjectFormatRetentionInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatRetentionInformationUpdateRequest)1 DescriptiveBusinessObjectFormatUpdateRequest (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormatUpdateRequest)1