@Test public void testSearch() throws IOException, Exception { Pagination<BankBranch> page = new Pagination<>(); page.setTotalPages(1); page.setTotalResults(1); page.setCurrentPage(0); page.setOffset(0); page.setPageSize(0); page.setPagedData(getBankBranches()); page.getPagedData().get(0).setId("1"); when(bankBranchService.search(any(BankBranchSearch.class), any(BindingResult.class))).thenReturn(page); mockMvc.perform(post("/bankbranches/_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("bankbranch/bankbranch_search_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public BankBranchResponse search(@ModelAttribute BankBranchSearchContract bankBranchSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); BankBranchSearch domain = new BankBranchSearch(); mapper.map(bankBranchSearchContract, domain); BankBranchContract contract; ModelMapper model = new ModelMapper(); List<BankBranchContract> bankBranchContracts = new ArrayList<>(); Pagination<BankBranch> bankbranches = bankBranchService.search(domain, errors); for (BankBranch bankBranch : bankbranches.getPagedData()) { contract = new BankBranchContract(); model.map(bankBranch, contract); bankBranchContracts.add(contract); } BankBranchResponse response = new BankBranchResponse(); response.setBankBranches(bankBranchContracts); response.setPage(new PaginationContract(bankbranches)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
BankBranchController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public BankBranchResponse search(@ModelAttribute BankBranchSearchContract bankBranchSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); BankBranchSearch domain = new BankBranchSearch(); mapper.map(bankBranchSearchContract, domain); BankBranchContract contract; ModelMapper model = new ModelMapper(); List<BankBranchContract> bankBranchContracts = new ArrayList<>(); Pagination<BankBranch> bankbranches = bankBranchService.search(domain, errors); for (BankBranch bankBranch : bankbranches.getPagedData()) { contract = new BankBranchContract(); model.map(bankBranch, contract); bankBranchContracts.add(contract); } BankBranchResponse response = new BankBranchResponse(); response.setBankBranches(bankBranchContracts); response.setPage(new PaginationContract(bankbranches)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
BankBranchController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public BankBranchResponse search(@ModelAttribute BankBranchSearchContract bankBranchSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); BankBranchSearch domain = new BankBranchSearch(); mapper.map(bankBranchSearchContract, domain); BankBranchContract contract; ModelMapper model = new ModelMapper(); List<BankBranchContract> bankBranchContracts = new ArrayList<>(); Pagination<BankBranch> bankbranches = bankBranchService.search(domain, errors); for (BankBranch bankBranch : bankbranches.getPagedData()) { contract = new BankBranchContract(); model.map(bankBranch, contract); bankBranchContracts.add(contract); } BankBranchResponse response = new BankBranchResponse(); response.setBankBranches(bankBranchContracts); response.setPage(new PaginationContract(bankbranches)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
BankBranchController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public BankBranchResponse search(@ModelAttribute BankBranchSearchContract bankBranchSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); BankBranchSearch domain = new BankBranchSearch(); mapper.map(bankBranchSearchContract, domain); BankBranchContract contract; ModelMapper model = new ModelMapper(); List<BankBranchContract> bankBranchContracts = new ArrayList<>(); Pagination<BankBranch> bankbranches = bankBranchService.search(domain, errors); for (BankBranch bankBranch : bankbranches.getPagedData()) { contract = new BankBranchContract(); model.map(bankBranch, contract); bankBranchContracts.add(contract); } BankBranchResponse response = new BankBranchResponse(); response.setBankBranches(bankBranchContracts); response.setPage(new PaginationContract(bankbranches)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) BankBranchResponse create(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankBranchResponse search(@ModelAttribute BankBranchSearchContract bankBranchSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId); }
BankBranchController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public BankBranchResponse search(@ModelAttribute BankBranchSearchContract bankBranchSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); BankBranchSearch domain = new BankBranchSearch(); mapper.map(bankBranchSearchContract, domain); BankBranchContract contract; ModelMapper model = new ModelMapper(); List<BankBranchContract> bankBranchContracts = new ArrayList<>(); Pagination<BankBranch> bankbranches = bankBranchService.search(domain, errors); for (BankBranch bankBranch : bankbranches.getPagedData()) { contract = new BankBranchContract(); model.map(bankBranch, contract); bankBranchContracts.add(contract); } BankBranchResponse response = new BankBranchResponse(); response.setBankBranches(bankBranchContracts); response.setPage(new PaginationContract(bankbranches)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) BankBranchResponse create(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankBranchResponse search(@ModelAttribute BankBranchSearchContract bankBranchSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId);  }