Search in sources :

Example 6 with BusinessObjectDataSearchResultPagingInfoDto

use of org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto in project herd by FINRAOS.

the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithPartitionFilterValues.

@Test
public void testSearchBusinessObjectDataWithPartitionFilterValues() {
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
    BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest();
    List<BusinessObjectDataSearchFilter> filters = new ArrayList<>();
    List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
    BusinessObjectDataSearchKey key = new BusinessObjectDataSearchKey();
    key.setNamespace(NAMESPACE);
    key.setBusinessObjectDefinitionName(BDEF_NAME);
    List<PartitionValueFilter> partitionValueFilters = new ArrayList<>();
    PartitionValueFilter partitionValueFilter = new PartitionValueFilter();
    partitionValueFilters.add(partitionValueFilter);
    partitionValueFilter.setPartitionKey(PARTITION_KEY);
    List<String> values = new ArrayList<>();
    values.add(PARTITION_VALUE);
    partitionValueFilter.setPartitionValues(values);
    key.setPartitionValueFilters(partitionValueFilters);
    businessObjectDataSearchKeys.add(key);
    BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
    filters.add(filter);
    request.setBusinessObjectDataSearchFilters(filters);
    BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
    // The result list should be empty, as no schema column is registered.
    assertEquals(0, result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements().size());
    // Validate the paging information.
    assertEquals(Long.valueOf(DEFAULT_PAGE_NUMBER), result.getPageNum());
    assertEquals(Long.valueOf(PAGE_SIZE), result.getPageSize());
    assertEquals(Long.valueOf(0), result.getPageCount());
    assertEquals(Long.valueOf(0), result.getTotalRecordsOnPage());
    assertEquals(Long.valueOf(0), result.getTotalRecordCount());
    assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) 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) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Example 7 with BusinessObjectDataSearchResultPagingInfoDto

use of org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto 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 8 with BusinessObjectDataSearchResultPagingInfoDto

use of org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto in project herd by FINRAOS.

the class BusinessObjectDataRestController method searchBusinessObjectData.

/**
 * Searches business object data based on namespace, definition name, format usage, file type, and format version. <p> Namespace and definition name are
 * required. </p> <p> Requires READ permission on namespace </p> <p> The response contains the following HTTP headers: <ul> <li>Paging-MaxResultsPerPage -
 * the HTTP header for the maximum number of results that will be returned on any page of data. The "pageSize" query parameter should not be greater than
 * this value or an HTTP status of 400 (Bad Request) error would be returned</li> <li>Paging-PageCount - the HTTP header for the total number of pages that
 * exist assuming a page size limit and the total records returned in the query</li> <li>Paging-PageNum - the HTTP header for the current page number being
 * returned. For the first page, this value would be "1"</li> <li>Paging-PageSize - the HTTP header for the current page size limit. This is based on what
 * is specified in the request "pageSize" query parameter</li> <li>Paging-TotalRecordsOnPage - the HTTP header for the total number of records returned on
 * the current page. This could be less than the "pageSize" query parameter on the last page of data</li> <li>Paging-TotalRecordCount - the HTTP header for
 * the total number of records that would be returned across all pages. This is basically a "select count" query</li> </ul> </p>
 *
 * @param pageNum the page number. If this parameter is specified, results contain the appropriate page that is specified. Page numbers are one-based - that
 * is the first page number is one. Default value is 1
 * @param pageSize the page size. If pageSize parameter is specified, results contain that number of business object data (unless it is the end of the
 * result set). Default value is 1000
 * @param businessObjectDataSearchRequest the business object data search request
 * @param httpServletResponse the HTTP servlet response
 *
 * @return the business object data search result with HTTP headers that contain the pagination information
 */
@RequestMapping(value = "/businessObjectData/search", method = RequestMethod.POST, consumes = { "application/xml", "application/json" })
@Secured(SecurityFunctions.FN_BUSINESS_OBJECT_DATA_SEARCH_POST)
public BusinessObjectDataSearchResult searchBusinessObjectData(@RequestParam(value = "pageNum", required = false) Integer pageNum, @RequestParam(value = "pageSize", required = false) Integer pageSize, @RequestBody BusinessObjectDataSearchRequest businessObjectDataSearchRequest, HttpServletResponse httpServletResponse) {
    // Search business object data.
    BusinessObjectDataSearchResultPagingInfoDto businessObjectDataSearchResultPagingInfoDto = businessObjectDataService.searchBusinessObjectData(pageNum, pageSize, businessObjectDataSearchRequest);
    // Add HTTP headers to HTTP servlet response per paging information.
    addPagingHttpHeaders(httpServletResponse, businessObjectDataSearchResultPagingInfoDto);
    // Create and return the HTTP response.
    return businessObjectDataSearchResultPagingInfoDto.getBusinessObjectDataSearchResult();
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with BusinessObjectDataSearchResultPagingInfoDto

use of org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto 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 10 with BusinessObjectDataSearchResultPagingInfoDto

use of org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto 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

BusinessObjectDataSearchResultPagingInfoDto (org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto)12 BusinessObjectDataSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)10 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)7 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)6 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)6 BusinessObjectDataSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter)5 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)3 HashMap (java.util.HashMap)2 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 BusinessObjectDataSearchResult (org.finra.herd.model.api.xml.BusinessObjectDataSearchResult)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)1 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)1 Secured (org.springframework.security.access.annotation.Secured)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1