Skip to content

Commit

Permalink
MOSIP-32842 Fixed test case failure
Browse files Browse the repository at this point in the history
Signed-off-by: kameshsr <[email protected]>
  • Loading branch information
kameshsr committed May 21, 2024
1 parent 75e393f commit 3439db1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class PartnerServiceResponseExceptionHandler extends ResponseEntityExcept
String msg = "mosip.partnermanagement";
String version = "1.0";

// @ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex) {
Map<String, Object> body = new LinkedHashMap<>();
body.put("id", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,27 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
@Autowired
private ObjectMapper objectMapper;

// /**
// * Exception to be thrown when validation on an argument annotated with {@code @Valid} fails.
// *
// */
// @Override
// protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers,
// HttpStatus status, WebRequest request) {
// ExceptionUtils.logRootCause(ex);
// List<FieldError> fieldErrors = ex.getBindingResult().getFieldErrors();
// FieldError fieldError = fieldErrors.get(0);
// ServiceError serviceError = new ServiceError(ErrorMessages.MISSING_INPUT_PARAMETER.getErrorCode(),
// "Invalid request parameter - " + fieldError.getDefaultMessage() + " :" + fieldError.getField());
// ResponseWrapper<ServiceError> errorResponse = null;
// try {
// errorResponse = setErrors(request);
// errorResponse.getErrors().add(serviceError);
// } catch (IOException e) {
// //
// }
// return new ResponseEntity<>(errorResponse, HttpStatus.OK);
// }
/**
* Exception to be thrown when validation on an argument annotated with {@code @Valid} fails.
*
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers,
HttpStatus status, WebRequest request) {
ExceptionUtils.logRootCause(ex);
List<FieldError> fieldErrors = ex.getBindingResult().getFieldErrors();
FieldError fieldError = fieldErrors.get(0);
ServiceError serviceError = new ServiceError(ErrorMessages.MISSING_INPUT_PARAMETER.getErrorCode(),
"Invalid request parameter - " + fieldError.getDefaultMessage() + " :" + fieldError.getField());
ResponseWrapper<ServiceError> errorResponse = null;
try {
errorResponse = setErrors(request);
errorResponse.getErrors().add(serviceError);
} catch (IOException e) {
//
}
return new ResponseEntity<>(errorResponse, HttpStatus.OK);
}

/**
* Exception to be thrown when misp application validations failed.
Expand Down

0 comments on commit 3439db1

Please sign in to comment.