WIP: TMP - WebClient
authorKai Moritz <kai@jupl.de>
Thu, 21 Nov 2019 13:47:29 +0000 (14:47 +0100)
committerKai Moritz <kai@jupl.de>
Thu, 21 Nov 2019 13:47:29 +0000 (14:47 +0100)
src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java

index 408ec48..b148d23 100644 (file)
@@ -103,25 +103,43 @@ public class GraphApiExchangeFilterFunctionIntegrationTest
             .filter((request, next) -> next.exchange(request).flatMap(response ->
             {
                                                        List<String> 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<String> result = webClient.get()
+               Mono<String> 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));
   }
 }