@Test public void test_search() throws IOException, Exception { Pagination<AccountCodePurpose> page = new Pagination<>(); page.setTotalPages(1); page.setTotalResults(1); page.setCurrentPage(0); page.setPagedData(getAccountCodePurposes()); page.getPagedData().get(0).setId("1"); when(accountCodePurposeService.search(any(AccountCodePurposeSearch.class), any(BindingResult.class))) .thenReturn(page); mockMvc.perform(post("/accountcodepurposes/_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("accountcodepurpose/accountcodepurpose_search_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeResponse search( @ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountCodePurposeSearch domain = new AccountCodePurposeSearch(); mapper.map(accountCodePurposeSearchContract, domain); AccountCodePurposeContract contract; ModelMapper model = new ModelMapper(); List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); Pagination<AccountCodePurpose> accountcodepurposes = accountCodePurposeService.search(domain, errors); for (AccountCodePurpose accountCodePurpose : accountcodepurposes.getPagedData()) { contract = new AccountCodePurposeContract(); model.map(accountCodePurpose, contract); accountCodePurposeContracts.add(contract); } AccountCodePurposeResponse response = new AccountCodePurposeResponse(); response.setAccountCodePurposes(accountCodePurposeContracts); response.setPage(new PaginationContract(accountcodepurposes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
AccountCodePurposeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeResponse search( @ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountCodePurposeSearch domain = new AccountCodePurposeSearch(); mapper.map(accountCodePurposeSearchContract, domain); AccountCodePurposeContract contract; ModelMapper model = new ModelMapper(); List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); Pagination<AccountCodePurpose> accountcodepurposes = accountCodePurposeService.search(domain, errors); for (AccountCodePurpose accountCodePurpose : accountcodepurposes.getPagedData()) { contract = new AccountCodePurposeContract(); model.map(accountCodePurpose, contract); accountCodePurposeContracts.add(contract); } AccountCodePurposeResponse response = new AccountCodePurposeResponse(); response.setAccountCodePurposes(accountCodePurposeContracts); response.setPage(new PaginationContract(accountcodepurposes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
AccountCodePurposeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeResponse search( @ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountCodePurposeSearch domain = new AccountCodePurposeSearch(); mapper.map(accountCodePurposeSearchContract, domain); AccountCodePurposeContract contract; ModelMapper model = new ModelMapper(); List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); Pagination<AccountCodePurpose> accountcodepurposes = accountCodePurposeService.search(domain, errors); for (AccountCodePurpose accountCodePurpose : accountcodepurposes.getPagedData()) { contract = new AccountCodePurposeContract(); model.map(accountCodePurpose, contract); accountCodePurposeContracts.add(contract); } AccountCodePurposeResponse response = new AccountCodePurposeResponse(); response.setAccountCodePurposes(accountCodePurposeContracts); response.setPage(new PaginationContract(accountcodepurposes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
AccountCodePurposeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeResponse search( @ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountCodePurposeSearch domain = new AccountCodePurposeSearch(); mapper.map(accountCodePurposeSearchContract, domain); AccountCodePurposeContract contract; ModelMapper model = new ModelMapper(); List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); Pagination<AccountCodePurpose> accountcodepurposes = accountCodePurposeService.search(domain, errors); for (AccountCodePurpose accountCodePurpose : accountcodepurposes.getPagedData()) { contract = new AccountCodePurposeContract(); model.map(accountCodePurpose, contract); accountCodePurposeContracts.add(contract); } AccountCodePurposeResponse response = new AccountCodePurposeResponse(); response.setAccountCodePurposes(accountCodePurposeContracts); response.setPage(new PaginationContract(accountcodepurposes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountCodePurposeResponse create(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountCodePurposeResponse update(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountCodePurposeResponse search(
			@ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId); }
AccountCodePurposeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeResponse search( @ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountCodePurposeSearch domain = new AccountCodePurposeSearch(); mapper.map(accountCodePurposeSearchContract, domain); AccountCodePurposeContract contract; ModelMapper model = new ModelMapper(); List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); Pagination<AccountCodePurpose> accountcodepurposes = accountCodePurposeService.search(domain, errors); for (AccountCodePurpose accountCodePurpose : accountcodepurposes.getPagedData()) { contract = new AccountCodePurposeContract(); model.map(accountCodePurpose, contract); accountCodePurposeContracts.add(contract); } AccountCodePurposeResponse response = new AccountCodePurposeResponse(); response.setAccountCodePurposes(accountCodePurposeContracts); response.setPage(new PaginationContract(accountcodepurposes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountCodePurposeResponse create(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountCodePurposeResponse update(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountCodePurposeResponse search(
			@ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId);  }