use of org.finra.herd.model.api.xml.AttributeDefinition 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());
}
}
use of org.finra.herd.model.api.xml.AttributeDefinition 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);
}
use of org.finra.herd.model.api.xml.AttributeDefinition in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsMissingOptionalParameters.
@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsMissingOptionalParameters() {
List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
// Passing null as optional parameter
List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, null));
// Perform an update by changing the attribute definition with an empty list.
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 (NullPointerException ex) {
assertEquals(null, ex.getMessage());
}
}
use of org.finra.herd.model.api.xml.AttributeDefinition in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatDuplicateAttributeDefinitions.
@Test
public void testCreateBusinessObjectFormatDuplicateAttributeDefinitions() {
// 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 attribute definition.
AttributeDefinition attributeDefinition = new AttributeDefinition();
attributeDefinition.setName(ATTRIBUTE_NAME_1_MIXED_CASE);
request.getAttributeDefinitions().add(attributeDefinition);
// Create the business object format which is invalid since duplicate attribute definitions are present.
try {
businessObjectFormatService.createBusinessObjectFormat(request);
fail("Expecting an Illegal Argument Exception to be thrown which wasn't since duplicate attribute definitions are present.");
} catch (IllegalArgumentException ex) {
// We are expecting this exception so do nothing.
}
}
use of org.finra.herd.model.api.xml.AttributeDefinition in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsUpperAndLowerCase.
@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsUpperAndLowerCase() {
List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
// Upper case and lower case
List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
List<AttributeDefinition> validateAttributeDefinitions = new ArrayList<>();
validateAttributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.PUBLISH_ATTRIBUTE));
attributeDefinitions.add(new AttributeDefinition(" " + AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE + " ", AbstractServiceTest.PUBLISH_ATTRIBUTE));
// Perform an update by changing the attribute definition to null.
BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(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, attributes, validateAttributeDefinitions, businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat);
// upper case and lower case
attributeDefinitions = new ArrayList<>();
// List<AttributeDefinition> attributeDefinitions = businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2();
attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), AbstractServiceTest.PUBLISH_ATTRIBUTE));
attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), AbstractServiceTest.PUBLISH_ATTRIBUTE));
// Perform an update by changing the attribute definition with an empty list.
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("Duplicate attribute definition name \"%s\" found.", ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase()), ex.getMessage());
}
}
Aggregations