@Test public void test_search() throws IOException, Exception { Pagination<Recovery> page = new Pagination<>(); page.setTotalPages(1); page.setTotalResults(1); page.setCurrentPage(0); page.setPagedData(getRecoverys()); page.getPagedData().get(0).setId("1"); when(recoveryService.search(any(RecoverySearch.class), any(BindingResult.class))).thenReturn(page); mockMvc.perform( post("/recoverys/_search?tenantId=default").content(resources.getRequestInfo()).contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().is(200)).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().json(resources.readResponse("recovery/recovery_search_valid_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public RecoveryResponse search(@ModelAttribute RecoverySearchContract recoverySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); RecoverySearch domain = new RecoverySearch(); mapper.map(recoverySearchContract, domain); RecoveryContract contract; ModelMapper model = new ModelMapper(); List<RecoveryContract> recoveryContracts = new ArrayList<>(); Pagination<Recovery> recoverys = recoveryService.search(domain, errors); if (recoverys.getPagedData() != null) { for (Recovery recovery : recoverys.getPagedData()) { contract = new RecoveryContract(); model.map(recovery, contract); recoveryContracts.add(contract); } } RecoveryResponse response = new RecoveryResponse(); response.setRecoverys(recoveryContracts); response.setPage(new PaginationContract(recoverys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
RecoveryController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public RecoveryResponse search(@ModelAttribute RecoverySearchContract recoverySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); RecoverySearch domain = new RecoverySearch(); mapper.map(recoverySearchContract, domain); RecoveryContract contract; ModelMapper model = new ModelMapper(); List<RecoveryContract> recoveryContracts = new ArrayList<>(); Pagination<Recovery> recoverys = recoveryService.search(domain, errors); if (recoverys.getPagedData() != null) { for (Recovery recovery : recoverys.getPagedData()) { contract = new RecoveryContract(); model.map(recovery, contract); recoveryContracts.add(contract); } } RecoveryResponse response = new RecoveryResponse(); response.setRecoverys(recoveryContracts); response.setPage(new PaginationContract(recoverys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
RecoveryController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public RecoveryResponse search(@ModelAttribute RecoverySearchContract recoverySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); RecoverySearch domain = new RecoverySearch(); mapper.map(recoverySearchContract, domain); RecoveryContract contract; ModelMapper model = new ModelMapper(); List<RecoveryContract> recoveryContracts = new ArrayList<>(); Pagination<Recovery> recoverys = recoveryService.search(domain, errors); if (recoverys.getPagedData() != null) { for (Recovery recovery : recoverys.getPagedData()) { contract = new RecoveryContract(); model.map(recovery, contract); recoveryContracts.add(contract); } } RecoveryResponse response = new RecoveryResponse(); response.setRecoverys(recoveryContracts); response.setPage(new PaginationContract(recoverys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
RecoveryController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public RecoveryResponse search(@ModelAttribute RecoverySearchContract recoverySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); RecoverySearch domain = new RecoverySearch(); mapper.map(recoverySearchContract, domain); RecoveryContract contract; ModelMapper model = new ModelMapper(); List<RecoveryContract> recoveryContracts = new ArrayList<>(); Pagination<Recovery> recoverys = recoveryService.search(domain, errors); if (recoverys.getPagedData() != null) { for (Recovery recovery : recoverys.getPagedData()) { contract = new RecoveryContract(); model.map(recovery, contract); recoveryContracts.add(contract); } } RecoveryResponse response = new RecoveryResponse(); response.setRecoverys(recoveryContracts); response.setPage(new PaginationContract(recoverys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) RecoveryResponse create(@RequestBody RecoveryRequest recoveryRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) RecoveryResponse update(@RequestBody RecoveryRequest recoveryRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) RecoveryResponse search(@ModelAttribute RecoverySearchContract recoverySearchContract, @RequestBody RequestInfo requestInfo,
                                   BindingResult errors,@RequestParam String tenantId); }
RecoveryController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public RecoveryResponse search(@ModelAttribute RecoverySearchContract recoverySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); RecoverySearch domain = new RecoverySearch(); mapper.map(recoverySearchContract, domain); RecoveryContract contract; ModelMapper model = new ModelMapper(); List<RecoveryContract> recoveryContracts = new ArrayList<>(); Pagination<Recovery> recoverys = recoveryService.search(domain, errors); if (recoverys.getPagedData() != null) { for (Recovery recovery : recoverys.getPagedData()) { contract = new RecoveryContract(); model.map(recovery, contract); recoveryContracts.add(contract); } } RecoveryResponse response = new RecoveryResponse(); response.setRecoverys(recoveryContracts); response.setPage(new PaginationContract(recoverys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) RecoveryResponse create(@RequestBody RecoveryRequest recoveryRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) RecoveryResponse update(@RequestBody RecoveryRequest recoveryRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) RecoveryResponse search(@ModelAttribute RecoverySearchContract recoverySearchContract, @RequestBody RequestInfo requestInfo,
                                   BindingResult errors,@RequestParam String tenantId);  }