use of org.finra.herd.model.api.xml.BusinessObjectFormatKey in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatWithMissingGlobalAttributes.
@Test
public void testUpdateBusinessObjectFormatWithMissingGlobalAttributes() {
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);
// Create a new partition key group for the update request.
partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP_2);
try {
// 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);
fail("should throw exception before");
} catch (IllegalArgumentException ex) {
assertEquals(String.format("The business object format has a required attribute \"%s\" which was not specified or has a value which is blank.", GLOBAL_ATTRIBUTE_DEFINITON_NAME), ex.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatKey in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatWithParents.
@Test
public void testCreateBusinessObjectFormatWithParents() {
// Create relative database entities including a business object definition.
businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting(NAMESPACE, DATA_PROVIDER_NAME, BDEF_NAME, FORMAT_FILE_TYPE_CODE, PARTITION_KEY_GROUP);
businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting(NAMESPACE_2, DATA_PROVIDER_NAME_2, BDEF_NAME_2, FORMAT_FILE_TYPE_CODE_2, PARTITION_KEY_GROUP_2);
// parent business object format
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);
List<BusinessObjectFormatKey> businessObjectFormatParents = Arrays.asList(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null));
BusinessObjectFormatCreateRequest request2 = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, PARTITION_KEY, NO_FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), NO_ATTRIBUTE_DEFINITIONS, NO_SCHEMA);
BusinessObjectFormat resultBusinessObjectFormatV0 = businessObjectFormatService.createBusinessObjectFormat(request);
BusinessObjectFormat resultBusinessObjectFormatChildV0 = businessObjectFormatService.createBusinessObjectFormat(request2);
BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null);
BusinessObjectFormatKey childBusinessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, null);
// create parent, child relationship
BusinessObjectFormatEntity formatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey);
BusinessObjectFormatEntity childFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(childBusinessObjectFormatKey);
childFormatEntity.getBusinessObjectFormatParents().add(formatEntity);
formatEntity.getBusinessObjectFormatChildren().add(childFormatEntity);
// create a new version of the child format
BusinessObjectFormat resultBusinessObjectFormatChildV1 = businessObjectFormatService.createBusinessObjectFormat(request2);
BusinessObjectFormat expectedBusinessObjectFormatChild = resultBusinessObjectFormatChildV0;
expectedBusinessObjectFormatChild.setId(resultBusinessObjectFormatChildV1.getId());
expectedBusinessObjectFormatChild.setBusinessObjectFormatVersion(resultBusinessObjectFormatChildV1.getBusinessObjectFormatVersion());
expectedBusinessObjectFormatChild.setBusinessObjectFormatParents(resultBusinessObjectFormatChildV1.getBusinessObjectFormatParents());
assertEquals(resultBusinessObjectFormatChildV1.getBusinessObjectFormatParents().size(), 1);
assertEquals(expectedBusinessObjectFormatChild, resultBusinessObjectFormatChildV1);
// create a new version of the parent
BusinessObjectFormat resultBusinessObjectFormatParentV2 = businessObjectFormatService.createBusinessObjectFormat(request);
assertEquals(resultBusinessObjectFormatParentV2.getBusinessObjectFormatChildren().size(), 1);
BusinessObjectFormat expectedBusinessObjectParent = resultBusinessObjectFormatV0;
expectedBusinessObjectParent.setId(resultBusinessObjectFormatParentV2.getId());
expectedBusinessObjectParent.setBusinessObjectFormatVersion(resultBusinessObjectFormatParentV2.getBusinessObjectFormatVersion());
expectedBusinessObjectParent.setBusinessObjectFormatChildren(resultBusinessObjectFormatParentV2.getBusinessObjectFormatChildren());
assertEquals(expectedBusinessObjectParent, resultBusinessObjectFormatParentV2);
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatKey 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.BusinessObjectFormatKey in project herd by FINRAOS.
the class CustomDdlServiceTest method testGetCustomDdls.
@Test
public void testGetCustomDdls() {
// List of test custom DDL names.
List<String> testCustomDdlNames = Arrays.asList(CUSTOM_DDL_NAME, CUSTOM_DDL_NAME_2);
// Create and persist a custom DDL entities.
for (String customDdlName : testCustomDdlNames) {
customDdlDaoTestHelper.createCustomDdlEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, customDdlName, TEST_DDL);
}
// Retrieve a list of custom DDL keys.
CustomDdlKeys resultCustomDdlKeys = customDdlService.getCustomDdls(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION));
// Validate the returned object.
assertNotNull(resultCustomDdlKeys);
assertEquals(testCustomDdlNames.size(), resultCustomDdlKeys.getCustomDdlKeys().size());
for (int i = 0; i < testCustomDdlNames.size(); i++) {
assertEquals(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, testCustomDdlNames.get(i)), resultCustomDdlKeys.getCustomDdlKeys().get(i));
}
}
use of org.finra.herd.model.api.xml.BusinessObjectFormatKey in project herd by FINRAOS.
the class CustomDdlServiceTest method testGetCustomDdlsMissingRequiredParameters.
@Test
public void testGetCustomDdlsMissingRequiredParameters() {
// Try to get custom DDLs when business object definition name is not specified.
try {
customDdlService.getCustomDdls(new BusinessObjectFormatKey(NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION));
fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object definition name must be specified.", e.getMessage());
}
// Try to get custom DDLs when business object format usage is not specified.
try {
customDdlService.getCustomDdls(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, BLANK_TEXT, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION));
fail("Should throw an IllegalArgumentException when business object format usage is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object format usage must be specified.", e.getMessage());
}
// Try to get custom DDLs when business object format file type is not specified.
try {
customDdlService.getCustomDdls(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, BLANK_TEXT, FORMAT_VERSION));
fail("Should throw an IllegalArgumentException when business object format file type is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object format file type must be specified.", e.getMessage());
}
// Try to get custom DDLs when business object format version is not specified.
try {
customDdlService.getCustomDdls(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null));
fail("Should throw an IllegalArgumentException when business object format version is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A business object format version must be specified.", e.getMessage());
}
}
Aggregations