@Test public void test_Should_Search_AssetCategory() throws Exception { final List<AssetCategory> assetCategories = new ArrayList<>(); assetCategories.add(getAssetCategory()); when(assetCategoryService.search(any(AssetCategoryCriteria.class))).thenReturn(assetCategories); mockMvc.perform(post("/assetCategories/_search").param("tenantId", "ap.kurnool") .contentType(MediaType.APPLICATION_JSON).content(getFileContents("requestinfowrapper.json"))) .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(content().json(getFileContents("assetcategorysearchresponse.json"))); }
@PostMapping("/_search") @ResponseBody public ResponseEntity<?> search(@RequestBody final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCategoryCriteria assetCategoryCriteria, final BindingResult bindingResult) { if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } final List<AssetCategory> assetCategories = assetCategoryService.search(assetCategoryCriteria); if(!assetCategories.isEmpty() && UPDATE.equalsIgnoreCase(assetCategoryCriteria.getAction())) assetCategoryValidator.getAssetExistInAgreements( assetCategories,requestInfoWrapper.getRequestInfo()); final AssetCategoryResponse response = new AssetCategoryResponse(); response.setAssetCategory(assetCategories); response.setResponseInfo(new ResponseInfo()); return new ResponseEntity<>(response, HttpStatus.OK); }
AssetCategoryController { @PostMapping("/_search") @ResponseBody public ResponseEntity<?> search(@RequestBody final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCategoryCriteria assetCategoryCriteria, final BindingResult bindingResult) { if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } final List<AssetCategory> assetCategories = assetCategoryService.search(assetCategoryCriteria); if(!assetCategories.isEmpty() && UPDATE.equalsIgnoreCase(assetCategoryCriteria.getAction())) assetCategoryValidator.getAssetExistInAgreements( assetCategories,requestInfoWrapper.getRequestInfo()); final AssetCategoryResponse response = new AssetCategoryResponse(); response.setAssetCategory(assetCategories); response.setResponseInfo(new ResponseInfo()); return new ResponseEntity<>(response, HttpStatus.OK); } }
AssetCategoryController { @PostMapping("/_search") @ResponseBody public ResponseEntity<?> search(@RequestBody final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCategoryCriteria assetCategoryCriteria, final BindingResult bindingResult) { if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } final List<AssetCategory> assetCategories = assetCategoryService.search(assetCategoryCriteria); if(!assetCategories.isEmpty() && UPDATE.equalsIgnoreCase(assetCategoryCriteria.getAction())) assetCategoryValidator.getAssetExistInAgreements( assetCategories,requestInfoWrapper.getRequestInfo()); final AssetCategoryResponse response = new AssetCategoryResponse(); response.setAssetCategory(assetCategories); response.setResponseInfo(new ResponseInfo()); return new ResponseEntity<>(response, HttpStatus.OK); }  }
AssetCategoryController { @PostMapping("/_search") @ResponseBody public ResponseEntity<?> search(@RequestBody final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCategoryCriteria assetCategoryCriteria, final BindingResult bindingResult) { if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } final List<AssetCategory> assetCategories = assetCategoryService.search(assetCategoryCriteria); if(!assetCategories.isEmpty() && UPDATE.equalsIgnoreCase(assetCategoryCriteria.getAction())) assetCategoryValidator.getAssetExistInAgreements( assetCategories,requestInfoWrapper.getRequestInfo()); final AssetCategoryResponse response = new AssetCategoryResponse(); response.setAssetCategory(assetCategories); response.setResponseInfo(new ResponseInfo()); return new ResponseEntity<>(response, HttpStatus.OK); }  @PostMapping("/_search") @ResponseBody ResponseEntity<?> search(@RequestBody final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final AssetCategoryCriteria assetCategoryCriteria,
            final BindingResult bindingResult); @PostMapping("/_create") @ResponseBody ResponseEntity<?> create(@RequestBody @Valid final AssetCategoryRequest assetCategoryRequest,
            final BindingResult bindingResult); @PostMapping("/_update") ResponseEntity<?> update(@RequestBody @Valid AssetCategoryRequest assetCategoryRequest,
            BindingResult bindingResult); }
AssetCategoryController { @PostMapping("/_search") @ResponseBody public ResponseEntity<?> search(@RequestBody final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCategoryCriteria assetCategoryCriteria, final BindingResult bindingResult) { if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } final List<AssetCategory> assetCategories = assetCategoryService.search(assetCategoryCriteria); if(!assetCategories.isEmpty() && UPDATE.equalsIgnoreCase(assetCategoryCriteria.getAction())) assetCategoryValidator.getAssetExistInAgreements( assetCategories,requestInfoWrapper.getRequestInfo()); final AssetCategoryResponse response = new AssetCategoryResponse(); response.setAssetCategory(assetCategories); response.setResponseInfo(new ResponseInfo()); return new ResponseEntity<>(response, HttpStatus.OK); }  @PostMapping("/_search") @ResponseBody ResponseEntity<?> search(@RequestBody final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final AssetCategoryCriteria assetCategoryCriteria,
            final BindingResult bindingResult); @PostMapping("/_create") @ResponseBody ResponseEntity<?> create(@RequestBody @Valid final AssetCategoryRequest assetCategoryRequest,
            final BindingResult bindingResult); @PostMapping("/_update") ResponseEntity<?> update(@RequestBody @Valid AssetCategoryRequest assetCategoryRequest,
            BindingResult bindingResult); static final String UPDATE; }