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