WIP: WebClient -- Syntax angeglichen
authorKai Moritz <kai@jupl.de>
Thu, 21 Nov 2019 20:00:42 +0000 (21:00 +0100)
committerKai Moritz <kai@jupl.de>
Thu, 21 Nov 2019 20:00:42 +0000 (21:00 +0100)
src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java

index a9ba58c..27795f9 100644 (file)
@@ -133,21 +133,18 @@ public class GraphApiExchangeFilterFunctionIntegrationTest
 
   public Mono<ClientResponse> errorHandlingFilter(ClientRequest request, ExchangeFunction next)
   {
-    return next.exchange(request).flatMap(response ->
-    {
-      if (response.statusCode() != null && (response.statusCode()
-          .is5xxServerError() || response.statusCode().is4xxClientError()))
-      {
-        return response.bodyToMono(String.class)
-            .flatMap(errorBody ->
+    return
+        next
+            .exchange(request)
+            .flatMap(response ->
             {
-              return Mono.error(GraphApiException.create(response.statusCode(), response.headers().asHttpHeaders(), errorBody.getBytes()));
+              return
+                  HttpStatus.Series.CLIENT_ERROR.equals(response.statusCode().series())
+                      ? response.bodyToMono(String.class).flatMap(errorBody ->
+                        {
+                          return Mono.error(GraphApiException.create(response.statusCode(), response.headers().asHttpHeaders(), errorBody.getBytes()));
+                        })
+                      : Mono.just(response);
             });
-      }
-      else
-      {
-        return Mono.just(response);
-      }
-    });
   }
 }