From 702cc4855fdf07c3c2aad5d90cb98d5ab8b84384 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 21 Nov 2019 14:47:29 +0100 Subject: [PATCH] WIP: TMP - WebClient --- ...ExchangeFilterFunctionIntegrationTest.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java index 408ec48..b148d23 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java @@ -103,25 +103,43 @@ public class GraphApiExchangeFilterFunctionIntegrationTest .filter((request, next) -> next.exchange(request).flatMap(response -> { List headerValues = response.headers().header("Foo"); - return headerValues.isEmpty() ? Mono.error( - new Exception("Response does not contain Foo header")) : + return headerValues.isEmpty() ? Mono.error(GraphApiException.create(response)) : Mono.just(response); })) .build(); server .enqueue(new MockResponse() - .setResponseCode(400) + .setResponseCode(200) .setHeader("Content-Type", "text/plain") .setBody("Hello Spring!")); - Mono result = webClient.get() + Mono result; + + result = webClient.get() .uri("/greeting?name=Spring") .retrieve() .bodyToMono(String.class); StepVerifier.create(result) .expectError(Exception.class) + .verify(Duration.ofSeconds(90)); + + server + .enqueue(new MockResponse() + .setResponseCode(200) + .setHeader("Content-Type", "text/plain") + .setHeader("Foo", "Bar") + .setBody("Hello Spring!")); + + result = webClient.get() + .uri("/greeting?name=Spring") + .retrieve() + .bodyToMono(String.class); + + StepVerifier.create(result) + .expectNext("Hello Spring!") + .expectComplete() .verify(Duration.ofSeconds(3)); } } -- 2.20.1