Search in sources :

Example 41 with BusinessObjectFormat

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsNullAsParameters.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsNullAsParameters() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    // null check for attribute definitions value
    // Perform an update by changing the attribute definition to null.
    BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(null);
    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("A business object format attribute definitions list is required."), ex.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) 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)

Example 42 with BusinessObjectFormat

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatInitialVersionExistsWithoutSchema.

@Test
public void testCreateBusinessObjectFormatInitialVersionExistsWithoutSchema() {
    // Create relative database entities.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting();
    BusinessObjectFormatCreateRequest request;
    BusinessObjectFormat resultBusinessObjectFormat;
    // Create an initial version of the business object format without a schema.
    request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), NO_SCHEMA);
    businessObjectFormatService.createBusinessObjectFormat(request);
    // Create a second version of the business object format without a schema.
    request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), NO_SCHEMA);
    resultBusinessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
    // Validate the returned object.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(resultBusinessObjectFormat.getId(), 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(), NO_SCHEMA, resultBusinessObjectFormat);
    // Create a second version of the business object format with a schema.
    request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
    resultBusinessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
    // Validate the returned object.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(resultBusinessObjectFormat.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, THIRD_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), resultBusinessObjectFormat);
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 43 with BusinessObjectFormat

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormat.

@Test
public void testUpdateBusinessObjectFormat() {
    // Create an initial version of a business object format with format description and schema information.
    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 schema.
    BusinessObjectFormatUpdateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestSchema2());
    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_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema2(), 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 44 with BusinessObjectFormat

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatSchemaWhitespaceNullValueAndDelimiter.

@Test
public void testCreateBusinessObjectFormatSchemaWhitespaceNullValueAndDelimiter() {
    // Create relative database entities.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting();
    // Create an initial version of business object format with schema null value and delimiter as a whitespace 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().setNullValue(" ");
    request.getSchema().setDelimiter(" ");
    BusinessObjectFormat businessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
    // Validate the returned object.
    Schema expectedSchema = businessObjectFormatServiceTestHelper.getTestSchema();
    expectedSchema.setNullValue(" ");
    expectedSchema.setDelimiter(" ");
    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 45 with BusinessObjectFormat

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

the class BusinessObjectFormatServiceTest method testDeleteBusinessObjectFormatLatestVersionWhenPreviousVersionExists.

@Test
public void testDeleteBusinessObjectFormatLatestVersionWhenPreviousVersionExists() {
    // Create and persist two versions of the business object format.
    BusinessObjectFormatEntity initialVersionBusinessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, false, PARTITION_KEY);
    BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
    // Validate that the initial version does not have the latest version flag set and that second version has it set.
    assertFalse(initialVersionBusinessObjectFormatEntity.getLatestVersion());
    assertTrue(latestVersionBusinessObjectFormatEntity.getLatestVersion());
    // Delete the latest (second) version of the business object format.
    BusinessObjectFormat deletedBusinessObjectFormat = businessObjectFormatService.deleteBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION));
    // Validate the returned object.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(latestVersionBusinessObjectFormatEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_DATA_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, NO_ATTRIBUTES, NO_ATTRIBUTE_DEFINITIONS, NO_SCHEMA, deletedBusinessObjectFormat);
    // Ensure that this business object format is no longer there.
    latestVersionBusinessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, SECOND_FORMAT_VERSION));
    assertNull(latestVersionBusinessObjectFormatEntity);
    // Validate that the initial version now has the latest version flag set.
    initialVersionBusinessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION));
    assertNotNull(initialVersionBusinessObjectFormatEntity);
    assertTrue(initialVersionBusinessObjectFormatEntity.getLatestVersion());
}
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)

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