@Test public void test_search() throws IOException, Exception { Pagination<SurrenderReason> page = new Pagination<>(); page.setTotalPages(1); page.setTotalResults(1); page.setCurrentPage(0); page.setPagedData(getSurrenderReasons()); page.getPagedData().get(0).setId("1"); when(surrenderReasonService.search(any(SurrenderReasonSearch.class))).thenReturn(page); mockMvc.perform(post("/surrenderreasons/_search").content(resources.getRequestInfo()) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(200)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(content() .json(resources.readResponse("surrenderreason/surrenderreason_search_valid_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public SurrenderReasonResponse search(@ModelAttribute SurrenderReasonSearchContract surrenderReasonSearchContract, RequestInfo requestInfo, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearch domain = mapper.toSearchDomain(surrenderReasonSearchContract); SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); Pagination<SurrenderReason> surrenderreasons = surrenderReasonService.search(domain); if (surrenderreasons.getPagedData() != null) for (SurrenderReason surrenderReason : surrenderreasons.getPagedData()) { contract = mapper.toContract(surrenderReason); surrenderReasonContracts.add(contract); } SurrenderReasonResponse response = new SurrenderReasonResponse(); response.setSurrenderReasons(surrenderReasonContracts); response.setPage(new PaginationContract(surrenderreasons)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
SurrenderReasonController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public SurrenderReasonResponse search(@ModelAttribute SurrenderReasonSearchContract surrenderReasonSearchContract, RequestInfo requestInfo, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearch domain = mapper.toSearchDomain(surrenderReasonSearchContract); SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); Pagination<SurrenderReason> surrenderreasons = surrenderReasonService.search(domain); if (surrenderreasons.getPagedData() != null) for (SurrenderReason surrenderReason : surrenderreasons.getPagedData()) { contract = mapper.toContract(surrenderReason); surrenderReasonContracts.add(contract); } SurrenderReasonResponse response = new SurrenderReasonResponse(); response.setSurrenderReasons(surrenderReasonContracts); response.setPage(new PaginationContract(surrenderreasons)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
SurrenderReasonController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public SurrenderReasonResponse search(@ModelAttribute SurrenderReasonSearchContract surrenderReasonSearchContract, RequestInfo requestInfo, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearch domain = mapper.toSearchDomain(surrenderReasonSearchContract); SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); Pagination<SurrenderReason> surrenderreasons = surrenderReasonService.search(domain); if (surrenderreasons.getPagedData() != null) for (SurrenderReason surrenderReason : surrenderreasons.getPagedData()) { contract = mapper.toContract(surrenderReason); surrenderReasonContracts.add(contract); } SurrenderReasonResponse response = new SurrenderReasonResponse(); response.setSurrenderReasons(surrenderReasonContracts); response.setPage(new PaginationContract(surrenderreasons)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
SurrenderReasonController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public SurrenderReasonResponse search(@ModelAttribute SurrenderReasonSearchContract surrenderReasonSearchContract, RequestInfo requestInfo, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearch domain = mapper.toSearchDomain(surrenderReasonSearchContract); SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); Pagination<SurrenderReason> surrenderreasons = surrenderReasonService.search(domain); if (surrenderreasons.getPagedData() != null) for (SurrenderReason surrenderReason : surrenderreasons.getPagedData()) { contract = mapper.toContract(surrenderReason); surrenderReasonContracts.add(contract); } SurrenderReasonResponse response = new SurrenderReasonResponse(); response.setSurrenderReasons(surrenderReasonContracts); response.setPage(new PaginationContract(surrenderreasons)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse create(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse update(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse delete(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) SurrenderReasonResponse search(@ModelAttribute SurrenderReasonSearchContract surrenderReasonSearchContract,
            RequestInfo requestInfo, BindingResult errors); }
SurrenderReasonController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public SurrenderReasonResponse search(@ModelAttribute SurrenderReasonSearchContract surrenderReasonSearchContract, RequestInfo requestInfo, BindingResult errors) { SurrenderReasonMapper mapper = new SurrenderReasonMapper(); SurrenderReasonSearch domain = mapper.toSearchDomain(surrenderReasonSearchContract); SurrenderReasonContract contract; List<SurrenderReasonContract> surrenderReasonContracts = new ArrayList<>(); Pagination<SurrenderReason> surrenderreasons = surrenderReasonService.search(domain); if (surrenderreasons.getPagedData() != null) for (SurrenderReason surrenderReason : surrenderreasons.getPagedData()) { contract = mapper.toContract(surrenderReason); surrenderReasonContracts.add(contract); } SurrenderReasonResponse response = new SurrenderReasonResponse(); response.setSurrenderReasons(surrenderReasonContracts); response.setPage(new PaginationContract(surrenderreasons)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse create(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse update(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) SurrenderReasonResponse delete(@RequestBody SurrenderReasonRequest surrenderReasonRequest,
            BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) SurrenderReasonResponse search(@ModelAttribute SurrenderReasonSearchContract surrenderReasonSearchContract,
            RequestInfo requestInfo, BindingResult errors); static final String ACTION_CREATE; static final String ACTION_UPDATE; static final String ACTION_DELETE; static final String PLACEHOLDER; }