@Test public void test_search() throws IOException, Exception { Pagination<VoucherSubType> page = new Pagination<>(); page.setTotalPages(1); page.setTotalResults(1); page.setCurrentPage(0); page.setPagedData(getVoucherSubTypes()); page.getPagedData().get(0).setId("1"); when(voucherSubTypeService.search(any(VoucherSubTypeSearch.class))).thenReturn(page); mockMvc.perform(post("/vouchersubtype/_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("vouchersubtype/vouchersubtype_search_valid_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeSearch domain = new VoucherSubTypeSearch(); mapper.map(voucherSubTypeSearchContract, domain); VoucherSubTypeContract contract; ModelMapper model = new ModelMapper(); List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); Pagination<VoucherSubType> voucherSubTypes = voucherSubTypeService.search(domain); if (voucherSubTypes.getPagedData() != null) { for (VoucherSubType voucherSubType : voucherSubTypes.getPagedData()) { contract = new VoucherSubTypeContract(); model.map(voucherSubType, contract); voucherSubTypeContracts.add(contract); } } VoucherSubTypeResponse response = new VoucherSubTypeResponse(); response.setVoucherSubTypes(voucherSubTypeContracts); response.setPage(new PaginationContract(voucherSubTypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
VoucherSubTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeSearch domain = new VoucherSubTypeSearch(); mapper.map(voucherSubTypeSearchContract, domain); VoucherSubTypeContract contract; ModelMapper model = new ModelMapper(); List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); Pagination<VoucherSubType> voucherSubTypes = voucherSubTypeService.search(domain); if (voucherSubTypes.getPagedData() != null) { for (VoucherSubType voucherSubType : voucherSubTypes.getPagedData()) { contract = new VoucherSubTypeContract(); model.map(voucherSubType, contract); voucherSubTypeContracts.add(contract); } } VoucherSubTypeResponse response = new VoucherSubTypeResponse(); response.setVoucherSubTypes(voucherSubTypeContracts); response.setPage(new PaginationContract(voucherSubTypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
VoucherSubTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeSearch domain = new VoucherSubTypeSearch(); mapper.map(voucherSubTypeSearchContract, domain); VoucherSubTypeContract contract; ModelMapper model = new ModelMapper(); List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); Pagination<VoucherSubType> voucherSubTypes = voucherSubTypeService.search(domain); if (voucherSubTypes.getPagedData() != null) { for (VoucherSubType voucherSubType : voucherSubTypes.getPagedData()) { contract = new VoucherSubTypeContract(); model.map(voucherSubType, contract); voucherSubTypeContracts.add(contract); } } VoucherSubTypeResponse response = new VoucherSubTypeResponse(); response.setVoucherSubTypes(voucherSubTypeContracts); response.setPage(new PaginationContract(voucherSubTypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
VoucherSubTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeSearch domain = new VoucherSubTypeSearch(); mapper.map(voucherSubTypeSearchContract, domain); VoucherSubTypeContract contract; ModelMapper model = new ModelMapper(); List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); Pagination<VoucherSubType> voucherSubTypes = voucherSubTypeService.search(domain); if (voucherSubTypes.getPagedData() != null) { for (VoucherSubType voucherSubType : voucherSubTypes.getPagedData()) { contract = new VoucherSubTypeContract(); model.map(voucherSubType, contract); voucherSubTypeContracts.add(contract); } } VoucherSubTypeResponse response = new VoucherSubTypeResponse(); response.setVoucherSubTypes(voucherSubTypeContracts); response.setPage(new PaginationContract(voucherSubTypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse create(
            @RequestBody VoucherSubTypeRequest voucherSubTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract,
            RequestInfo requestInfo,
            BindingResult errors); }
VoucherSubTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { ModelMapper mapper = new ModelMapper(); VoucherSubTypeSearch domain = new VoucherSubTypeSearch(); mapper.map(voucherSubTypeSearchContract, domain); VoucherSubTypeContract contract; ModelMapper model = new ModelMapper(); List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); Pagination<VoucherSubType> voucherSubTypes = voucherSubTypeService.search(domain); if (voucherSubTypes.getPagedData() != null) { for (VoucherSubType voucherSubType : voucherSubTypes.getPagedData()) { contract = new VoucherSubTypeContract(); model.map(voucherSubType, contract); voucherSubTypeContracts.add(contract); } } VoucherSubTypeResponse response = new VoucherSubTypeResponse(); response.setVoucherSubTypes(voucherSubTypeContracts); response.setPage(new PaginationContract(voucherSubTypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse create(
            @RequestBody VoucherSubTypeRequest voucherSubTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract,
            RequestInfo requestInfo,
            BindingResult errors);  }