added more common exchangeToMono example for article

This commit is contained in:
Gerardo Roza 2021-01-26 17:41:44 -03:00
parent d87cd065aa
commit 32f3528575
1 changed files with 12 additions and 2 deletions

View File

@ -115,8 +115,18 @@ public class WebClientIntegrationTest {
.bodyToMono(String.class);
Mono<String> responsePostWithBody2 = headerSpecPost2.retrieve()
.bodyToMono(String.class);
Mono<String> responsePostWithBody3 = headerSpecPost3.retrieve()
.bodyToMono(String.class);
Mono<String> responsePostWithBody3 = headerSpecPost3.exchangeToMono(response -> {
if (response.statusCode()
.equals(HttpStatus.OK)) {
return response.bodyToMono(String.class);
} else if (response.statusCode()
.is4xxClientError()) {
return Mono.just("Error response");
} else {
return response.createException()
.flatMap(Mono::error);
}
});
Mono<String> responsePostFoo = headerSpecFooPost.retrieve()
.bodyToMono(String.class);
ParameterizedTypeReference<Map<String, String>> ref = new ParameterizedTypeReference<Map<String, String>>() {