Skip to content

Commit

Permalink
Fixed issues with error handling issues after spring upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
ndwlocatieservices committed Oct 30, 2024
1 parent 020d863 commit e752ff9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import nu.ndw.nls.accessibilitymap.backend.exceptions.IncompleteArgumentsException;
import nu.ndw.nls.accessibilitymap.accessibility.exceptions.ResourceNotFoundException;
import nu.ndw.nls.accessibilitymap.backend.exceptions.IncompleteArgumentsException;
import nu.ndw.nls.accessibilitymap.backend.exceptions.VehicleTypeNotSupportedException;
import nu.ndw.nls.accessibilitymap.backend.exceptions.VehicleWeightRequiredException;
import nu.ndw.nls.accessibilitymap.backend.generated.model.v1.APIErrorJson;
Expand Down Expand Up @@ -60,7 +60,7 @@ public ResponseEntity<APIErrorJson> handleBadRequestException(RuntimeException e
public ResponseEntity<APIErrorJson> handleMethodArgumentTypeMismatchException(
MethodArgumentTypeMismatchException exception) {
APIErrorJson restError = new APIErrorJson()
.message("'" + exception.getPropertyName() + "' " + exception.getMessage());
.message(exception.getMessage());
return ResponseEntity.badRequest()
.body(restError);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@ void handleAccessDenied_ok() {

@Test
void handleMethodArgumentTypeMismatchException_ok() {
when(methodArgumentTypeMismatchException.getPropertyName()).thenReturn(PROPERTY_NAME);
when(methodArgumentTypeMismatchException.getMessage()).thenReturn(MESSAGE);
ResponseEntity<APIErrorJson> response = errorHandlerController
.handleMethodArgumentTypeMismatchException(methodArgumentTypeMismatchException);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
assertThat(response.getBody()).isNotNull();
assertThat(response.getBody().getMessage()).isEqualTo("'" + PROPERTY_NAME + "' " + MESSAGE);
assertThat(response.getBody().getMessage()).isEqualTo(MESSAGE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"message": "'vehicleHasTrailer' Failed to convert value of type 'java.lang.String' to required type 'java.lang.Boolean'; Invalid boolean value [2]"
"message": "Method parameter 'vehicleHasTrailer': Failed to convert value of type 'java.lang.String' to required type 'java.lang.Boolean'; Invalid boolean value [2]"
}

0 comments on commit e752ff9

Please sign in to comment.