@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2019 the original author or authors .
* Copyright 2002 - 2020 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -60,6 +60,8 @@ public class DefaultClientResponseTests {
@@ -60,6 +60,8 @@ public class DefaultClientResponseTests {
private ClientHttpResponse mockResponse ;
private final HttpHeaders httpHeaders = new HttpHeaders ( ) ;
private ExchangeStrategies mockExchangeStrategies ;
private DefaultClientResponse defaultClientResponse ;
@ -68,6 +70,7 @@ public class DefaultClientResponseTests {
@@ -68,6 +70,7 @@ public class DefaultClientResponseTests {
@BeforeEach
public void createMocks ( ) {
mockResponse = mock ( ClientHttpResponse . class ) ;
given ( mockResponse . getHeaders ( ) ) . willReturn ( this . httpHeaders ) ;
mockExchangeStrategies = mock ( ExchangeStrategies . class ) ;
defaultClientResponse = new DefaultClientResponse ( mockResponse , mockExchangeStrategies , "" , "" , ( ) - > null ) ;
}
@ -91,7 +94,6 @@ public class DefaultClientResponseTests {
@@ -91,7 +94,6 @@ public class DefaultClientResponseTests {
@Test
public void header ( ) {
HttpHeaders httpHeaders = new HttpHeaders ( ) ;
long contentLength = 42L ;
httpHeaders . setContentLength ( contentLength ) ;
MediaType contentType = MediaType . TEXT_PLAIN ;
@ -233,7 +235,6 @@ public class DefaultClientResponseTests {
@@ -233,7 +235,6 @@ public class DefaultClientResponseTests {
= factory . wrap ( ByteBuffer . wrap ( "foo" . getBytes ( StandardCharsets . UTF_8 ) ) ) ;
Flux < DataBuffer > body = Flux . just ( dataBuffer ) ;
HttpHeaders httpHeaders = new HttpHeaders ( ) ;
httpHeaders . setContentType ( MediaType . TEXT_PLAIN ) ;
given ( mockResponse . getHeaders ( ) ) . willReturn ( httpHeaders ) ;
given ( mockResponse . getStatusCode ( ) ) . willThrow ( new IllegalArgumentException ( "999" ) ) ;
@ -293,13 +294,12 @@ public class DefaultClientResponseTests {
@@ -293,13 +294,12 @@ public class DefaultClientResponseTests {
}
@Test
public void toEntityListWithUnknownStatusCode ( ) throws Exception {
public void toEntityListWithUnknownStatusCode ( ) {
DefaultDataBufferFactory factory = new DefaultDataBufferFactory ( ) ;
DefaultDataBuffer dataBuffer =
factory . wrap ( ByteBuffer . wrap ( "foo" . getBytes ( StandardCharsets . UTF_8 ) ) ) ;
Flux < DataBuffer > body = Flux . just ( dataBuffer ) ;
HttpHeaders httpHeaders = new HttpHeaders ( ) ;
httpHeaders . setContentType ( MediaType . TEXT_PLAIN ) ;
given ( mockResponse . getHeaders ( ) ) . willReturn ( httpHeaders ) ;
given ( mockResponse . getStatusCode ( ) ) . willThrow ( new IllegalArgumentException ( "999" ) ) ;
@ -321,8 +321,7 @@ public class DefaultClientResponseTests {
@@ -321,8 +321,7 @@ public class DefaultClientResponseTests {
@Test
public void toEntityListTypeReference ( ) {
DefaultDataBufferFactory factory = new DefaultDataBufferFactory ( ) ;
DefaultDataBuffer dataBuffer =
factory . wrap ( ByteBuffer . wrap ( "foo" . getBytes ( StandardCharsets . UTF_8 ) ) ) ;
DefaultDataBuffer dataBuffer = factory . wrap ( ByteBuffer . wrap ( "foo" . getBytes ( StandardCharsets . UTF_8 ) ) ) ;
Flux < DataBuffer > body = Flux . just ( dataBuffer ) ;
mockTextPlainResponse ( body ) ;
@ -332,8 +331,7 @@ public class DefaultClientResponseTests {
@@ -332,8 +331,7 @@ public class DefaultClientResponseTests {
given ( mockExchangeStrategies . messageReaders ( ) ) . willReturn ( messageReaders ) ;
ResponseEntity < List < String > > result = defaultClientResponse . toEntityList (
new ParameterizedTypeReference < String > ( ) {
} ) . block ( ) ;
new ParameterizedTypeReference < String > ( ) { } ) . block ( ) ;
assertThat ( result . getBody ( ) ) . isEqualTo ( Collections . singletonList ( "foo" ) ) ;
assertThat ( result . getStatusCode ( ) ) . isEqualTo ( HttpStatus . OK ) ;
assertThat ( result . getStatusCodeValue ( ) ) . isEqualTo ( HttpStatus . OK . value ( ) ) ;
@ -342,9 +340,7 @@ public class DefaultClientResponseTests {
@@ -342,9 +340,7 @@ public class DefaultClientResponseTests {
private void mockTextPlainResponse ( Flux < DataBuffer > body ) {
HttpHeaders httpHeaders = new HttpHeaders ( ) ;
httpHeaders . setContentType ( MediaType . TEXT_PLAIN ) ;
given ( mockResponse . getHeaders ( ) ) . willReturn ( httpHeaders ) ;
given ( mockResponse . getStatusCode ( ) ) . willReturn ( HttpStatus . OK ) ;
given ( mockResponse . getRawStatusCode ( ) ) . willReturn ( HttpStatus . OK . value ( ) ) ;
given ( mockResponse . getBody ( ) ) . willReturn ( body ) ;