use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsDuplicateAttributeDefintions.
@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsDuplicateAttributeDefintions() {
List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
List<AttributeDefinition> attributeDefinitions = businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2();
// Check for the duplicate attribute definition.
attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.NO_PUBLISH_ATTRIBUTE));
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("Duplicate attribute definition name \"%s\" found.", ATTRIBUTE_NAME_1_MIXED_CASE), ex.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testDeleteBusinessObjectFormat.
@Test
public void testDeleteBusinessObjectFormat() throws Exception {
// Create an initial version of a business object format.
businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(businessObjectDefinitionServiceTestHelper.getNewAttributes());
// Retrieve the business object format entity.
BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION));
// Delete the business object format.
BusinessObjectFormat deletedBusinessObjectFormat = businessObjectFormatService.deleteBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION));
// Validate the returned object.
businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(businessObjectFormatEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), deletedBusinessObjectFormat);
// Ensure that this business object format is no longer there.
assertNull(businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION)));
}
use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatWithGlobalAttributesAndAllowedAttributeValuesNegative.
@Test
public void testCreateBusinessObjectFormatWithGlobalAttributesAndAllowedAttributeValuesNegative() {
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = createGlobalAttributeDefinitionEntityWithAllowedAttributeValues();
String invalidAttributeValue = "test attribute 1";
List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
attributes.add(new Attribute(GLOBAL_ATTRIBUTE_DEFINITON_NAME, invalidAttributeValue));
try {
// Create an initial version of a business object format.
BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
fail("Should throw exception before");
} catch (IllegalArgumentException ex) {
assertEquals(String.format("The business object format attribute \"%s\" value \"%s\" is not from allowed attribute values.", GLOBAL_ATTRIBUTE_DEFINITON_NAME, invalidAttributeValue), ex.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatCreateSecondVersion.
@Test
public void testCreateBusinessObjectFormatCreateSecondVersion() {
// Create an initial version of a business object format.
businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat();
// Create a second version of the business object format.
BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
// Validate the returned object.
businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(null, 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(), businessObjectFormatServiceTestHelper.getTestSchema(), resultBusinessObjectFormat);
// Check if we now have only one latest format version - our first version is not marked as latest anymore.
// Please note that we do not have to validate if the first format version is not marked as "latest" now, since having more that one
// format versions with the latestVersion flag set to Yes produces exception in herdDao.getBusinessObjectFormatByAltKey() method.
BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null));
assertEquals(SECOND_FORMAT_VERSION, businessObjectFormatEntity.getBusinessObjectFormatVersion());
assertEquals(true, businessObjectFormatEntity.getLatestVersion());
}
use of org.finra.herd.model.api.xml.BusinessObjectFormat in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testGetBusinessObjectFormatWithParents.
@Test
public void testGetBusinessObjectFormatWithParents() {
setupBusinessObjectFormatParentChild();
BusinessObjectFormatKey businessObjectFormat = new BusinessObjectFormatKey(NAMESPACE + " ", BDEF_NAME.toLowerCase(), " " + FORMAT_USAGE_CODE, " " + FORMAT_FILE_TYPE_CODE + " ", null);
BusinessObjectFormatKey childBusinessObjectFormat = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, null);
BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService.getBusinessObjectFormat(businessObjectFormat);
BusinessObjectFormat resultChildBusinessObjectFormat = businessObjectFormatService.getBusinessObjectFormat(childBusinessObjectFormat);
assertEquals(0, resultBusinessObjectFormat.getBusinessObjectFormatParents().size());
assertEquals(1, resultChildBusinessObjectFormat.getBusinessObjectFormatParents().size());
assertEquals(1, resultBusinessObjectFormat.getBusinessObjectFormatChildren().size());
}
Aggregations