### Question:
GlobalExceptionHandlerController { @ExceptionHandler(value = RestException.class) public ResponseEntity restException(RestException ex, HandlerMethod handlerMethod) { log.warn("RestException handled in service: {}, message: {}", handlerMethod.getMethod().getDeclaringClass().getSimpleName(), ex.getMessage()); log.debug("Stacktrace: {}", ex); return responseErrorMapper.generateErrorResponse(createMessageError(ex.getMessageErrorCode(), ex.getMessage())); }  @ExceptionHandler(value = ValidationException.class) ResponseEntity validationException(ValidationException ex, HandlerMethod handlerMethod); @ExceptionHandler(value = ServletRequestBindingException.class) ResponseEntity servletRequestBindingException(ServletRequestBindingException ex,
                                                         HandlerMethod handlerMethod); @ExceptionHandler(value = IllegalArgumentException.class) ResponseEntity illegalArgumentException(IllegalArgumentException ex, HandlerMethod handlerMethod); @ExceptionHandler(value = HttpMessageNotReadableException.class) ResponseEntity httpMessageException(HttpMessageNotReadableException ex, HandlerMethod handlerMethod); @ExceptionHandler(value = HttpMediaTypeNotAcceptableException.class) ResponseEntity mediaTypeNotSupportedException(HttpMediaTypeNotAcceptableException ex,
                                                         HandlerMethod handlerMethod); @ExceptionHandler(value = Exception.class) ResponseEntity exception(Exception ex, HandlerMethod handlerMethod); @ExceptionHandler(value = RestException.class) ResponseEntity restException(RestException ex, HandlerMethod handlerMethod); @ExceptionHandler(value = AspspProfileRestException.class) ResponseEntity aspspProfileRestException(AspspProfileRestException ex, HandlerMethod handlerMethod); @ExceptionHandler(value = ResourceAccessException.class) ResponseEntity resourceAccessException(ResourceAccessException ex, HandlerMethod handlerMethod); @ExceptionHandler(value = MethodArgumentNotValidException.class) ResponseEntity requestBodyValidationException(MethodArgumentNotValidException ex,
                                                         HandlerMethod handlerMethod); @ExceptionHandler(value = CertificateException.class) ResponseEntity getTppIdException(CertificateException ex, HandlerMethod handlerMethod); @ExceptionHandler(value = MethodArgumentTypeMismatchException.class) ResponseEntity methodArgumentTypeMismatchException(MethodArgumentTypeMismatchException ex,
                                                              HandlerMethod handlerMethod); @ExceptionHandler(value = WrongPaymentTypeException.class) ResponseEntity wrongPaymentTypeException(WrongPaymentTypeException ex,
                                                              HandlerMethod handlerMethod);  }### Answer:
@Test void methodRestException_shouldReturnErrorWithMessage() throws NoSuchMethodException { ErrorType errorType = ErrorType.AIS_400; MessageErrorCode messageErrorCode = MessageErrorCode.FORMAT_ERROR; String restExceptionMessage = "restExceptionMessage"; when(serviceTypeDiscoveryService.getServiceType()).thenReturn(ServiceType.AIS); when(errorTypeMapper.mapToErrorType(ServiceType.AIS, 400)).thenReturn(errorType); when(handlerMethod.getMethod()).thenReturn(Object.class.getMethod("toString")); RestException restException = new RestException(messageErrorCode, restExceptionMessage); globalExceptionHandlerController.restException(restException, handlerMethod); verify(errorTypeMapper).mapToErrorType(ServiceType.AIS, 400); verify(responseErrorMapper).generateErrorResponse(new MessageError(errorType, TppMessageInformation.buildWithCustomError(messageErrorCode, restExceptionMessage))); }