Search in sources :

Example 11 with BusinessObjectDataSearchRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest in project herd by FINRAOS.

the class SearchBusinessObjectDataTest method getBusinessObjectDataSearchRequest.

private BusinessObjectDataSearchRequest getBusinessObjectDataSearchRequest() {
    BusinessObjectDataSearchRequest businessObjectDataSearchRequest = new BusinessObjectDataSearchRequest();
    List<BusinessObjectDataSearchFilter> businessObjectDataSearchFilters = new ArrayList<>();
    List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
    BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
    businessObjectDataSearchKey.setNamespace(NAMESPACE);
    businessObjectDataSearchKey.setBusinessObjectDefinitionName(BDEF_NAME);
    businessObjectDataSearchKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
    businessObjectDataSearchKeys.add(businessObjectDataSearchKey);
    BusinessObjectDataSearchFilter businessObjectDataSearchFilter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
    businessObjectDataSearchFilters.add(businessObjectDataSearchFilter);
    businessObjectDataSearchRequest.setBusinessObjectDataSearchFilters(businessObjectDataSearchFilters);
    return businessObjectDataSearchRequest;
}
Also used : BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)

Example 12 with BusinessObjectDataSearchRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest in project herd by FINRAOS.

the class SearchBusinessObjectDataTest method testSearchBusinessObjectDataWithJson.

@Test
public void testSearchBusinessObjectDataWithJson() throws Exception {
    this.businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
    BusinessObjectDataSearchRequest businessObjectDataSearchRequest = getBusinessObjectDataSearchRequest();
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataSearchRequest", "${businessObjectDataSearchRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "json"));
    parameters.add(buildParameter("businessObjectDataSearchRequest", jsonHelper.objectToJson(businessObjectDataSearchRequest)));
    parameters.add(buildParameter("pageNum", PAGE_NUMBER_ONE.toString()));
    parameters.add(buildParameter("pageSize", PAGE_SIZE_ONE_THOUSAND.toString()));
    // Get the expected result by calling the service method directly.
    BusinessObjectDataSearchResultPagingInfoDto result = this.businessObjectDataService.searchBusinessObjectData(PAGE_NUMBER_ONE, PAGE_SIZE_ONE_THOUSAND, businessObjectDataSearchRequest);
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(result.getBusinessObjectDataSearchResult()));
    testActivitiServiceTaskSuccess(SearchBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) Test(org.junit.Test)

Example 13 with BusinessObjectDataSearchRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest in project herd by FINRAOS.

the class BusinessObjectDataRestControllerTest method testSearchBusinessObjectData.

@Test
public void testSearchBusinessObjectData() {
    // Create a business object data search request.
    BusinessObjectDataSearchRequest businessObjectDataSearchRequest = new BusinessObjectDataSearchRequest();
    // Create a business object data search response with paging information.
    BusinessObjectDataSearchResultPagingInfoDto businessObjectDataSearchResultPagingInfoDto = new BusinessObjectDataSearchResultPagingInfoDto(Long.valueOf(PAGE_NUMBER_ONE), Long.valueOf(PAGE_SIZE_ONE_THOUSAND), PAGE_COUNT, TOTAL_RECORDS_ON_PAGE, TOTAL_RECORD_COUNT, MAX_RESULTS_PER_PAGE, new BusinessObjectDataSearchResult());
    // Create a mocked HTTP servlet response.
    HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
    // Mock the external calls.
    when(businessObjectDataService.searchBusinessObjectData(PAGE_NUMBER_ONE, PAGE_SIZE_ONE_THOUSAND, businessObjectDataSearchRequest)).thenReturn(businessObjectDataSearchResultPagingInfoDto);
    // Call the method under test.
    BusinessObjectDataSearchResult result = businessObjectDataRestController.searchBusinessObjectData(PAGE_NUMBER_ONE, PAGE_SIZE_ONE_THOUSAND, businessObjectDataSearchRequest, httpServletResponse);
    // Verify the external calls.
    verify(businessObjectDataService).searchBusinessObjectData(PAGE_NUMBER_ONE, PAGE_SIZE_ONE_THOUSAND, businessObjectDataSearchRequest);
    verifyNoMoreInteractionsHelper();
    // Verify interactions with the mocked objects.
    verify(httpServletResponse).setHeader(HerdBaseController.HTTP_HEADER_PAGING_PAGE_NUM, String.valueOf(PAGE_NUMBER_ONE));
    verify(httpServletResponse).setHeader(HerdBaseController.HTTP_HEADER_PAGING_PAGE_SIZE, String.valueOf(PAGE_SIZE_ONE_THOUSAND));
    verify(httpServletResponse).setHeader(HerdBaseController.HTTP_HEADER_PAGING_PAGE_COUNT, String.valueOf(PAGE_COUNT));
    verify(httpServletResponse).setHeader(HerdBaseController.HTTP_HEADER_PAGING_TOTAL_RECORDS_ON_PAGE, String.valueOf(TOTAL_RECORDS_ON_PAGE));
    verify(httpServletResponse).setHeader(HerdBaseController.HTTP_HEADER_PAGING_TOTAL_RECORD_COUNT, String.valueOf(TOTAL_RECORD_COUNT));
    verify(httpServletResponse).setHeader(HerdBaseController.HTTP_HEADER_PAGING_MAX_RESULTS_PER_PAGE, String.valueOf(MAX_RESULTS_PER_PAGE));
    verifyNoMoreInteractions(httpServletResponse);
    // Validate the results.
    assertEquals(businessObjectDataSearchResultPagingInfoDto.getBusinessObjectDataSearchResult(), result);
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) HttpServletResponse(javax.servlet.http.HttpServletResponse) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) BusinessObjectDataSearchResult(org.finra.herd.model.api.xml.BusinessObjectDataSearchResult) Test(org.junit.Test)

Example 14 with BusinessObjectDataSearchRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest in project herd by FINRAOS.

the class BusinessObjectDataSearchHelperTest method testValidateBusinessObjectDataSearchRequestIllegalArgumentExceptions.

@Test
public void testValidateBusinessObjectDataSearchRequestIllegalArgumentExceptions() {
    try {
        businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(null);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object data search request must be specified.", e.getMessage());
    }
    try {
        businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest());
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object data search filter must be specified.", e.getMessage());
    }
    try {
        businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest(new ArrayList<>()));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object data search filter must be specified.", e.getMessage());
    }
    try {
        businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest(Arrays.asList(new BusinessObjectDataSearchFilter(), new BusinessObjectDataSearchFilter())));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A list of business object data search filters can only have one element.", e.getMessage());
    }
    try {
        businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest(Collections.singletonList(new BusinessObjectDataSearchFilter())));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object data search key must be specified.", e.getMessage());
    }
    try {
        businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest(Collections.singletonList(new BusinessObjectDataSearchFilter(new ArrayList<>()))));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object data search key must be specified.", e.getMessage());
    }
    try {
        businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest(Collections.singletonList(new BusinessObjectDataSearchFilter(Arrays.asList(new BusinessObjectDataSearchKey(), new BusinessObjectDataSearchKey())))));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A list of business object data search keys can only have one element.", e.getMessage());
    }
}
Also used : BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 15 with BusinessObjectDataSearchRequest

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest in project herd by FINRAOS.

the class SearchBusinessObjectDataTest method testSearchBusinessObjectDataWithXML.

@Test
public void testSearchBusinessObjectDataWithXML() throws Exception {
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
    BusinessObjectDataSearchRequest businessObjectDataSearchRequest = getBusinessObjectDataSearchRequest();
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataSearchRequest", "${businessObjectDataSearchRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "xml"));
    parameters.add(buildParameter("businessObjectDataSearchRequest", xmlHelper.objectToXml(businessObjectDataSearchRequest)));
    parameters.add(buildParameter("pageNum", PAGE_NUMBER_ONE.toString()));
    parameters.add(buildParameter("pageSize", PAGE_SIZE_ONE_THOUSAND.toString()));
    // Get the expected result by calling the service method directly.
    BusinessObjectDataSearchResultPagingInfoDto result = this.businessObjectDataService.searchBusinessObjectData(PAGE_NUMBER_ONE, PAGE_SIZE_ONE_THOUSAND, businessObjectDataSearchRequest);
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(result.getBusinessObjectDataSearchResult()));
    testActivitiServiceTaskSuccess(SearchBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) Test(org.junit.Test)

Aggregations

BusinessObjectDataSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)21 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)13 BusinessObjectDataSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter)12 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)12 BusinessObjectDataSearchResultPagingInfoDto (org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto)10 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)6 BusinessObjectDataSearchResult (org.finra.herd.model.api.xml.BusinessObjectDataSearchResult)5 HashMap (java.util.HashMap)4 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)4 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 Parameter (org.finra.herd.model.api.xml.Parameter)3 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1