Use HttpStatusCode interface
This commit contains changes made because of the introduction of HttpStatusCode. In general, methods that used to return a HttpStatus now return HttpStatusCode instead, and methods that returned raw status codes are now deprecated. See gh-28214
This commit is contained in:
@@ -328,7 +328,7 @@ public class ErrorResponseExceptionTests {
|
||||
|
||||
private void assertStatus(ErrorResponse ex, HttpStatus status) {
|
||||
ProblemDetail body = ex.getBody();
|
||||
assertThat(ex.getStatus()).isEqualTo(status);
|
||||
assertThat(ex.getStatusCode()).isEqualTo(status);
|
||||
assertThat(body.getStatus()).isEqualTo(status.value());
|
||||
assertThat(body.getTitle()).isEqualTo(status.getReasonPhrase());
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class DefaultResponseErrorHandlerHttpStatusTests {
|
||||
@DisplayName("hasError() returns true")
|
||||
@MethodSource("errorCodes")
|
||||
void hasErrorTrue(HttpStatus httpStatus) throws Exception {
|
||||
given(this.response.getRawStatusCode()).willReturn(httpStatus.value());
|
||||
given(this.response.getStatusCode()).willReturn(httpStatus);
|
||||
assertThat(this.handler.hasError(this.response)).isTrue();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class DefaultResponseErrorHandlerHttpStatusTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
|
||||
given(this.response.getRawStatusCode()).willReturn(httpStatus.value());
|
||||
given(this.response.getStatusCode()).willReturn(httpStatus);
|
||||
given(this.response.getHeaders()).willReturn(headers);
|
||||
|
||||
assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() -> this.handler.handleError(this.response));
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.util.StreamUtils;
|
||||
@@ -50,13 +51,13 @@ public class DefaultResponseErrorHandlerTests {
|
||||
|
||||
@Test
|
||||
public void hasErrorTrue() throws Exception {
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.NOT_FOUND.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
|
||||
assertThat(handler.hasError(response)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasErrorFalse() throws Exception {
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
assertThat(handler.hasError(response)).isFalse();
|
||||
}
|
||||
|
||||
@@ -65,7 +66,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.NOT_FOUND.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
|
||||
given(response.getStatusText()).willReturn("Not Found");
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
given(response.getBody()).willReturn(new ByteArrayInputStream("Hello World".getBytes(StandardCharsets.UTF_8)));
|
||||
@@ -81,7 +82,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.NOT_FOUND.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
|
||||
given(response.getStatusText()).willReturn("Not Found");
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
given(response.getBody()).willThrow(new IOException());
|
||||
@@ -94,7 +95,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.NOT_FOUND.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
|
||||
given(response.getStatusText()).willReturn("Not Found");
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
|
||||
@@ -107,7 +108,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(999);
|
||||
given(response.getStatusCode()).willReturn(HttpStatusCode.valueOf(999));
|
||||
given(response.getStatusText()).willReturn("Custom status code");
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
|
||||
@@ -119,7 +120,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(999);
|
||||
given(response.getStatusCode()).willReturn(HttpStatusCode.valueOf(999));
|
||||
given(response.getStatusText()).willReturn("Custom status code");
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
|
||||
@@ -132,7 +133,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(499);
|
||||
given(response.getStatusCode()).willReturn(HttpStatusCode.valueOf(499));
|
||||
given(response.getStatusText()).willReturn("Custom status code");
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
|
||||
@@ -141,7 +142,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
|
||||
@Test
|
||||
public void handleErrorForCustomClientError() throws Exception {
|
||||
int statusCode = 499;
|
||||
HttpStatusCode statusCode = HttpStatusCode.valueOf(499);
|
||||
String statusText = "Custom status code";
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -150,7 +151,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
String responseBody = "Hello World";
|
||||
TestByteArrayInputStream body = new TestByteArrayInputStream(responseBody.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(statusCode);
|
||||
given(response.getStatusCode()).willReturn(statusCode);
|
||||
given(response.getStatusText()).willReturn(statusText);
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
given(response.getBody()).willReturn(body);
|
||||
@@ -158,13 +159,13 @@ public class DefaultResponseErrorHandlerTests {
|
||||
Throwable throwable = catchThrowable(() -> handler.handleError(response));
|
||||
|
||||
// validate exception
|
||||
assertThat(throwable).isInstanceOf(UnknownHttpStatusCodeException.class);
|
||||
UnknownHttpStatusCodeException actualUnknownHttpStatusCodeException = (UnknownHttpStatusCodeException) throwable;
|
||||
assertThat(actualUnknownHttpStatusCodeException.getRawStatusCode()).isEqualTo(statusCode);
|
||||
assertThat(actualUnknownHttpStatusCodeException.getStatusText()).isEqualTo(statusText);
|
||||
assertThat(actualUnknownHttpStatusCodeException.getResponseHeaders()).isEqualTo(headers);
|
||||
assertThat(actualUnknownHttpStatusCodeException.getMessage()).contains(responseBody);
|
||||
assertThat(actualUnknownHttpStatusCodeException.getResponseBodyAsString()).isEqualTo(responseBody);
|
||||
assertThat(throwable).isInstanceOf(HttpClientErrorException.class);
|
||||
HttpClientErrorException actualHttpClientErrorException = (HttpClientErrorException) throwable;
|
||||
assertThat(actualHttpClientErrorException.getStatusCode()).isEqualTo(statusCode);
|
||||
assertThat(actualHttpClientErrorException.getStatusText()).isEqualTo(statusText);
|
||||
assertThat(actualHttpClientErrorException.getResponseHeaders()).isEqualTo(headers);
|
||||
assertThat(actualHttpClientErrorException.getMessage()).contains(responseBody);
|
||||
assertThat(actualHttpClientErrorException.getResponseBodyAsString()).isEqualTo(responseBody);
|
||||
}
|
||||
|
||||
@Test // SPR-17461
|
||||
@@ -172,7 +173,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(599);
|
||||
given(response.getStatusCode()).willReturn(HttpStatusCode.valueOf(599));
|
||||
given(response.getStatusText()).willReturn("Custom status code");
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
|
||||
@@ -181,7 +182,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
|
||||
@Test
|
||||
public void handleErrorForCustomServerError() throws Exception {
|
||||
int statusCode = 599;
|
||||
HttpStatusCode statusCode = HttpStatusCode.valueOf(599);
|
||||
String statusText = "Custom status code";
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -190,7 +191,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
String responseBody = "Hello World";
|
||||
TestByteArrayInputStream body = new TestByteArrayInputStream(responseBody.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(statusCode);
|
||||
given(response.getStatusCode()).willReturn(statusCode);
|
||||
given(response.getStatusText()).willReturn(statusText);
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
given(response.getBody()).willReturn(body);
|
||||
@@ -198,13 +199,13 @@ public class DefaultResponseErrorHandlerTests {
|
||||
Throwable throwable = catchThrowable(() -> handler.handleError(response));
|
||||
|
||||
// validate exception
|
||||
assertThat(throwable).isInstanceOf(UnknownHttpStatusCodeException.class);
|
||||
UnknownHttpStatusCodeException actualUnknownHttpStatusCodeException = (UnknownHttpStatusCodeException) throwable;
|
||||
assertThat(actualUnknownHttpStatusCodeException.getRawStatusCode()).isEqualTo(statusCode);
|
||||
assertThat(actualUnknownHttpStatusCodeException.getStatusText()).isEqualTo(statusText);
|
||||
assertThat(actualUnknownHttpStatusCodeException.getResponseHeaders()).isEqualTo(headers);
|
||||
assertThat(actualUnknownHttpStatusCodeException.getMessage()).contains(responseBody);
|
||||
assertThat(actualUnknownHttpStatusCodeException.getResponseBodyAsString()).isEqualTo(responseBody);
|
||||
assertThat(throwable).isInstanceOf(HttpServerErrorException.class);
|
||||
HttpServerErrorException actualHttpServerErrorException = (HttpServerErrorException) throwable;
|
||||
assertThat(actualHttpServerErrorException.getStatusCode()).isEqualTo(statusCode);
|
||||
assertThat(actualHttpServerErrorException.getStatusText()).isEqualTo(statusText);
|
||||
assertThat(actualHttpServerErrorException.getResponseHeaders()).isEqualTo(headers);
|
||||
assertThat(actualHttpServerErrorException.getMessage()).contains(responseBody);
|
||||
assertThat(actualHttpServerErrorException.getResponseBodyAsString()).isEqualTo(responseBody);
|
||||
}
|
||||
|
||||
@Test // SPR-16604
|
||||
@@ -213,7 +214,7 @@ public class DefaultResponseErrorHandlerTests {
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
TestByteArrayInputStream body = new TestByteArrayInputStream("Hello World".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(999);
|
||||
given(response.getStatusCode()).willReturn(HttpStatusCode.valueOf(999));
|
||||
given(response.getStatusText()).willReturn("Custom status code");
|
||||
given(response.getHeaders()).willReturn(headers);
|
||||
given(response.getBody()).willReturn(body);
|
||||
|
||||
@@ -60,13 +60,13 @@ public class ExtractingResponseErrorHandlerTests {
|
||||
|
||||
@Test
|
||||
public void hasError() throws Exception {
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT);
|
||||
assertThat(this.errorHandler.hasError(this.response)).isTrue();
|
||||
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
assertThat(this.errorHandler.hasError(this.response)).isTrue();
|
||||
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
assertThat(this.errorHandler.hasError(this.response)).isFalse();
|
||||
}
|
||||
|
||||
@@ -75,19 +75,19 @@ public class ExtractingResponseErrorHandlerTests {
|
||||
this.errorHandler.setSeriesMapping(Collections
|
||||
.singletonMap(HttpStatus.Series.CLIENT_ERROR, null));
|
||||
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT);
|
||||
assertThat(this.errorHandler.hasError(this.response)).isTrue();
|
||||
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.NOT_FOUND.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
|
||||
assertThat(this.errorHandler.hasError(this.response)).isFalse();
|
||||
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
assertThat(this.errorHandler.hasError(this.response)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleErrorStatusMatch() throws Exception {
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.I_AM_A_TEAPOT);
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
given(this.response.getHeaders()).willReturn(responseHeaders);
|
||||
@@ -103,7 +103,7 @@ public class ExtractingResponseErrorHandlerTests {
|
||||
|
||||
@Test
|
||||
public void handleErrorSeriesMatch() throws Exception {
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
given(this.response.getHeaders()).willReturn(responseHeaders);
|
||||
@@ -119,7 +119,7 @@ public class ExtractingResponseErrorHandlerTests {
|
||||
|
||||
@Test
|
||||
public void handleNoMatch() throws Exception {
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.NOT_FOUND.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
given(this.response.getHeaders()).willReturn(responseHeaders);
|
||||
@@ -141,7 +141,7 @@ public class ExtractingResponseErrorHandlerTests {
|
||||
this.errorHandler.setSeriesMapping(Collections
|
||||
.singletonMap(HttpStatus.Series.CLIENT_ERROR, null));
|
||||
|
||||
given(this.response.getRawStatusCode()).willReturn(HttpStatus.NOT_FOUND.value());
|
||||
given(this.response.getStatusCode()).willReturn(HttpStatus.NOT_FOUND);
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
given(this.response.getHeaders()).willReturn(responseHeaders);
|
||||
|
||||
@@ -72,7 +72,7 @@ class HttpMessageConverterExtractorTests {
|
||||
|
||||
@Test
|
||||
void noContent() throws IOException {
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.NO_CONTENT.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.NO_CONTENT);
|
||||
|
||||
Object result = extractor.extractData(response);
|
||||
assertThat(result).isNull();
|
||||
@@ -80,7 +80,7 @@ class HttpMessageConverterExtractorTests {
|
||||
|
||||
@Test
|
||||
void notModified() throws IOException {
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.NOT_MODIFIED.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.NOT_MODIFIED);
|
||||
|
||||
Object result = extractor.extractData(response);
|
||||
assertThat(result).isNull();
|
||||
@@ -88,7 +88,7 @@ class HttpMessageConverterExtractorTests {
|
||||
|
||||
@Test
|
||||
void informational() throws IOException {
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.CONTINUE.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.CONTINUE);
|
||||
|
||||
Object result = extractor.extractData(response);
|
||||
assertThat(result).isNull();
|
||||
@@ -97,7 +97,7 @@ class HttpMessageConverterExtractorTests {
|
||||
@Test
|
||||
void zeroContentLength() throws IOException {
|
||||
responseHeaders.setContentLength(0);
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
|
||||
Object result = extractor.extractData(response);
|
||||
@@ -106,7 +106,7 @@ class HttpMessageConverterExtractorTests {
|
||||
|
||||
@Test
|
||||
void emptyMessageBody() throws IOException {
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
given(response.getBody()).willReturn(new ByteArrayInputStream("".getBytes()));
|
||||
|
||||
@@ -116,7 +116,7 @@ class HttpMessageConverterExtractorTests {
|
||||
|
||||
@Test // gh-22265
|
||||
void nullMessageBody() throws IOException {
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
given(response.getBody()).willReturn(null);
|
||||
|
||||
@@ -128,7 +128,7 @@ class HttpMessageConverterExtractorTests {
|
||||
void normal() throws IOException {
|
||||
responseHeaders.setContentType(contentType);
|
||||
String expected = "Foo";
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
given(response.getBody()).willReturn(new ByteArrayInputStream(expected.getBytes()));
|
||||
given(converter.canRead(String.class, contentType)).willReturn(true);
|
||||
@@ -141,7 +141,7 @@ class HttpMessageConverterExtractorTests {
|
||||
@Test
|
||||
void cannotRead() throws IOException {
|
||||
responseHeaders.setContentType(contentType);
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
given(response.getBody()).willReturn(new ByteArrayInputStream("Foobar".getBytes()));
|
||||
given(converter.canRead(String.class, contentType)).willReturn(false);
|
||||
@@ -159,7 +159,7 @@ class HttpMessageConverterExtractorTests {
|
||||
GenericHttpMessageConverter<String> converter = mock(GenericHttpMessageConverter.class);
|
||||
HttpMessageConverterExtractor<?> extractor = new HttpMessageConverterExtractor<List<String>>(type, asList(converter));
|
||||
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
given(response.getBody()).willReturn(new ByteArrayInputStream(expected.getBytes()));
|
||||
given(converter.canRead(type, null, contentType)).willReturn(true);
|
||||
@@ -172,7 +172,7 @@ class HttpMessageConverterExtractorTests {
|
||||
@Test // SPR-13592
|
||||
void converterThrowsIOException() throws IOException {
|
||||
responseHeaders.setContentType(contentType);
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
given(response.getBody()).willReturn(new ByteArrayInputStream("Foobar".getBytes()));
|
||||
given(converter.canRead(String.class, contentType)).willReturn(true);
|
||||
@@ -185,7 +185,7 @@ class HttpMessageConverterExtractorTests {
|
||||
@Test // SPR-13592
|
||||
void converterThrowsHttpMessageNotReadableException() throws IOException {
|
||||
responseHeaders.setContentType(contentType);
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
given(response.getBody()).willReturn(new ByteArrayInputStream("Foobar".getBytes()));
|
||||
given(converter.canRead(String.class, contentType)).willThrow(HttpMessageNotReadableException.class);
|
||||
@@ -197,7 +197,7 @@ class HttpMessageConverterExtractorTests {
|
||||
@Test
|
||||
void unknownContentTypeExceptionContainsCorrectResponseBody() throws IOException {
|
||||
responseHeaders.setContentType(contentType);
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getStatusCode()).willReturn(HttpStatus.OK);
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
given(response.getBody()).willReturn(new ByteArrayInputStream("Foobar".getBytes()) {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user