@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testSearch() { List<MarriageDocumentType> marriageDocumentTypes = getMarriageDocumentTypesForSearch(); MarriageDocTypeResponse marriageDocTypeResponse = new MarriageDocTypeResponse(); marriageDocTypeResponse.setMarriageDocTypes(marriageDocumentTypes); ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setTs(Long.valueOf("987456321")); responseInfo.setStatus(HttpStatus.OK.toString()); marriageDocTypeResponse.setResponseInfo(responseInfo); when(errorHandler.getErrorResponse(Matchers.any(), Matchers.any(RequestInfo.class))).thenReturn(null); when(marriageDocumentTypeService.search(Matchers.any(MarriageDocumentTypeSearchCriteria.class), Matchers.any(RequestInfo.class))) .thenReturn(new ResponseEntity(marriageDocTypeResponse, HttpStatus.OK)); try { mockMvc.perform(post("/marriageRegns/documents/_search") .content(getFileContents("marriageDocumentTypeSearchRequest.json")).param("tenantId", "ap.kurnool") .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(200)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().json(getFileContents("marriageDocumentTypeSearchResponse.json"))); } catch (Exception e) { e.printStackTrace(); } }
@PostMapping @RequestMapping("/_search") public ResponseEntity<?> search(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper, BindingResult bindingResultsForRequestInfoWrapper, @ModelAttribute @Valid MarriageDocumentTypeSearchCriteria marriageDocTypeSearchCriteria, BindingResult bindingResult) { RequestInfo requestInfo = requestInfoWrapper.getRequestInfo(); if (bindingResult.hasErrors()) return new ResponseEntity<>(errorHandler.getErrorResponse(bindingResult, requestInfo), HttpStatus.BAD_REQUEST); ResponseEntity<?> marriageDocumentTypeResponse = null; try { marriageDocumentTypeResponse = marriageDocumentTypeService.search(marriageDocTypeSearchCriteria, requestInfo); } catch (Exception e) { log.info(" Error While Procssing the Request!"); return errorHandler.getUnExpectedErrorResponse(bindingResultsForRequestInfoWrapper, requestInfo, "Encountered : " + e.getMessage()); } return marriageDocumentTypeResponse; }
MarriageDocumentTypeController { @PostMapping @RequestMapping("/_search") public ResponseEntity<?> search(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper, BindingResult bindingResultsForRequestInfoWrapper, @ModelAttribute @Valid MarriageDocumentTypeSearchCriteria marriageDocTypeSearchCriteria, BindingResult bindingResult) { RequestInfo requestInfo = requestInfoWrapper.getRequestInfo(); if (bindingResult.hasErrors()) return new ResponseEntity<>(errorHandler.getErrorResponse(bindingResult, requestInfo), HttpStatus.BAD_REQUEST); ResponseEntity<?> marriageDocumentTypeResponse = null; try { marriageDocumentTypeResponse = marriageDocumentTypeService.search(marriageDocTypeSearchCriteria, requestInfo); } catch (Exception e) { log.info(" Error While Procssing the Request!"); return errorHandler.getUnExpectedErrorResponse(bindingResultsForRequestInfoWrapper, requestInfo, "Encountered : " + e.getMessage()); } return marriageDocumentTypeResponse; } }
MarriageDocumentTypeController { @PostMapping @RequestMapping("/_search") public ResponseEntity<?> search(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper, BindingResult bindingResultsForRequestInfoWrapper, @ModelAttribute @Valid MarriageDocumentTypeSearchCriteria marriageDocTypeSearchCriteria, BindingResult bindingResult) { RequestInfo requestInfo = requestInfoWrapper.getRequestInfo(); if (bindingResult.hasErrors()) return new ResponseEntity<>(errorHandler.getErrorResponse(bindingResult, requestInfo), HttpStatus.BAD_REQUEST); ResponseEntity<?> marriageDocumentTypeResponse = null; try { marriageDocumentTypeResponse = marriageDocumentTypeService.search(marriageDocTypeSearchCriteria, requestInfo); } catch (Exception e) { log.info(" Error While Procssing the Request!"); return errorHandler.getUnExpectedErrorResponse(bindingResultsForRequestInfoWrapper, requestInfo, "Encountered : " + e.getMessage()); } return marriageDocumentTypeResponse; }  }
MarriageDocumentTypeController { @PostMapping @RequestMapping("/_search") public ResponseEntity<?> search(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper, BindingResult bindingResultsForRequestInfoWrapper, @ModelAttribute @Valid MarriageDocumentTypeSearchCriteria marriageDocTypeSearchCriteria, BindingResult bindingResult) { RequestInfo requestInfo = requestInfoWrapper.getRequestInfo(); if (bindingResult.hasErrors()) return new ResponseEntity<>(errorHandler.getErrorResponse(bindingResult, requestInfo), HttpStatus.BAD_REQUEST); ResponseEntity<?> marriageDocumentTypeResponse = null; try { marriageDocumentTypeResponse = marriageDocumentTypeService.search(marriageDocTypeSearchCriteria, requestInfo); } catch (Exception e) { log.info(" Error While Procssing the Request!"); return errorHandler.getUnExpectedErrorResponse(bindingResultsForRequestInfoWrapper, requestInfo, "Encountered : " + e.getMessage()); } return marriageDocumentTypeResponse; }  @PostMapping @RequestMapping("/_search") ResponseEntity<?> search(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult bindingResultsForRequestInfoWrapper,
			@ModelAttribute @Valid MarriageDocumentTypeSearchCriteria marriageDocTypeSearchCriteria,
			BindingResult bindingResult); @PostMapping @RequestMapping("/_create") ResponseEntity<?> createMarriageDocumentType(
			@RequestBody @Valid MarriageDocTypeRequest marriageDocTypeRequest, BindingResult bindingResult); @PostMapping @RequestMapping("/_update") ResponseEntity<?> updateMarriageDocumentType(
			@RequestBody @Valid MarriageDocTypeRequest marriageDocTypeRequest, BindingResult bindingResult); }
