Search in sources :

Example 1 with BusinessObjectDefinitionSubjectMatterExpertCreateRequest

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);
}
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 2 with BusinessObjectDefinitionSubjectMatterExpertCreateRequest

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

Example 3 with BusinessObjectDefinitionSubjectMatterExpertCreateRequest

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

Example 4 with BusinessObjectDefinitionSubjectMatterExpertCreateRequest

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);
}
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 5 with BusinessObjectDefinitionSubjectMatterExpertCreateRequest

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);
}
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

BusinessObjectDefinitionSubjectMatterExpertCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertCreateRequest)9 BusinessObjectDefinitionSubjectMatterExpertKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey)9 Test (org.junit.Test)9 BusinessObjectDefinitionSubjectMatterExpert (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpert)5 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1