@Test public void test_should_search_disposal() throws IOException, Exception { final List<Disposal> disposal = new ArrayList<>(); disposal.add(getDisposals()); final ResponseInfo resInfo = new ResponseInfo(); when(disposalService.search(any(DisposalCriteria.class), any(RequestInfo.class))).thenReturn(disposal); when(responseInfoFactory.createResponseInfoFromRequestHeaders(any(RequestInfo.class))).thenReturn(resInfo); mockMvc.perform(post("/assets/dispose/_search").contentType(MediaType.APPLICATION_JSON) .param("tenantId", "ap.kurnool").content(getFileContents("requestinfowrapper.json"))) .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) .andExpect(content().json(getFileContents("disposal/disposesearchresponse.json"))); }
@PostMapping("_search") @ResponseBody public ResponseEntity<?> search(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCriteria assetCriteria, final BindingResult bindingResult) { log.debug("assetCriteria::" + assetCriteria + "requestInfoWrapper::" + requestInfoWrapper); if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } if (assetCriteria.getTransaction() != null) if (assetCriteria.getTransaction().toString().equals(TransactionType.DEPRECIATION.toString())) { final List<ErrorResponse> errorResponses = assetValidator.validateSearchAssetDepreciation(assetCriteria); if (!errorResponses.isEmpty()) return new ResponseEntity<>(errorResponses, HttpStatus.BAD_REQUEST); } if (assetCriteria.getGrossValue() != null && assetCriteria.getFromCapitalizedValue() != null && assetCriteria.getToCapitalizedValue() != null) throw new RuntimeException( "Gross Value should not be present with from capitalized value and to capitalized value"); final List<Asset> assets = assetService.getAssets(assetCriteria, requestInfoWrapper.getRequestInfo()); return getAssetResponse(assets, requestInfoWrapper.getRequestInfo()); }
AssetController { @PostMapping("_search") @ResponseBody public ResponseEntity<?> search(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCriteria assetCriteria, final BindingResult bindingResult) { log.debug("assetCriteria::" + assetCriteria + "requestInfoWrapper::" + requestInfoWrapper); if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } if (assetCriteria.getTransaction() != null) if (assetCriteria.getTransaction().toString().equals(TransactionType.DEPRECIATION.toString())) { final List<ErrorResponse> errorResponses = assetValidator.validateSearchAssetDepreciation(assetCriteria); if (!errorResponses.isEmpty()) return new ResponseEntity<>(errorResponses, HttpStatus.BAD_REQUEST); } if (assetCriteria.getGrossValue() != null && assetCriteria.getFromCapitalizedValue() != null && assetCriteria.getToCapitalizedValue() != null) throw new RuntimeException( "Gross Value should not be present with from capitalized value and to capitalized value"); final List<Asset> assets = assetService.getAssets(assetCriteria, requestInfoWrapper.getRequestInfo()); return getAssetResponse(assets, requestInfoWrapper.getRequestInfo()); } }
AssetController { @PostMapping("_search") @ResponseBody public ResponseEntity<?> search(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCriteria assetCriteria, final BindingResult bindingResult) { log.debug("assetCriteria::" + assetCriteria + "requestInfoWrapper::" + requestInfoWrapper); if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } if (assetCriteria.getTransaction() != null) if (assetCriteria.getTransaction().toString().equals(TransactionType.DEPRECIATION.toString())) { final List<ErrorResponse> errorResponses = assetValidator.validateSearchAssetDepreciation(assetCriteria); if (!errorResponses.isEmpty()) return new ResponseEntity<>(errorResponses, HttpStatus.BAD_REQUEST); } if (assetCriteria.getGrossValue() != null && assetCriteria.getFromCapitalizedValue() != null && assetCriteria.getToCapitalizedValue() != null) throw new RuntimeException( "Gross Value should not be present with from capitalized value and to capitalized value"); final List<Asset> assets = assetService.getAssets(assetCriteria, requestInfoWrapper.getRequestInfo()); return getAssetResponse(assets, requestInfoWrapper.getRequestInfo()); }  }
AssetController { @PostMapping("_search") @ResponseBody public ResponseEntity<?> search(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCriteria assetCriteria, final BindingResult bindingResult) { log.debug("assetCriteria::" + assetCriteria + "requestInfoWrapper::" + requestInfoWrapper); if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } if (assetCriteria.getTransaction() != null) if (assetCriteria.getTransaction().toString().equals(TransactionType.DEPRECIATION.toString())) { final List<ErrorResponse> errorResponses = assetValidator.validateSearchAssetDepreciation(assetCriteria); if (!errorResponses.isEmpty()) return new ResponseEntity<>(errorResponses, HttpStatus.BAD_REQUEST); } if (assetCriteria.getGrossValue() != null && assetCriteria.getFromCapitalizedValue() != null && assetCriteria.getToCapitalizedValue() != null) throw new RuntimeException( "Gross Value should not be present with from capitalized value and to capitalized value"); final List<Asset> assets = assetService.getAssets(assetCriteria, requestInfoWrapper.getRequestInfo()); return getAssetResponse(assets, requestInfoWrapper.getRequestInfo()); }  @PostMapping("_search") @ResponseBody ResponseEntity<?> search(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final AssetCriteria assetCriteria, final BindingResult bindingResult); @PostMapping("_paginatedsearch") @ResponseBody ResponseEntity<?> paginatedSearch(@ModelAttribute @Valid final AssetCriteria assetCriteria,
            @RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            final BindingResult bindingResult); @PostMapping("_create") @ResponseBody ResponseEntity<?> create(@RequestBody @Valid final AssetRequest assetRequest,
            final BindingResult bindingResult); @PostMapping("_update") @ResponseBody ResponseEntity<?> update(@RequestBody final AssetRequest assetRequest, final BindingResult bindingResult); @PostMapping("revaluation/_create") @ResponseBody ResponseEntity<?> revaluate(@RequestBody @Valid final RevaluationRequest revaluationRequest,
            final BindingResult bindingResult, @RequestHeader final HttpHeaders headers); @PostMapping("revaluation/_search") @ResponseBody ResponseEntity<?> revaluateSearch(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final RevaluationCriteria revaluationCriteria, final BindingResult bindingResult); @PostMapping("dispose/_create") @ResponseBody ResponseEntity<?> dispose(@RequestBody @Valid final DisposalRequest disposalRequest,
            final BindingResult bindingResult, @RequestHeader final HttpHeaders headers); @PostMapping("dispose/_search") @ResponseBody ResponseEntity<?> disposalSearch(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final DisposalCriteria disposalCriteria, final BindingResult bindingResult); @PostMapping("currentvalue/_search") @ResponseBody ResponseEntity<?> getAssetCurrentValue(
            @RequestParam(name = "assetIds", required = true) final Set<Long> assetIds,
            @RequestParam(name = "tenantId", required = true) final String tenantId,
            @RequestBody @Valid final RequestInfoWrapper requestInfoWrapper, final BindingResult bindingResult); @PostMapping("currentvalue/_create") @ResponseBody ResponseEntity<?> saveCurrentValue(
            @RequestBody @Valid final AssetCurrentValueRequest assetCurrentValueRequest,
            final BindingResult bindingResult); @PostMapping("depreciations/_create") @ResponseBody ResponseEntity<?> saveDepreciation(@RequestBody @Valid final DepreciationRequest depreciationRequest,
            final BindingResult bindingResult, @RequestHeader final HttpHeaders headers); @PostMapping("depreciations/_search") @ResponseBody ResponseEntity<?> depreciationReport(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final DepreciationReportCriteria depreciationReportCriteria,
            final BindingResult bindingResult); ResponseEntity<?> getDisposalResponse(final List<Disposal> disposals, final RequestInfo requestInfo); ResponseEntity<?> getDepreciationResponse(final Depreciation depreciations, final RequestInfo requestInfo); ResponseEntity<?> getPaginatedSuccessResponse(final Map<String, Object> requestMap, final RequestInfo requestInfo); }
