use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatWithGlobalAttributes.
@Test
public void testCreateBusinessObjectFormatWithGlobalAttributes() {
globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// create one non-format level global attribute
globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL + "_1", GLOBAL_ATTRIBUTE_DEFINITON_NAME);
List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
attributes.add(new Attribute(GLOBAL_ATTRIBUTE_DEFINITON_NAME, "test attribute 1"));
// Create an initial version of a business object format.
BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
// Validate the returned object.
businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 0, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, attributes, businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), businessObjectFormat);
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatMissingRequiredParameters.
@Test
public void testCreateBusinessObjectFormatMissingRequiredParameters() {
// Try to perform a create without specifying business object definition name parameter.
try {
businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema()));
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A business object definition name must be specified.", e.getMessage());
}
// Try to perform a create without specifying format usage parameter.
try {
businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, BLANK_TEXT, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema()));
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A business object format usage must be specified.", e.getMessage());
}
// Try to perform a create without specifying format file type parameter.
try {
businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, BLANK_TEXT, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema()));
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A business object format file type must be specified.", e.getMessage());
}
// Try to perform a create without specifying format partition key parameter.
try {
businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, BLANK_TEXT, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema()));
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals("A partition key must be specified.", e.getMessage());
}
// Try to create a business object format instance when attribute name is not specified.
try {
businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, Arrays.asList(new Attribute(BLANK_TEXT, ATTRIBUTE_VALUE_1)), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema()));
fail("Should throw an IllegalArgumentException when attribute name is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("An attribute name must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitions.
@Test
public void testUpdateBusinessObjectFormatAttributeDefinitions() {
List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
// Create an initial version of a business object format with format description and schema information.
// Attributes are passed rather attribute definations as this method also set attribute definition by default and no need to create another method
BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
List<AttributeDefinition> attributeDefinitions = businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2();
BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
// Perform an update by changing the description and schema.
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, attributeDefinitions, businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat);
}
use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatDuplicateAttributes.
@Test
public void testUpdateBusinessObjectFormatDuplicateAttributes() {
// Try to update a business object format instance when duplicate attributes are specified.
try {
businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, Arrays.asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3), new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_3)), businessObjectFormatServiceTestHelper.getTestSchema2()));
fail("Should throw an IllegalArgumentException when duplicate attributes are specified.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Duplicate attribute name found: %s", ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.Attribute 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());
}
}
Aggregations