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