@Test public void testReqForMissingParameter() { ResponseEntity<?> errResEntity = errorHandler.getMissingParameterErrorResponse(bindingResult, getRequestInfo()); assertTrue(errResEntity.getStatusCode().equals(HttpStatus.BAD_REQUEST)); }
@SuppressWarnings("unchecked") public ResponseEntity<?> getMissingParameterErrorResponse(BindingResult bindingResults, RequestInfo requestInfo) { Error error = new Error(); error.setCode(400); @SuppressWarnings("rawtypes") List fieldErrorsList = new ArrayList(); if (bindingResults.hasFieldErrors()) { for (FieldError fieldError : bindingResults.getFieldErrors()) { fieldErrorsList.add(fieldError.getField()); } } error.setMessage(fieldErrorsList + " : Required Query Parameter Missing "); error.setDescription("Error While Binding Results"); error.setFields(fieldErrorsList); ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setApiId(requestInfo.getApiId()); responseInfo.setResMsgId(requestInfo.getMsgId()); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); responseInfo.setTs(requestInfo.getTs()); responseInfo.setVer(requestInfo.getVer()); ErrorResponse errRes = new ErrorResponse(); errRes.setError(error); errRes.setResponseInfo(responseInfo); return new ResponseEntity<ErrorResponse>(errRes, HttpStatus.BAD_REQUEST); }
ErrorHandler { @SuppressWarnings("unchecked") public ResponseEntity<?> getMissingParameterErrorResponse(BindingResult bindingResults, RequestInfo requestInfo) { Error error = new Error(); error.setCode(400); @SuppressWarnings("rawtypes") List fieldErrorsList = new ArrayList(); if (bindingResults.hasFieldErrors()) { for (FieldError fieldError : bindingResults.getFieldErrors()) { fieldErrorsList.add(fieldError.getField()); } } error.setMessage(fieldErrorsList + " : Required Query Parameter Missing "); error.setDescription("Error While Binding Results"); error.setFields(fieldErrorsList); ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setApiId(requestInfo.getApiId()); responseInfo.setResMsgId(requestInfo.getMsgId()); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); responseInfo.setTs(requestInfo.getTs()); responseInfo.setVer(requestInfo.getVer()); ErrorResponse errRes = new ErrorResponse(); errRes.setError(error); errRes.setResponseInfo(responseInfo); return new ResponseEntity<ErrorResponse>(errRes, HttpStatus.BAD_REQUEST); } }
ErrorHandler { @SuppressWarnings("unchecked") public ResponseEntity<?> getMissingParameterErrorResponse(BindingResult bindingResults, RequestInfo requestInfo) { Error error = new Error(); error.setCode(400); @SuppressWarnings("rawtypes") List fieldErrorsList = new ArrayList(); if (bindingResults.hasFieldErrors()) { for (FieldError fieldError : bindingResults.getFieldErrors()) { fieldErrorsList.add(fieldError.getField()); } } error.setMessage(fieldErrorsList + " : Required Query Parameter Missing "); error.setDescription("Error While Binding Results"); error.setFields(fieldErrorsList); ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setApiId(requestInfo.getApiId()); responseInfo.setResMsgId(requestInfo.getMsgId()); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); responseInfo.setTs(requestInfo.getTs()); responseInfo.setVer(requestInfo.getVer()); ErrorResponse errRes = new ErrorResponse(); errRes.setError(error); errRes.setResponseInfo(responseInfo); return new ResponseEntity<ErrorResponse>(errRes, HttpStatus.BAD_REQUEST); }  }
ErrorHandler { @SuppressWarnings("unchecked") public ResponseEntity<?> getMissingParameterErrorResponse(BindingResult bindingResults, RequestInfo requestInfo) { Error error = new Error(); error.setCode(400); @SuppressWarnings("rawtypes") List fieldErrorsList = new ArrayList(); if (bindingResults.hasFieldErrors()) { for (FieldError fieldError : bindingResults.getFieldErrors()) { fieldErrorsList.add(fieldError.getField()); } } error.setMessage(fieldErrorsList + " : Required Query Parameter Missing "); error.setDescription("Error While Binding Results"); error.setFields(fieldErrorsList); ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setApiId(requestInfo.getApiId()); responseInfo.setResMsgId(requestInfo.getMsgId()); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); responseInfo.setTs(requestInfo.getTs()); responseInfo.setVer(requestInfo.getVer()); ErrorResponse errRes = new ErrorResponse(); errRes.setError(error); errRes.setResponseInfo(responseInfo); return new ResponseEntity<ErrorResponse>(errRes, HttpStatus.BAD_REQUEST); }  ResponseEntity<?> handleBindingErrorsForSearch(RequestInfo requestInfo,
			BindingResult bindingResultsForRequestInfo, BindingResult bindingResultsForSearchCriteria); ResponseEntity<?> handleBindingErrorsForCreate(RequestInfo requestInfo, BindingResult bindingResult); ResponseEntity<?> handleBindingErrorsForUpdate(RequestInfo requestInfo, BindingResult bindingResult); @SuppressWarnings("unchecked") ResponseEntity<?> getMissingParameterErrorResponse(BindingResult bindingResults, RequestInfo requestInfo); ResponseEntity<?> getUnExpectedErrorResponse(BindingResult bindingResults, RequestInfo requestInfo,
			String errorCause); ResponseEntity<?> getUpdateErrorResponse(BindingResult bindingResults, RequestInfo requestInfo,
			RegistrationUnit registrationUnit); ErrorResponse getErrorResponse(Errors bindingResult, RequestInfo requestInfo); ResponseInfo getResponseInfo(RequestInfo requestInfo, HttpStatus status); }
