Search in sources :

Example 11 with BusinessObjectFormatCreateRequest

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatNullSchemaEscapeCharacter.

@Test
public void testCreateBusinessObjectFormatNullSchemaEscapeCharacter() {
    // Create relative database entities.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting();
    // Create a business object format create request.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
    // Try to create a business object format with an empty schema escape character which is valid.
    request.getSchema().setEscapeCharacter(null);
    BusinessObjectFormat businessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
    // Validate the returned object.
    Schema expectedSchema = businessObjectFormatServiceTestHelper.getTestSchema();
    // The escape characters gets trimmed which gets stored as the empty string which gets returned as null.
    expectedSchema.setEscapeCharacter(null);
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 0, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), expectedSchema, businessObjectFormat);
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) Schema(org.finra.herd.model.api.xml.Schema) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 12 with BusinessObjectFormatCreateRequest

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatUnprintableSchemaEscapeCharacter.

@Test
public void testCreateBusinessObjectFormatUnprintableSchemaEscapeCharacter() {
    // Create relative database entities.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting();
    // Create an initial version of business object format with a schema having an unprintable escape character.
    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().setEscapeCharacter(String.valueOf((char) 1));
    BusinessObjectFormat businessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
    // Validate the returned object.
    Schema expectedSchema = businessObjectFormatServiceTestHelper.getTestSchema();
    expectedSchema.setEscapeCharacter(String.valueOf((char) 1));
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 0, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), expectedSchema, businessObjectFormat);
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) Schema(org.finra.herd.model.api.xml.Schema) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 13 with BusinessObjectFormatCreateRequest

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatIncorrectLatestVersion.

@Test
public void testCreateBusinessObjectFormatIncorrectLatestVersion() throws Exception {
    // Create relative database entities.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting();
    // Create a first version of the format with the latest flag set to false.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, false, PARTITION_KEY);
    try {
        // Try to create a new format version for this format.
        final BusinessObjectFormatCreateRequest businessObjectFormatCreateRequest = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
        executeWithoutLogging(SqlExceptionHelper.class, new Command() {

            @Override
            public void execute() {
                businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatCreateRequest);
                fail("Should throw a PersistenceException since the latest flag does not identify the maximum format version.");
            }
        });
    } catch (PersistenceException e) {
        assertTrue(e.getMessage().contains("ConstraintViolationException: could not execute statement"));
    }
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) Command(org.finra.herd.core.Command) PersistenceException(javax.persistence.PersistenceException) Test(org.junit.Test)

Example 14 with BusinessObjectFormatCreateRequest

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatDuplicateColumns.

@Test
public void testCreateBusinessObjectFormatDuplicateColumns() {
    // Create a business object format create request.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
    // Add in duplicate schema columns.
    for (String columnName : Arrays.asList("duplicate_column_name", "DUPLICATE_COLUMN_NAME")) {
        SchemaColumn schemaColumn = new SchemaColumn();
        request.getSchema().getColumns().add(schemaColumn);
        schemaColumn.setName(columnName);
        schemaColumn.setType("TYPE");
    }
    // Try to create a business object format which has duplicate column names.
    try {
        businessObjectFormatService.createBusinessObjectFormat(request);
        fail("Should throw an IllegalArgumentException when duplicate column names are present.");
    } catch (IllegalArgumentException e) {
        String expectedErrorMessage = String.format("Duplicate schema column name \"DUPLICATE_COLUMN_NAME\" found.");
        assertEquals(expectedErrorMessage, e.getMessage());
    }
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) Test(org.junit.Test)

Example 15 with BusinessObjectFormatCreateRequest

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatNoAttributeDefinitionPublishOptionSpecified.

@Test
public void testCreateBusinessObjectFormatNoAttributeDefinitionPublishOptionSpecified() {
    // Create relative database entities including a business object definition.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting(NAMESPACE, DATA_PROVIDER_NAME, BDEF_NAME, FORMAT_FILE_TYPE_CODE, PARTITION_KEY_GROUP);
    // Perform a create without specifying a publish option for an attribute definition.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, NO_FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), Arrays.asList(new AttributeDefinition(ATTRIBUTE_NAME_1_MIXED_CASE, null)), NO_SCHEMA);
    BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
    // Validate the returned object. The publish option is expected to default to "false".
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, NO_FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), Arrays.asList(new AttributeDefinition(ATTRIBUTE_NAME_1_MIXED_CASE, NO_PUBLISH_ATTRIBUTE)), NO_SCHEMA, resultBusinessObjectFormat);
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) 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