use of org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatMissingOptionalParameters.
@Test
public void testCreateBusinessObjectFormatMissingOptionalParameters() {
// 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 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);
BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
// Validate the returned object.
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(), NO_ATTRIBUTE_DEFINITIONS, NO_SCHEMA, resultBusinessObjectFormat);
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatNoPartitionKeyGroupSpecified.
@Test
public void testCreateBusinessObjectFormatNoPartitionKeyGroupSpecified() {
// Create relative database entities.
businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting();
// Create a version of business object format without specifying a partition key group (using both blank text and a null value).
Integer expectedBusinessObjectFormatVersion = INITIAL_FORMAT_VERSION;
for (String partitionKeyGroupName : Arrays.asList(BLANK_TEXT, null)) {
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().setPartitionKeyGroup(partitionKeyGroupName);
BusinessObjectFormat businessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
// Validate the returned object.
Schema expectedSchema = businessObjectFormatServiceTestHelper.getTestSchema();
expectedSchema.setPartitionKeyGroup(null);
businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, expectedBusinessObjectFormatVersion++, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), expectedSchema, businessObjectFormat);
}
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatNoSchemaColumnName.
@Test
public void testCreateBusinessObjectFormatNoSchemaColumnName() {
// 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 column name.
SchemaColumn schemaColumn = new SchemaColumn();
request.getSchema().getColumns().add(schemaColumn);
schemaColumn.setName(BLANK_TEXT);
schemaColumn.setType("TYPE");
try {
businessObjectFormatService.createBusinessObjectFormat(request);
fail("Should throw an IllegalArgumentException when schema has an empty column name.");
} catch (IllegalArgumentException e) {
assertEquals("A schema column name must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatRetentionWithLatestVersion.
@Test
public void testUpdateBusinessObjectFormatRetentionWithLatestVersion() {
// Create an initial version of a business object format with format description and schema information.
BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(businessObjectDefinitionServiceTestHelper.getNewAttributes());
boolean recordFlag = true;
Integer retentionPeriodInDays = new Integer(180);
String retentionType = "PARTITION_VALUE";
BusinessObjectFormatRetentionInformationUpdateRequest updateRequest = new BusinessObjectFormatRetentionInformationUpdateRequest();
updateRequest.setRetentionType(retentionType);
updateRequest.setRecordFlag(recordFlag);
updateRequest.setRetentionPeriodInDays(retentionPeriodInDays);
BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormatRetentionInformation(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null), updateRequest);
businessObjectFormatServiceTestHelper.validateRetentionInformation(recordFlag, retentionPeriodInDays, retentionType, updatedBusinessObjectFormat);
BusinessObjectFormatCreateRequest createRequest = new BusinessObjectFormatCreateRequest();
createRequest.setNamespace(NAMESPACE);
createRequest.setBusinessObjectDefinitionName(BDEF_NAME);
createRequest.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
createRequest.setBusinessObjectFormatUsage(FORMAT_USAGE_CODE);
createRequest.setPartitionKey(originalBusinessObjectFormat.getPartitionKey());
createRequest.setSchema(originalBusinessObjectFormat.getSchema());
BusinessObjectFormat newVersionBusinessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(createRequest);
// the new version of business object format should have the retention information
businessObjectFormatServiceTestHelper.validateRetentionInformation(recordFlag, retentionPeriodInDays, retentionType, newVersionBusinessObjectFormat);
BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 1);
// now delete the oldest version
businessObjectFormatService.deleteBusinessObjectFormat(businessObjectFormatKey);
// now the old version 0, should have the retention information
businessObjectFormatKey.setBusinessObjectFormatVersion(0);
BusinessObjectFormat businessObjectFormat = businessObjectFormatService.getBusinessObjectFormat(businessObjectFormatKey);
businessObjectFormatServiceTestHelper.validateRetentionInformation(recordFlag, retentionPeriodInDays, retentionType, businessObjectFormat);
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatNoSchemaColumns.
@Test
public void testCreateBusinessObjectFormatNoSchemaColumns() {
// 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 a schema without columns.
request.getSchema().setColumns(null);
try {
businessObjectFormatService.createBusinessObjectFormat(request);
fail("Should throw an IllegalArgumentException when schema has no columns.");
} catch (IllegalArgumentException e) {
assertEquals("A schema must have at least one column.", e.getMessage());
}
}
Aggregations