@Test public void test_search() throws IOException, Exception { Pagination<AccountEntity> page = new Pagination<>(); page.setTotalPages(1); page.setTotalResults(1); page.setCurrentPage(0); page.setPagedData(getAccountEntities()); page.getPagedData().get(0).setId("1"); when(accountEntityService.search(any(AccountEntitySearch.class), any(BindingResult.class))).thenReturn(page); mockMvc.perform(post("/accountentities/_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("accountentity/accountentity_search_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountEntityResponse search(@ModelAttribute AccountEntitySearchContract accountEntitySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountEntitySearch domain = new AccountEntitySearch(); mapper.map(accountEntitySearchContract, domain); AccountEntityContract contract; ModelMapper model = new ModelMapper(); List<AccountEntityContract> accountEntityContracts = new ArrayList<>(); Pagination<AccountEntity> accountentities = accountEntityService.search(domain, errors); for (AccountEntity accountEntity : accountentities.getPagedData()) { contract = new AccountEntityContract(); model.map(accountEntity, contract); accountEntityContracts.add(contract); } AccountEntityResponse response = new AccountEntityResponse(); response.setAccountEntities(accountEntityContracts); response.setPage(new PaginationContract(accountentities)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
AccountEntityController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountEntityResponse search(@ModelAttribute AccountEntitySearchContract accountEntitySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountEntitySearch domain = new AccountEntitySearch(); mapper.map(accountEntitySearchContract, domain); AccountEntityContract contract; ModelMapper model = new ModelMapper(); List<AccountEntityContract> accountEntityContracts = new ArrayList<>(); Pagination<AccountEntity> accountentities = accountEntityService.search(domain, errors); for (AccountEntity accountEntity : accountentities.getPagedData()) { contract = new AccountEntityContract(); model.map(accountEntity, contract); accountEntityContracts.add(contract); } AccountEntityResponse response = new AccountEntityResponse(); response.setAccountEntities(accountEntityContracts); response.setPage(new PaginationContract(accountentities)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
AccountEntityController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountEntityResponse search(@ModelAttribute AccountEntitySearchContract accountEntitySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountEntitySearch domain = new AccountEntitySearch(); mapper.map(accountEntitySearchContract, domain); AccountEntityContract contract; ModelMapper model = new ModelMapper(); List<AccountEntityContract> accountEntityContracts = new ArrayList<>(); Pagination<AccountEntity> accountentities = accountEntityService.search(domain, errors); for (AccountEntity accountEntity : accountentities.getPagedData()) { contract = new AccountEntityContract(); model.map(accountEntity, contract); accountEntityContracts.add(contract); } AccountEntityResponse response = new AccountEntityResponse(); response.setAccountEntities(accountEntityContracts); response.setPage(new PaginationContract(accountentities)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
AccountEntityController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountEntityResponse search(@ModelAttribute AccountEntitySearchContract accountEntitySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountEntitySearch domain = new AccountEntitySearch(); mapper.map(accountEntitySearchContract, domain); AccountEntityContract contract; ModelMapper model = new ModelMapper(); List<AccountEntityContract> accountEntityContracts = new ArrayList<>(); Pagination<AccountEntity> accountentities = accountEntityService.search(domain, errors); for (AccountEntity accountEntity : accountentities.getPagedData()) { contract = new AccountEntityContract(); model.map(accountEntity, contract); accountEntityContracts.add(contract); } AccountEntityResponse response = new AccountEntityResponse(); response.setAccountEntities(accountEntityContracts); response.setPage(new PaginationContract(accountentities)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountEntityResponse create(@RequestBody AccountEntityRequest accountEntityRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountEntityResponse update(@RequestBody AccountEntityRequest accountEntityRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountEntityResponse search(@ModelAttribute AccountEntitySearchContract accountEntitySearchContract,
                                        @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId); }
AccountEntityController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountEntityResponse search(@ModelAttribute AccountEntitySearchContract accountEntitySearchContract, @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountEntitySearch domain = new AccountEntitySearch(); mapper.map(accountEntitySearchContract, domain); AccountEntityContract contract; ModelMapper model = new ModelMapper(); List<AccountEntityContract> accountEntityContracts = new ArrayList<>(); Pagination<AccountEntity> accountentities = accountEntityService.search(domain, errors); for (AccountEntity accountEntity : accountentities.getPagedData()) { contract = new AccountEntityContract(); model.map(accountEntity, contract); accountEntityContracts.add(contract); } AccountEntityResponse response = new AccountEntityResponse(); response.setAccountEntities(accountEntityContracts); response.setPage(new PaginationContract(accountentities)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountEntityResponse create(@RequestBody AccountEntityRequest accountEntityRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountEntityResponse update(@RequestBody AccountEntityRequest accountEntityRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountEntityResponse search(@ModelAttribute AccountEntitySearchContract accountEntitySearchContract,
                                        @RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId);  }