@Test public void test_search() throws IOException, Exception { Pagination<InstrumentType> page = new Pagination<>(); page.setTotalPages(1); page.setTotalResults(1); page.setCurrentPage(0); page.setPagedData(getInstrumentTypes()); page.getPagedData().get(0).setId("1"); when(instrumentTypeService.search(any(InstrumentTypeSearch.class))).thenReturn(page); mockMvc.perform(post("/instrumenttypes/_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("instrumenttype/instrumenttype_search_valid_response.json"))); }
@PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public InstrumentTypeResponse search(@ModelAttribute InstrumentTypeSearchContract instrumentTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); InstrumentTypeSearch domain = mapper.toSearchDomain(instrumentTypeSearchContract); InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); Pagination<InstrumentType> instrumenttypes = instrumentTypeService.search(domain); if (instrumenttypes.getPagedData() != null) for (InstrumentType instrumentType : instrumenttypes.getPagedData()) { contract = mapper.toContract(instrumentType); instrumentTypeContracts.add(contract); } InstrumentTypeResponse response = new InstrumentTypeResponse(); response.setInstrumentTypes(instrumentTypeContracts); response.setPage(new PaginationContract(instrumenttypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }
InstrumentTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public InstrumentTypeResponse search(@ModelAttribute InstrumentTypeSearchContract instrumentTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); InstrumentTypeSearch domain = mapper.toSearchDomain(instrumentTypeSearchContract); InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); Pagination<InstrumentType> instrumenttypes = instrumentTypeService.search(domain); if (instrumenttypes.getPagedData() != null) for (InstrumentType instrumentType : instrumenttypes.getPagedData()) { contract = mapper.toContract(instrumentType); instrumentTypeContracts.add(contract); } InstrumentTypeResponse response = new InstrumentTypeResponse(); response.setInstrumentTypes(instrumentTypeContracts); response.setPage(new PaginationContract(instrumenttypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; } }
InstrumentTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public InstrumentTypeResponse search(@ModelAttribute InstrumentTypeSearchContract instrumentTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); InstrumentTypeSearch domain = mapper.toSearchDomain(instrumentTypeSearchContract); InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); Pagination<InstrumentType> instrumenttypes = instrumentTypeService.search(domain); if (instrumenttypes.getPagedData() != null) for (InstrumentType instrumentType : instrumenttypes.getPagedData()) { contract = mapper.toContract(instrumentType); instrumentTypeContracts.add(contract); } InstrumentTypeResponse response = new InstrumentTypeResponse(); response.setInstrumentTypes(instrumentTypeContracts); response.setPage(new PaginationContract(instrumenttypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  }
InstrumentTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public InstrumentTypeResponse search(@ModelAttribute InstrumentTypeSearchContract instrumentTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); InstrumentTypeSearch domain = mapper.toSearchDomain(instrumentTypeSearchContract); InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); Pagination<InstrumentType> instrumenttypes = instrumentTypeService.search(domain); if (instrumenttypes.getPagedData() != null) for (InstrumentType instrumentType : instrumenttypes.getPagedData()) { contract = mapper.toContract(instrumentType); instrumentTypeContracts.add(contract); } InstrumentTypeResponse response = new InstrumentTypeResponse(); response.setInstrumentTypes(instrumentTypeContracts); response.setPage(new PaginationContract(instrumenttypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse create(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse update(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse delete(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) InstrumentTypeResponse search(@ModelAttribute InstrumentTypeSearchContract instrumentTypeSearchContract,
            RequestInfo requestInfo, BindingResult errors); }
InstrumentTypeController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public InstrumentTypeResponse search(@ModelAttribute InstrumentTypeSearchContract instrumentTypeSearchContract, RequestInfo requestInfo, BindingResult errors) { InstrumentTypeMapper mapper = new InstrumentTypeMapper(); InstrumentTypeSearch domain = mapper.toSearchDomain(instrumentTypeSearchContract); InstrumentTypeContract contract; List<InstrumentTypeContract> instrumentTypeContracts = new ArrayList<>(); Pagination<InstrumentType> instrumenttypes = instrumentTypeService.search(domain); if (instrumenttypes.getPagedData() != null) for (InstrumentType instrumentType : instrumenttypes.getPagedData()) { contract = mapper.toContract(instrumentType); instrumentTypeContracts.add(contract); } InstrumentTypeResponse response = new InstrumentTypeResponse(); response.setInstrumentTypes(instrumentTypeContracts); response.setPage(new PaginationContract(instrumenttypes)); response.setResponseInfo(getResponseInfo(requestInfo)); return response; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse create(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse update(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_delete") @ResponseStatus(HttpStatus.CREATED) InstrumentTypeResponse delete(@RequestBody InstrumentTypeRequest instrumentTypeRequest,
            BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) InstrumentTypeResponse search(@ModelAttribute InstrumentTypeSearchContract instrumentTypeSearchContract,
            RequestInfo requestInfo, BindingResult errors); static final String ACTION_CREATE; static final String ACTION_UPDATE; static final String ACTION_DELETE; static final String PLACEHOLDER; }