@Test public void test_search() throws IOException, Exception { Pagination<AccountDetailKey> page = new Pagination<>(); page.setTotalPages(1); page.setTotalResults(1); page.setCurrentPage(0); page.setPagedData(getAccountDetailKies()); page.getPagedData().get(0).setId("1"); when(accountDetailKeyService.search(any(AccountDetailKeySearch.class), any(BindingResult.class))) .thenReturn(page); mockMvc.perform(post("/accountdetailkeys/_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("accountdetailkey/accountdetailkey_search_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailKeyResponse search( @ModelAttribute AccountDetailKeySearchContract accountDetailKeySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailKeySearch domain = new AccountDetailKeySearch(); mapper.map(accountDetailKeySearchContract, domain); AccountDetailKeyContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); Pagination<AccountDetailKey> accountdetailkeys = accountDetailKeyService.search(domain, errors); for (AccountDetailKey accountDetailKey : accountdetailkeys.getPagedData()) { contract = new AccountDetailKeyContract(); model.map(accountDetailKey, contract); accountDetailKeyContracts.add(contract); } AccountDetailKeyResponse response = new AccountDetailKeyResponse(); response.setAccountDetailKeys(accountDetailKeyContracts); response.setPage(new PaginationContract(accountdetailkeys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
AccountDetailKeyController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailKeyResponse search( @ModelAttribute AccountDetailKeySearchContract accountDetailKeySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailKeySearch domain = new AccountDetailKeySearch(); mapper.map(accountDetailKeySearchContract, domain); AccountDetailKeyContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); Pagination<AccountDetailKey> accountdetailkeys = accountDetailKeyService.search(domain, errors); for (AccountDetailKey accountDetailKey : accountdetailkeys.getPagedData()) { contract = new AccountDetailKeyContract(); model.map(accountDetailKey, contract); accountDetailKeyContracts.add(contract); } AccountDetailKeyResponse response = new AccountDetailKeyResponse(); response.setAccountDetailKeys(accountDetailKeyContracts); response.setPage(new PaginationContract(accountdetailkeys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
AccountDetailKeyController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailKeyResponse search( @ModelAttribute AccountDetailKeySearchContract accountDetailKeySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailKeySearch domain = new AccountDetailKeySearch(); mapper.map(accountDetailKeySearchContract, domain); AccountDetailKeyContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); Pagination<AccountDetailKey> accountdetailkeys = accountDetailKeyService.search(domain, errors); for (AccountDetailKey accountDetailKey : accountdetailkeys.getPagedData()) { contract = new AccountDetailKeyContract(); model.map(accountDetailKey, contract); accountDetailKeyContracts.add(contract); } AccountDetailKeyResponse response = new AccountDetailKeyResponse(); response.setAccountDetailKeys(accountDetailKeyContracts); response.setPage(new PaginationContract(accountdetailkeys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
AccountDetailKeyController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailKeyResponse search( @ModelAttribute AccountDetailKeySearchContract accountDetailKeySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailKeySearch domain = new AccountDetailKeySearch(); mapper.map(accountDetailKeySearchContract, domain); AccountDetailKeyContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); Pagination<AccountDetailKey> accountdetailkeys = accountDetailKeyService.search(domain, errors); for (AccountDetailKey accountDetailKey : accountdetailkeys.getPagedData()) { contract = new AccountDetailKeyContract(); model.map(accountDetailKey, contract); accountDetailKeyContracts.add(contract); } AccountDetailKeyResponse response = new AccountDetailKeyResponse(); response.setAccountDetailKeys(accountDetailKeyContracts); response.setPage(new PaginationContract(accountdetailkeys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountDetailKeyResponse create(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountDetailKeyResponse search(
			@ModelAttribute AccountDetailKeySearchContract accountDetailKeySearchContract, @RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId); }
AccountDetailKeyController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailKeyResponse search( @ModelAttribute AccountDetailKeySearchContract accountDetailKeySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailKeySearch domain = new AccountDetailKeySearch(); mapper.map(accountDetailKeySearchContract, domain); AccountDetailKeyContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); Pagination<AccountDetailKey> accountdetailkeys = accountDetailKeyService.search(domain, errors); for (AccountDetailKey accountDetailKey : accountdetailkeys.getPagedData()) { contract = new AccountDetailKeyContract(); model.map(accountDetailKey, contract); accountDetailKeyContracts.add(contract); } AccountDetailKeyResponse response = new AccountDetailKeyResponse(); response.setAccountDetailKeys(accountDetailKeyContracts); response.setPage(new PaginationContract(accountdetailkeys)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountDetailKeyResponse create(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountDetailKeyResponse search(
			@ModelAttribute AccountDetailKeySearchContract accountDetailKeySearchContract, @RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId);  }