Clean up warnings related to deprecated HttpStatus values, etc.

This commit is contained in:
Sam Brannen
2025-09-02 12:50:57 +02:00
parent 521764e68b
commit 6dc5bf7634
20 changed files with 37 additions and 35 deletions
@@ -175,7 +175,7 @@ class ResponseEntityTests {
}
@Test
@SuppressWarnings("deprecate")
@SuppressWarnings("deprecation")
void unprocessableEntity() {
ResponseEntity<String> responseEntity = ResponseEntity.unprocessableEntity().body("error");
@@ -86,6 +86,7 @@ class DefaultResponseErrorHandlerHttpStatusTests {
.isThrownBy(() -> this.handler.handleError(URI.create("/"), HttpMethod.GET, this.response));
}
@SuppressWarnings("deprecation")
static Stream<Arguments> errorCodes() {
return Stream.of(
// 4xx
@@ -57,14 +57,14 @@ class ExtractingResponseErrorHandlerTests {
HttpMessageConverter<Object> converter = new JacksonJsonHttpMessageConverter();
this.errorHandler = new ExtractingResponseErrorHandler(List.of(converter));
this.errorHandler.setStatusMapping(Map.of(HttpStatus.I_AM_A_TEAPOT, MyRestClientException.class));
this.errorHandler.setStatusMapping(Map.of(HttpStatus.EXPECTATION_FAILED, MyRestClientException.class));
this.errorHandler.setSeriesMapping(Map.of(HttpStatus.Series.SERVER_ERROR, MyRestClientException.class));
}
@Test
void hasError() throws Exception {
given(this.response.getStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT);
given(this.response.getStatusCode()).willReturn(HttpStatus.EXPECTATION_FAILED);
assertThat(this.errorHandler.hasError(this.response)).isTrue();
given(this.response.getStatusCode()).willReturn(HttpStatus.INTERNAL_SERVER_ERROR);
@@ -78,7 +78,7 @@ class ExtractingResponseErrorHandlerTests {
void hasErrorOverride() throws Exception {
this.errorHandler.setSeriesMapping(Collections.singletonMap(HttpStatus.Series.CLIENT_ERROR, null));
given(this.response.getStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT);
given(this.response.getStatusCode()).willReturn(HttpStatus.EXPECTATION_FAILED);
assertThat(this.errorHandler.hasError(this.response)).isTrue();
given(this.response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
@@ -90,7 +90,7 @@ class ExtractingResponseErrorHandlerTests {
@Test
void handleErrorStatusMatch() throws Exception {
given(this.response.getStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT);
given(this.response.getStatusCode()).willReturn(HttpStatus.EXPECTATION_FAILED);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
given(this.response.getHeaders()).willReturn(responseHeaders);