Search in sources :

Example 11 with BusinessObjectDefinitionSubjectMatterExpertKey

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")));
}
Also used : BusinessObjectDefinitionSubjectMatterExpertKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey) BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity) Test(org.junit.Test)

Example 12 with BusinessObjectDefinitionSubjectMatterExpertKey

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());
    }
}
Also used : BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionSubjectMatterExpertKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey) Test(org.junit.Test)

Example 13 with BusinessObjectDefinitionSubjectMatterExpertKey

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);
}
Also used : BusinessObjectDefinitionSubjectMatterExpertKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey) BusinessObjectDefinitionSubjectMatterExpert(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpert) BusinessObjectDefinitionSubjectMatterExpertCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertCreateRequest) Test(org.junit.Test)

Example 14 with BusinessObjectDefinitionSubjectMatterExpertKey

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());
    }
}
Also used : BusinessObjectDefinitionSubjectMatterExpertKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 15 with BusinessObjectDefinitionSubjectMatterExpertKey

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);
}
Also used : BusinessObjectDefinitionSubjectMatterExpertKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey) BusinessObjectDefinitionSubjectMatterExpert(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpert) BusinessObjectDefinitionSubjectMatterExpertCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertCreateRequest) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionSubjectMatterExpertKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey)23 Test (org.junit.Test)23 BusinessObjectDefinitionSubjectMatterExpert (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpert)10 BusinessObjectDefinitionSubjectMatterExpertCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertCreateRequest)9 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)5 BusinessObjectDefinitionSubjectMatterExpertKeys (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKeys)5 BusinessObjectDefinitionSubjectMatterExpertEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity)5 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)1