From 70a37345037a4ac678c8047cd8cb54727635e5f5 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 21 Nov 2019 21:00:42 +0100 Subject: [PATCH] WIP: WebClient -- Syntax angeglichen --- ...ExchangeFilterFunctionIntegrationTest.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java index a9ba58c..27795f9 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java @@ -133,21 +133,18 @@ public class GraphApiExchangeFilterFunctionIntegrationTest public Mono 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); - } - }); } } -- 2.20.1