test_class.declarator: FIELD_ERROR_CODE = "NotNull"
test_class.modifier: private static final
test_class.original_string: private static final String FIELD_ERROR_CODE = "NotNull";
test_class.type: String
test_class.var_name: FIELD_ERROR_CODE
test_class.declarator: FIELD_ERROR_DEFAULT_MESSAGE = "May not be null"
test_class.modifier: private static final
test_class.original_string: private static final String FIELD_ERROR_DEFAULT_MESSAGE = "May not be null";
test_class.type: String
test_class.var_name: FIELD_ERROR_DEFAULT_MESSAGE
test_class.declarator: FIELD_NAME = "field"
test_class.modifier: private static final
test_class.original_string: private static final String FIELD_NAME = "field";
test_class.type: String
test_class.var_name: FIELD_NAME
test_class.declarator: OBJECT_NAME = "object"
test_class.modifier: private static final
test_class.original_string: private static final String OBJECT_NAME = "object";
test_class.type: String
test_class.var_name: OBJECT_NAME
test_class.declarator: errorHandler = new RestErrorHandler()
test_class.modifier: private
test_class.original_string: private RestErrorHandler errorHandler = new RestErrorHandler();
test_class.type: RestErrorHandler
test_class.var_name: errorHandler
test_class.file: jooq-only/src/test/java/net/petrikainulainen/spring/jooq/common/controller/RestErrorHandlerTest.java
test_class.identifier: RestErrorHandlerTest
test_case.body: @Test
      public void handleValidationError_WithOneFieldError_ShouldReturnRestErrorWithOneValidationError() throws NoSuchMethodException {
  
          MethodParameter invokedMethod = createInvokedMethod();
  
          FieldError fieldValidationError = createFieldError(FIELD_NAME, FIELD_ERROR_CODE, FIELD_ERROR_DEFAULT_MESSAGE);
          BindingResult bindingResult = new BeanPropertyBindingResult(new Object(), OBJECT_NAME);
          bindingResult.addError(fieldValidationError);
  
          MethodArgumentNotValidException ex = new MethodArgumentNotValidException(invokedMethod, bindingResult);
  
          RestError error = errorHandler.handleValidationError(ex);
  
          assertThat(error.getCode()).isEqualTo(HttpStatus.BAD_REQUEST.value());
          assertThat(error.getMessage()).isNotEmpty();
          assertThat(error.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST);
  
          List<ValidationError> validationErrors = error.getValidationErrors();
          assertThat(validationErrors).hasSize(1);
  
          ValidationError validationError = validationErrors.get(0);
          assertThat(validationError.getField()).isEqualTo(FIELD_NAME);
          assertThat(validationError.getErrorCode()).isEqualTo(FIELD_ERROR_CODE);
          assertThat(validationError.getErrorMessage()).isEqualTo(FIELD_ERROR_DEFAULT_MESSAGE);
      }
test_case.class_method_signature: RestErrorHandlerTest.handleValidationError_WithOneFieldError_ShouldReturnRestErrorWithOneValidationError()
test_case.full_signature: @Test public void handleValidationError_WithOneFieldError_ShouldReturnRestErrorWithOneValidationError()
test_case.identifier: handleValidationError_WithOneFieldError_ShouldReturnRestErrorWithOneValidationError
test_case.invocations: createInvokedMethod createFieldError addError handleValidationError isEqualTo assertThat getCode value isNotEmpty assertThat getMessage isEqualTo assertThat getStatus getValidationErrors hasSize assertThat get isEqualTo assertThat getField isEqualTo assertThat getErrorCode isEqualTo assertThat getErrorMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void handleValidationError_WithOneFieldError_ShouldReturnRestErrorWithOneValidationError()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(RestErrorHandler.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(RestErrorHandler.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.file: jooq-only/src/main/java/net/petrikainulainen/spring/jooq/common/controller/RestErrorHandler.java
focal_class.identifier: RestErrorHandler
focal_class.class_method_signature: RestErrorHandler.handleTodoNotFound(TodoNotFoundException ex)
focal_class.full_signature: @ExceptionHandler(TodoNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) public void handleTodoNotFound(TodoNotFoundException ex)
focal_class.identifier: handleTodoNotFound
focal_class.modifiers: @ExceptionHandler(TodoNotFoundException.class) @ResponseStatus(HttpStatus.NOT_FOUND) public
focal_class.parameters: (TodoNotFoundException ex)
focal_class.return: void
focal_class.signature: void handleTodoNotFound(TodoNotFoundException ex)
focal_class.class_method_signature: RestErrorHandler.handleValidationError(MethodArgumentNotValidException ex)
focal_class.full_signature: @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public RestError handleValidationError(MethodArgumentNotValidException ex)
focal_class.identifier: handleValidationError
focal_class.modifiers: @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public
focal_class.parameters: (MethodArgumentNotValidException ex)
focal_class.return: RestError
focal_class.signature: RestError handleValidationError(MethodArgumentNotValidException ex)
focal_method.body: @ExceptionHandler(MethodArgumentNotValidException.class)
      @ResponseStatus(HttpStatus.BAD_REQUEST)
      @ResponseBody
      public RestError handleValidationError(MethodArgumentNotValidException ex) {
          LOGGER.info("Handling validation error");
  
          RestError.Builder error = RestError.getBuilder()
                  .status(HttpStatus.BAD_REQUEST)
                  .code(HttpStatus.BAD_REQUEST.value())
                  .message(ex.getMessage());
  
          List<FieldError> fieldErrors = ex.getBindingResult().getFieldErrors();
  
          for (FieldError fieldError: fieldErrors) {
              error.validationError(fieldError.getField(), fieldError.getCode(), fieldError.getDefaultMessage());
          }
  
          RestError validationError = error.build();
  
          LOGGER.info("Returning validation error: {}", validationError);
  
          return validationError;
      }
focal_method.class_method_signature: RestErrorHandler.handleValidationError(MethodArgumentNotValidException ex)
focal_method.full_signature: @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public RestError handleValidationError(MethodArgumentNotValidException ex)
focal_method.identifier: handleValidationError
focal_method.invocations: info message code status getBuilder value getMessage getFieldErrors getBindingResult validationError getField getCode getDefaultMessage build info
focal_method.modifiers: @ExceptionHandler(MethodArgumentNotValidException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public
focal_method.parameters: (MethodArgumentNotValidException ex)
focal_method.return: RestError
focal_method.signature: RestError handleValidationError(MethodArgumentNotValidException ex)