@Test public void test_search() throws IOException, Exception { Pagination<AccountDetailType> page = new Pagination<>(); page.setTotalPages(1); page.setTotalResults(1); page.setCurrentPage(0); page.setPagedData(getAccountDetailTypes()); page.getPagedData().get(0).setId("1"); when(accountDetailTypeService.search(any(AccountDetailTypeSearch.class), any(BindingResult.class))) .thenReturn(page); mockMvc.perform(post("/accountdetailtypes/_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("accountdetailtype/accountdetailtype_search_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailTypeResponse search( @ModelAttribute AccountDetailTypeSearchContract accountDetailTypeSearchContract,@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeSearch domain = new AccountDetailTypeSearch(); mapper.map(accountDetailTypeSearchContract, domain); AccountDetailTypeContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); Pagination<AccountDetailType> accountdetailtypes = accountDetailTypeService.search(domain, errors); for (AccountDetailType accountDetailType : accountdetailtypes.getPagedData()) { contract = new AccountDetailTypeContract(); model.map(accountDetailType, contract); accountDetailTypeContracts.add(contract); } AccountDetailTypeResponse response = new AccountDetailTypeResponse(); response.setAccountDetailTypes(accountDetailTypeContracts); response.setPage(new PaginationContract(accountdetailtypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
AccountDetailTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailTypeResponse search( @ModelAttribute AccountDetailTypeSearchContract accountDetailTypeSearchContract,@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeSearch domain = new AccountDetailTypeSearch(); mapper.map(accountDetailTypeSearchContract, domain); AccountDetailTypeContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); Pagination<AccountDetailType> accountdetailtypes = accountDetailTypeService.search(domain, errors); for (AccountDetailType accountDetailType : accountdetailtypes.getPagedData()) { contract = new AccountDetailTypeContract(); model.map(accountDetailType, contract); accountDetailTypeContracts.add(contract); } AccountDetailTypeResponse response = new AccountDetailTypeResponse(); response.setAccountDetailTypes(accountDetailTypeContracts); response.setPage(new PaginationContract(accountdetailtypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
AccountDetailTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailTypeResponse search( @ModelAttribute AccountDetailTypeSearchContract accountDetailTypeSearchContract,@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeSearch domain = new AccountDetailTypeSearch(); mapper.map(accountDetailTypeSearchContract, domain); AccountDetailTypeContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); Pagination<AccountDetailType> accountdetailtypes = accountDetailTypeService.search(domain, errors); for (AccountDetailType accountDetailType : accountdetailtypes.getPagedData()) { contract = new AccountDetailTypeContract(); model.map(accountDetailType, contract); accountDetailTypeContracts.add(contract); } AccountDetailTypeResponse response = new AccountDetailTypeResponse(); response.setAccountDetailTypes(accountDetailTypeContracts); response.setPage(new PaginationContract(accountdetailtypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
AccountDetailTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailTypeResponse search( @ModelAttribute AccountDetailTypeSearchContract accountDetailTypeSearchContract,@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeSearch domain = new AccountDetailTypeSearch(); mapper.map(accountDetailTypeSearchContract, domain); AccountDetailTypeContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); Pagination<AccountDetailType> accountdetailtypes = accountDetailTypeService.search(domain, errors); for (AccountDetailType accountDetailType : accountdetailtypes.getPagedData()) { contract = new AccountDetailTypeContract(); model.map(accountDetailType, contract); accountDetailTypeContracts.add(contract); } AccountDetailTypeResponse response = new AccountDetailTypeResponse(); response.setAccountDetailTypes(accountDetailTypeContracts); response.setPage(new PaginationContract(accountdetailtypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountDetailTypeResponse create(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountDetailTypeResponse update(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountDetailTypeResponse search(
			@ModelAttribute AccountDetailTypeSearchContract accountDetailTypeSearchContract,@RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId); }
AccountDetailTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountDetailTypeResponse search( @ModelAttribute AccountDetailTypeSearchContract accountDetailTypeSearchContract,@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId) { ModelMapper mapper = new ModelMapper(); AccountDetailTypeSearch domain = new AccountDetailTypeSearch(); mapper.map(accountDetailTypeSearchContract, domain); AccountDetailTypeContract contract; ModelMapper model = new ModelMapper(); List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); Pagination<AccountDetailType> accountdetailtypes = accountDetailTypeService.search(domain, errors); for (AccountDetailType accountDetailType : accountdetailtypes.getPagedData()) { contract = new AccountDetailTypeContract(); model.map(accountDetailType, contract); accountDetailTypeContracts.add(contract); } AccountDetailTypeResponse response = new AccountDetailTypeResponse(); response.setAccountDetailTypes(accountDetailTypeContracts); response.setPage(new PaginationContract(accountdetailtypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountDetailTypeResponse create(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountDetailTypeResponse update(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountDetailTypeResponse search(
			@ModelAttribute AccountDetailTypeSearchContract accountDetailTypeSearchContract,@RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId);  }