use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertServiceTest method testCreateBusinessObjectDefinitionSubjectMatterExpert.
@Test
public void testCreateBusinessObjectDefinitionSubjectMatterExpert() {
// Create a business object definition subject matter expert key.
BusinessObjectDefinitionSubjectMatterExpertKey key = new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID);
// Create and persist the relative database entities.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, DESCRIPTION);
// Create a business object definition subject matter expert.
BusinessObjectDefinitionSubjectMatterExpert resultBusinessObjectDefinitionSubjectMatterExpert = businessObjectDefinitionSubjectMatterExpertService.createBusinessObjectDefinitionSubjectMatterExpert(new BusinessObjectDefinitionSubjectMatterExpertCreateRequest(key));
// Validate the returned object.
assertEquals(new BusinessObjectDefinitionSubjectMatterExpert(resultBusinessObjectDefinitionSubjectMatterExpert.getId(), key), resultBusinessObjectDefinitionSubjectMatterExpert);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertServiceTest method testCreateBusinessObjectDefinitionSubjectMatterExpertBusinessObjectDefinitionSubjectMatterExpertAlreadyExists.
@Test
public void testCreateBusinessObjectDefinitionSubjectMatterExpertBusinessObjectDefinitionSubjectMatterExpertAlreadyExists() {
// Create and persist a business object definition subject matter expert entity.
businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID));
// Try to add a duplicate business object definition subject matter expert.
for (String userId : Arrays.asList(USER_ID, USER_ID.toUpperCase(), USER_ID.toLowerCase())) {
try {
businessObjectDefinitionSubjectMatterExpertService.createBusinessObjectDefinitionSubjectMatterExpert(new BusinessObjectDefinitionSubjectMatterExpertCreateRequest(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, userId)));
fail();
} catch (AlreadyExistsException e) {
assertEquals(String.format("Unable to create business object definition subject matter expert with user id \"%s\" " + "because it already exists for the business object definition {%s}.", userId, businessObjectDefinitionServiceTestHelper.getExpectedBusinessObjectDefinitionKeyAsString(BDEF_NAMESPACE, BDEF_NAME)), e.getMessage());
}
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertServiceTest method testCreateBusinessObjectDefinitionSubjectMatterExpertInvalidParameters.
@Test
public void testCreateBusinessObjectDefinitionSubjectMatterExpertInvalidParameters() {
// Try to create a business object definition subject matter expert when business object definition namespace contains a forward slash character.
try {
businessObjectDefinitionSubjectMatterExpertService.createBusinessObjectDefinitionSubjectMatterExpert(new BusinessObjectDefinitionSubjectMatterExpertCreateRequest(new BusinessObjectDefinitionSubjectMatterExpertKey(addSlash(BDEF_NAMESPACE), BDEF_NAME, USER_ID)));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Namespace can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object definition subject matter expert when business object definition name contains a forward slash character.
try {
businessObjectDefinitionSubjectMatterExpertService.createBusinessObjectDefinitionSubjectMatterExpert(new BusinessObjectDefinitionSubjectMatterExpertCreateRequest(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, addSlash(BDEF_NAME), USER_ID)));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Business object definition name can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object definition subject matter expert when user id contains a forward slash character.
try {
businessObjectDefinitionSubjectMatterExpertService.createBusinessObjectDefinitionSubjectMatterExpert(new BusinessObjectDefinitionSubjectMatterExpertCreateRequest(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, addSlash(USER_ID))));
fail();
} catch (IllegalArgumentException e) {
assertEquals("User id can not contain a forward slash character.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertRestControllerTest method testCreateBusinessObjectDefinitionSubjectMatterExpert.
@Test
public void testCreateBusinessObjectDefinitionSubjectMatterExpert() {
// Create a business object definition subject matter expert key.
BusinessObjectDefinitionSubjectMatterExpertKey key = new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID);
BusinessObjectDefinitionSubjectMatterExpertCreateRequest request = new BusinessObjectDefinitionSubjectMatterExpertCreateRequest(key);
BusinessObjectDefinitionSubjectMatterExpert businessObjectDefinitionSubjectMatterExpert = new BusinessObjectDefinitionSubjectMatterExpert(ID, key);
when(businessObjectDefinitionSubjectMatterExpertService.createBusinessObjectDefinitionSubjectMatterExpert(request)).thenReturn(businessObjectDefinitionSubjectMatterExpert);
// Create a business object definition subject matter expert.
BusinessObjectDefinitionSubjectMatterExpert resultBusinessObjectDefinitionSubjectMatterExpert = businessObjectDefinitionSubjectMatterExpertRestController.createBusinessObjectDefinitionSubjectMatterExpert(request);
// Verify the external calls.
verify(businessObjectDefinitionSubjectMatterExpertService).createBusinessObjectDefinitionSubjectMatterExpert(request);
verifyNoMoreInteractions(businessObjectDefinitionSubjectMatterExpertService);
// Validate the returned object.
assertEquals(businessObjectDefinitionSubjectMatterExpert, resultBusinessObjectDefinitionSubjectMatterExpert);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertCreateRequest in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertServiceTest method testCreateBusinessObjectDefinitionSubjectMatterExpertTrimParameters.
@Test
public void testCreateBusinessObjectDefinitionSubjectMatterExpertTrimParameters() {
// Create and persist the relative database entities.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, DESCRIPTION);
// Create a business object definition subject matter expert using input parameters with leading and trailing empty spaces.
BusinessObjectDefinitionSubjectMatterExpert resultBusinessObjectDefinitionSubjectMatterExpert = businessObjectDefinitionSubjectMatterExpertService.createBusinessObjectDefinitionSubjectMatterExpert(new BusinessObjectDefinitionSubjectMatterExpertCreateRequest(new BusinessObjectDefinitionSubjectMatterExpertKey(addWhitespace(BDEF_NAMESPACE), addWhitespace(BDEF_NAME.toUpperCase()), addWhitespace(USER_ID))));
// Validate the returned object.
assertEquals(new BusinessObjectDefinitionSubjectMatterExpert(resultBusinessObjectDefinitionSubjectMatterExpert.getId(), new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID)), resultBusinessObjectDefinitionSubjectMatterExpert);
}
Aggregations