ErrorHandler { @SuppressWarnings("unchecked") public ResponseEntity<?> getMissingParameterErrorResponse(BindingResult bindingResults, RequestInfo requestInfo) { Error error = new Error(); error.setCode(400); @SuppressWarnings("rawtypes") List fieldErrorsList = new ArrayList(); if (bindingResults.hasFieldErrors()) { for (FieldError fieldError : bindingResults.getFieldErrors()) { fieldErrorsList.add(fieldError.getField()); } } error.setMessage(fieldErrorsList + " : Required Query Parameter Missing "); error.setDescription("Error While Binding Results"); error.setFields(fieldErrorsList); ResponseInfo responseInfo = new ResponseInfo(); responseInfo.setApiId(requestInfo.getApiId()); responseInfo.setResMsgId(requestInfo.getMsgId()); responseInfo.setStatus(HttpStatus.BAD_REQUEST.toString()); responseInfo.setTs(requestInfo.getTs()); responseInfo.setVer(requestInfo.getVer()); ErrorResponse errRes = new ErrorResponse(); errRes.setError(error); errRes.setResponseInfo(responseInfo); return new ResponseEntity<ErrorResponse>(errRes, HttpStatus.BAD_REQUEST); }  ResponseEntity<?> handleBindingErrorsForSearch(RequestInfo requestInfo,
			BindingResult bindingResultsForRequestInfo, BindingResult bindingResultsForSearchCriteria); ResponseEntity<?> handleBindingErrorsForCreate(RequestInfo requestInfo, BindingResult bindingResult); ResponseEntity<?> handleBindingErrorsForUpdate(RequestInfo requestInfo, BindingResult bindingResult); @SuppressWarnings("unchecked") ResponseEntity<?> getMissingParameterErrorResponse(BindingResult bindingResults, RequestInfo requestInfo); ResponseEntity<?> getUnExpectedErrorResponse(BindingResult bindingResults, RequestInfo requestInfo,
			String errorCause); ResponseEntity<?> getUpdateErrorResponse(BindingResult bindingResults, RequestInfo requestInfo,
			RegistrationUnit registrationUnit); ErrorResponse getErrorResponse(Errors bindingResult, RequestInfo requestInfo); ResponseInfo getResponseInfo(RequestInfo requestInfo, HttpStatus status);  }