@Test public void testSearch() throws IOException, Exception { when(chartOfAccountService.search(any(ChartOfAccountSearch.class), any(BindingResult.class))) .thenReturn((getPagination())); mockMvc.perform( post("/chartofaccounts/_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("chartofaccount/chartofaccount_search_valid_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public ChartOfAccountResponse search(@ModelAttribute ChartOfAccountSearchContract chartOfAccountSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); ChartOfAccountSearch domain = new ChartOfAccountSearch(); mapper.map(chartOfAccountSearchContract, domain); ChartOfAccountContract contract; ModelMapper model = new ModelMapper(); List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); Pagination<ChartOfAccount> chartofaccounts = chartOfAccountService.search(domain, errors); for (ChartOfAccount chartOfAccount : chartofaccounts.getPagedData()) { contract = new ChartOfAccountContract(); model.map(chartOfAccount, contract); chartOfAccountContracts.add(contract); } ChartOfAccountResponse response = new ChartOfAccountResponse(); response.setChartOfAccounts(chartOfAccountContracts); response.setPage(new PaginationContract(chartofaccounts)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
ChartOfAccountController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public ChartOfAccountResponse search(@ModelAttribute ChartOfAccountSearchContract chartOfAccountSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); ChartOfAccountSearch domain = new ChartOfAccountSearch(); mapper.map(chartOfAccountSearchContract, domain); ChartOfAccountContract contract; ModelMapper model = new ModelMapper(); List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); Pagination<ChartOfAccount> chartofaccounts = chartOfAccountService.search(domain, errors); for (ChartOfAccount chartOfAccount : chartofaccounts.getPagedData()) { contract = new ChartOfAccountContract(); model.map(chartOfAccount, contract); chartOfAccountContracts.add(contract); } ChartOfAccountResponse response = new ChartOfAccountResponse(); response.setChartOfAccounts(chartOfAccountContracts); response.setPage(new PaginationContract(chartofaccounts)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
ChartOfAccountController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public ChartOfAccountResponse search(@ModelAttribute ChartOfAccountSearchContract chartOfAccountSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); ChartOfAccountSearch domain = new ChartOfAccountSearch(); mapper.map(chartOfAccountSearchContract, domain); ChartOfAccountContract contract; ModelMapper model = new ModelMapper(); List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); Pagination<ChartOfAccount> chartofaccounts = chartOfAccountService.search(domain, errors); for (ChartOfAccount chartOfAccount : chartofaccounts.getPagedData()) { contract = new ChartOfAccountContract(); model.map(chartOfAccount, contract); chartOfAccountContracts.add(contract); } ChartOfAccountResponse response = new ChartOfAccountResponse(); response.setChartOfAccounts(chartOfAccountContracts); response.setPage(new PaginationContract(chartofaccounts)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
ChartOfAccountController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public ChartOfAccountResponse search(@ModelAttribute ChartOfAccountSearchContract chartOfAccountSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); ChartOfAccountSearch domain = new ChartOfAccountSearch(); mapper.map(chartOfAccountSearchContract, domain); ChartOfAccountContract contract; ModelMapper model = new ModelMapper(); List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); Pagination<ChartOfAccount> chartofaccounts = chartOfAccountService.search(domain, errors); for (ChartOfAccount chartOfAccount : chartofaccounts.getPagedData()) { contract = new ChartOfAccountContract(); model.map(chartOfAccount, contract); chartOfAccountContracts.add(contract); } ChartOfAccountResponse response = new ChartOfAccountResponse(); response.setChartOfAccounts(chartOfAccountContracts); response.setPage(new PaginationContract(chartofaccounts)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountResponse create(@RequestBody ChartOfAccountRequest chartOfAccountRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountResponse update(@RequestBody ChartOfAccountRequest chartOfAccountRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) ChartOfAccountResponse search(@ModelAttribute ChartOfAccountSearchContract chartOfAccountSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId); }
ChartOfAccountController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public ChartOfAccountResponse search(@ModelAttribute ChartOfAccountSearchContract chartOfAccountSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); ChartOfAccountSearch domain = new ChartOfAccountSearch(); mapper.map(chartOfAccountSearchContract, domain); ChartOfAccountContract contract; ModelMapper model = new ModelMapper(); List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); Pagination<ChartOfAccount> chartofaccounts = chartOfAccountService.search(domain, errors); for (ChartOfAccount chartOfAccount : chartofaccounts.getPagedData()) { contract = new ChartOfAccountContract(); model.map(chartOfAccount, contract); chartOfAccountContracts.add(contract); } ChartOfAccountResponse response = new ChartOfAccountResponse(); response.setChartOfAccounts(chartOfAccountContracts); response.setPage(new PaginationContract(chartofaccounts)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountResponse create(@RequestBody ChartOfAccountRequest chartOfAccountRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountResponse update(@RequestBody ChartOfAccountRequest chartOfAccountRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) ChartOfAccountResponse search(@ModelAttribute ChartOfAccountSearchContract chartOfAccountSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId);  }