MarriageDocumentTypeController { @PostMapping @RequestMapping("/_search") public ResponseEntity<?> search(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper, BindingResult bindingResultsForRequestInfoWrapper, @ModelAttribute @Valid MarriageDocumentTypeSearchCriteria marriageDocTypeSearchCriteria, BindingResult bindingResult) { RequestInfo requestInfo = requestInfoWrapper.getRequestInfo(); if (bindingResult.hasErrors()) return new ResponseEntity<>(errorHandler.getErrorResponse(bindingResult, requestInfo), HttpStatus.BAD_REQUEST); ResponseEntity<?> marriageDocumentTypeResponse = null; try { marriageDocumentTypeResponse = marriageDocumentTypeService.search(marriageDocTypeSearchCriteria, requestInfo); } catch (Exception e) { log.info(" Error While Procssing the Request!"); return errorHandler.getUnExpectedErrorResponse(bindingResultsForRequestInfoWrapper, requestInfo, "Encountered : " + e.getMessage()); } return marriageDocumentTypeResponse; }  @PostMapping @RequestMapping("/_search") ResponseEntity<?> search(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper,
			BindingResult bindingResultsForRequestInfoWrapper,
			@ModelAttribute @Valid MarriageDocumentTypeSearchCriteria marriageDocTypeSearchCriteria,
			BindingResult bindingResult); @PostMapping @RequestMapping("/_create") ResponseEntity<?> createMarriageDocumentType(
			@RequestBody @Valid MarriageDocTypeRequest marriageDocTypeRequest, BindingResult bindingResult); @PostMapping @RequestMapping("/_update") ResponseEntity<?> updateMarriageDocumentType(
			@RequestBody @Valid MarriageDocTypeRequest marriageDocTypeRequest, BindingResult bindingResult);  }