use of org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionAlreadyExists.
@Test
public void testCreateBusinessObjectDefinitionAlreadyExists() throws Exception {
// Create and persist a business object definition.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, null);
// Try to create a business object definition when it already exists.
try {
businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES));
fail("Should throw an AlreadyExistsException when business object definition already exists.");
} catch (AlreadyExistsException e) {
assertEquals(String.format("Unable to create business object definition with name \"%s\" because it already exists for namespace \"%s\".", BDEF_NAME, NAMESPACE), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionNoAttributes.
@Test
public void testCreateBusinessObjectDefinitionNoAttributes() {
// Create and persist database entities required for testing.
businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
// Create a business object definition without specifying any of the attributes.
BusinessObjectDefinition resultBusinessObjectDefinition = businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, NO_BDEF_DESCRIPTION, NO_BDEF_DISPLAY_NAME, NO_ATTRIBUTES));
// Get the business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
assertNotNull(businessObjectDefinitionEntity);
// Validate the returned object.
assertEquals(new BusinessObjectDefinition(resultBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, NO_BDEF_DESCRIPTION, NO_BDEF_SHORT_DESCRIPTION, NO_BDEF_DISPLAY_NAME, NO_ATTRIBUTES, NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), resultBusinessObjectDefinition);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionTrimParameters.
@Test
public void testCreateBusinessObjectDefinitionTrimParameters() {
// Create and persist database entities required for testing.
businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
// Create a business object definition using input parameters with leading and trailing empty spaces.
BusinessObjectDefinition resultBusinessObjectDefinition = businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME), addWhitespace(DATA_PROVIDER_NAME), addWhitespace(BDEF_DESCRIPTION), addWhitespace(BDEF_DISPLAY_NAME), Arrays.asList(new Attribute(addWhitespace(ATTRIBUTE_NAME_1_MIXED_CASE), addWhitespace(ATTRIBUTE_VALUE_1)))));
// Get the business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
assertNotNull(businessObjectDefinitionEntity);
// Validate the returned object.
assertEquals(new BusinessObjectDefinition(resultBusinessObjectDefinition.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, addWhitespace(BDEF_DESCRIPTION), NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, addWhitespace(ATTRIBUTE_VALUE_1))), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), resultBusinessObjectDefinition);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionDuplicateAttributes.
@Test
public void testCreateBusinessObjectDefinitionDuplicateAttributes() {
// Try to create a business object definition instance when duplicate attributes are specified.
try {
businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, Arrays.asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3), new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_3))));
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.BusinessObjectDefinitionCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionInvalidParameters.
@Test
public void testCreateBusinessObjectDefinitionInvalidParameters() {
BusinessObjectDefinitionCreateRequest request;
// Create and persist database entities required for testing.
businessObjectDefinitionServiceTestHelper.createDatabaseEntitiesForBusinessObjectDefinitionTesting();
// Try to create a business object definition using non-existing namespace.
request = new BusinessObjectDefinitionCreateRequest("I_DO_NOT_EXIST", BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an ObjectNotFoundException when using non-existing namespace.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Namespace \"%s\" doesn't exist.", request.getNamespace()), e.getMessage());
}
// Try to create a business object definition when namespace contains a forward slash character.
request = new BusinessObjectDefinitionCreateRequest(addSlash(BDEF_NAMESPACE), BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an IllegalArgumentException when namespace contains a forward slash character");
} catch (IllegalArgumentException e) {
assertEquals("Namespace can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object definition when business object definition name contains a forward slash character.
request = new BusinessObjectDefinitionCreateRequest(BDEF_NAMESPACE, addSlash(BDEF_NAME), DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an IllegalArgumentException when business object definition name contains a forward slash character");
} catch (IllegalArgumentException e) {
assertEquals("Business object definition name can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object definition using non-existing data provider.
request = new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an ObjectNotFoundException when using non-existing data provider name.");
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Data provider with name \"%s\" doesn't exist.", request.getDataProviderName()), e.getMessage());
}
// Try to create a business object definition when data provider name contains a forward slash character.
request = new BusinessObjectDefinitionCreateRequest(BDEF_NAMESPACE, BDEF_NAME, addSlash(DATA_PROVIDER_NAME), BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES);
try {
businessObjectDefinitionService.createBusinessObjectDefinition(request);
fail("Should throw an IllegalArgumentException when data provider name contains a forward slash character");
} catch (IllegalArgumentException e) {
assertEquals("Data provider name can not contain a forward slash character.", e.getMessage());
}
}
Aggregations