AssetController { @PostMapping("_search") @ResponseBody public ResponseEntity<?> search(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid final AssetCriteria assetCriteria, final BindingResult bindingResult) { log.debug("assetCriteria::" + assetCriteria + "requestInfoWrapper::" + requestInfoWrapper); if (bindingResult.hasErrors()) { final ErrorResponse errorResponse = assetCommonService.populateErrors(bindingResult); return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } if (assetCriteria.getTransaction() != null) if (assetCriteria.getTransaction().toString().equals(TransactionType.DEPRECIATION.toString())) { final List<ErrorResponse> errorResponses = assetValidator.validateSearchAssetDepreciation(assetCriteria); if (!errorResponses.isEmpty()) return new ResponseEntity<>(errorResponses, HttpStatus.BAD_REQUEST); } if (assetCriteria.getGrossValue() != null && assetCriteria.getFromCapitalizedValue() != null && assetCriteria.getToCapitalizedValue() != null) throw new RuntimeException( "Gross Value should not be present with from capitalized value and to capitalized value"); final List<Asset> assets = assetService.getAssets(assetCriteria, requestInfoWrapper.getRequestInfo()); return getAssetResponse(assets, requestInfoWrapper.getRequestInfo()); }  @PostMapping("_search") @ResponseBody ResponseEntity<?> search(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final AssetCriteria assetCriteria, final BindingResult bindingResult); @PostMapping("_paginatedsearch") @ResponseBody ResponseEntity<?> paginatedSearch(@ModelAttribute @Valid final AssetCriteria assetCriteria,
            @RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            final BindingResult bindingResult); @PostMapping("_create") @ResponseBody ResponseEntity<?> create(@RequestBody @Valid final AssetRequest assetRequest,
            final BindingResult bindingResult); @PostMapping("_update") @ResponseBody ResponseEntity<?> update(@RequestBody final AssetRequest assetRequest, final BindingResult bindingResult); @PostMapping("revaluation/_create") @ResponseBody ResponseEntity<?> revaluate(@RequestBody @Valid final RevaluationRequest revaluationRequest,
            final BindingResult bindingResult, @RequestHeader final HttpHeaders headers); @PostMapping("revaluation/_search") @ResponseBody ResponseEntity<?> revaluateSearch(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final RevaluationCriteria revaluationCriteria, final BindingResult bindingResult); @PostMapping("dispose/_create") @ResponseBody ResponseEntity<?> dispose(@RequestBody @Valid final DisposalRequest disposalRequest,
            final BindingResult bindingResult, @RequestHeader final HttpHeaders headers); @PostMapping("dispose/_search") @ResponseBody ResponseEntity<?> disposalSearch(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final DisposalCriteria disposalCriteria, final BindingResult bindingResult); @PostMapping("currentvalue/_search") @ResponseBody ResponseEntity<?> getAssetCurrentValue(
            @RequestParam(name = "assetIds", required = true) final Set<Long> assetIds,
            @RequestParam(name = "tenantId", required = true) final String tenantId,
            @RequestBody @Valid final RequestInfoWrapper requestInfoWrapper, final BindingResult bindingResult); @PostMapping("currentvalue/_create") @ResponseBody ResponseEntity<?> saveCurrentValue(
            @RequestBody @Valid final AssetCurrentValueRequest assetCurrentValueRequest,
            final BindingResult bindingResult); @PostMapping("depreciations/_create") @ResponseBody ResponseEntity<?> saveDepreciation(@RequestBody @Valid final DepreciationRequest depreciationRequest,
            final BindingResult bindingResult, @RequestHeader final HttpHeaders headers); @PostMapping("depreciations/_search") @ResponseBody ResponseEntity<?> depreciationReport(@RequestBody @Valid final RequestInfoWrapper requestInfoWrapper,
            @ModelAttribute @Valid final DepreciationReportCriteria depreciationReportCriteria,
            final BindingResult bindingResult); ResponseEntity<?> getDisposalResponse(final List<Disposal> disposals, final RequestInfo requestInfo); ResponseEntity<?> getDepreciationResponse(final Depreciation depreciations, final RequestInfo requestInfo); ResponseEntity<?> getPaginatedSuccessResponse(final Map<String, Object> requestMap, final RequestInfo requestInfo);  }