use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertDaoTest method testGetBusinessObjectDefinitionSubjectMatterExpertByKey.
@Test
public void testGetBusinessObjectDefinitionSubjectMatterExpertByKey() {
// Create a business object definition subject matter expert key.
BusinessObjectDefinitionSubjectMatterExpertKey key = new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID);
// Create a business object definition subject matter expert entity.
BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity = businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(key);
// Get business object definition subject matter expert.
assertEquals(businessObjectDefinitionSubjectMatterExpertEntity, businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(key));
// Get business object definition subject matter expert by passing all case-insensitive parameters in uppercase.
assertEquals(businessObjectDefinitionSubjectMatterExpertEntity, businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), USER_ID.toUpperCase())));
// Get business object definition subject matter expert by passing all case-insensitive parameters in lowercase.
assertEquals(businessObjectDefinitionSubjectMatterExpertEntity, businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), USER_ID.toLowerCase())));
// Try invalid values for all input parameters.
assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey("I_DO_NOT_EXIST", BDEF_NAME, USER_ID)));
assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, "I_DO_NOT_EXIST", USER_ID)));
assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST")));
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertDaoTest method testGetBusinessObjectDefinitionSubjectMatterExpertByKeyDuplicateSubjectMatterExperts.
@Test
public void testGetBusinessObjectDefinitionSubjectMatterExpertByKeyDuplicateSubjectMatterExperts() throws Exception {
// Create a business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
// Create duplicate business object definition subject matter experts.
businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(businessObjectDefinitionEntity, USER_ID.toUpperCase());
businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(businessObjectDefinitionEntity, USER_ID.toLowerCase());
// Try to get business object definition subject matter expert when business object definition has duplicate subject matter experts.
try {
businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID));
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("Found more than one business object definition subject matter expert instance with parameters {namespace=\"%s\", " + "businessObjectDefinitionName=\"%s\", userId=\"%s\"}.", BDEF_NAMESPACE, BDEF_NAME, USER_ID), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey 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.BusinessObjectDefinitionSubjectMatterExpertKey in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertServiceTest method testDeleteBusinessObjectDefinitionSubjectMatterExpertBusinessObjectDefinitionSubjectMatterExpertNoExists.
@Test
public void testDeleteBusinessObjectDefinitionSubjectMatterExpertBusinessObjectDefinitionSubjectMatterExpertNoExists() {
// Try to delete a non-existing business object definition subject matter expert.
try {
businessObjectDefinitionSubjectMatterExpertService.deleteBusinessObjectDefinitionSubjectMatterExpert(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Subject matter expert with user id \"%s\" does not exist for business object definition {%s}.", USER_ID, businessObjectDefinitionServiceTestHelper.getExpectedBusinessObjectDefinitionKeyAsString(BDEF_NAMESPACE, BDEF_NAME)), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey 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