WIP: WebClient
authorKai Moritz <kai@jupl.de>
Thu, 21 Nov 2019 12:24:39 +0000 (13:24 +0100)
committerKai Moritz <kai@jupl.de>
Thu, 21 Nov 2019 12:24:39 +0000 (13:24 +0100)
src/main/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunction.java
src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java

index 0b583f4..53bdd0b 100644 (file)
@@ -1,6 +1,8 @@
 package de.juplo.facebook.errors;
 
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.reactive.function.client.ClientRequest;
 import org.springframework.web.reactive.function.client.ClientResponse;
@@ -15,6 +17,9 @@ import reactor.core.publisher.Mono;
  */
 public class GraphApiExchangeFilterFunction implements ExchangeFilterFunction
 {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(GraphApiExchangeFilterFunction.class);
+
   public static GraphApiExchangeFilterFunction INSTANCE =
       new GraphApiExchangeFilterFunction();
 
@@ -23,14 +28,15 @@ public class GraphApiExchangeFilterFunction implements ExchangeFilterFunction
   public Mono<ClientResponse> filter(ClientRequest request, ExchangeFunction next)
   {
     return
-    next
-        .exchange(request)
-        .flatMap(response ->
-        {
-          return
-              HttpStatus.Series.CLIENT_ERROR.equals(response.statusCode().series())
-                  ? Mono.error(GraphApiException.create(response))
-                  : Mono.just(response);
-        });
+        next
+            .exchange(request)
+            .doOnError(e -> LOG.debug("ERROR: {}", e))
+            .flatMap(response ->
+            {
+              return
+                  HttpStatus.Series.CLIENT_ERROR.equals(response.statusCode().series())
+                      ? Mono.error(GraphApiException.create(response))
+                      : Mono.just(response);
+            });
   }
 }
index 2e3ae22..2c94a49 100644 (file)
@@ -87,6 +87,6 @@ public class GraphApiExchangeFilterFunctionIntegrationTest
           assertEquals("(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.", e.getMessage());
           assertEquals(Type.OAuthException, e.getType());
         })
-        .verifyLater();
+        .verify(Duration.ofSeconds(3));
   }
 }