@Test public void testPopulateErrors() { final ErrorResponse expectedErrResponse = getErrorResponse(); final BindingResult errors = getBindingResultError(); final ErrorResponse actualErrResponse = assetCommonService.populateErrors(errors); assertEquals(expectedErrResponse.toString(), actualErrResponse.toString()); }
public ErrorResponse populateErrors(final BindingResult errors) { final ErrorResponse errRes = new ErrorResponse(); final ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); errRes.setResponseInfo(responseInfo); final Error error = new Error(); error.setCode(1); error.setDescription("Error while binding request"); if (errors.hasFieldErrors()) for (final FieldError errs : errors.getFieldErrors()) error.getFields().put(errs.getField(), errs.getRejectedValue()); errRes.setError(error); return errRes; }
AssetCommonService { public ErrorResponse populateErrors(final BindingResult errors) { final ErrorResponse errRes = new ErrorResponse(); final ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); errRes.setResponseInfo(responseInfo); final Error error = new Error(); error.setCode(1); error.setDescription("Error while binding request"); if (errors.hasFieldErrors()) for (final FieldError errs : errors.getFieldErrors()) error.getFields().put(errs.getField(), errs.getRejectedValue()); errRes.setError(error); return errRes; } }
AssetCommonService { public ErrorResponse populateErrors(final BindingResult errors) { final ErrorResponse errRes = new ErrorResponse(); final ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); errRes.setResponseInfo(responseInfo); final Error error = new Error(); error.setCode(1); error.setDescription("Error while binding request"); if (errors.hasFieldErrors()) for (final FieldError errs : errors.getFieldErrors()) error.getFields().put(errs.getField(), errs.getRejectedValue()); errRes.setError(error); return errRes; }  }
AssetCommonService { public ErrorResponse populateErrors(final BindingResult errors) { final ErrorResponse errRes = new ErrorResponse(); final ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); errRes.setResponseInfo(responseInfo); final Error error = new Error(); error.setCode(1); error.setDescription("Error while binding request"); if (errors.hasFieldErrors()) for (final FieldError errs : errors.getFieldErrors()) error.getFields().put(errs.getField(), errs.getRejectedValue()); errRes.setError(error); return errRes; }  ErrorResponse populateErrors(final BindingResult errors); Double getDepreciationRate(final Double depreciationRate); void validateDepreciationRateValue(final Double depreciationRate); AuditDetails getAuditDetails(final RequestInfo requestInfo); String getCode(final String codeFormat, final Sequence sequence); Long getNextId(final Sequence sequence); }
AssetCommonService { public ErrorResponse populateErrors(final BindingResult errors) { final ErrorResponse errRes = new ErrorResponse(); final ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); errRes.setResponseInfo(responseInfo); final Error error = new Error(); error.setCode(1); error.setDescription("Error while binding request"); if (errors.hasFieldErrors()) for (final FieldError errs : errors.getFieldErrors()) error.getFields().put(errs.getField(), errs.getRejectedValue()); errRes.setError(error); return errRes; }  ErrorResponse populateErrors(final BindingResult errors); Double getDepreciationRate(final Double depreciationRate); void validateDepreciationRateValue(final Double depreciationRate); AuditDetails getAuditDetails(final RequestInfo requestInfo); String getCode(final String codeFormat, final Sequence sequence); Long getNextId(final Sequence sequence);  }