From 0910e04bdf1028a820e63e9ba1564b0822ff7215 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Mon, 2 Jul 2018 10:00:06 -0500 Subject: [PATCH] MockExchangeFunction Support Multiple Requests Issue: gh-5386 --- .../function/client/MockExchangeFunction.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/MockExchangeFunction.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/MockExchangeFunction.java index a6cf3b4183..681d672b60 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/MockExchangeFunction.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/reactive/function/client/MockExchangeFunction.java @@ -24,23 +24,31 @@ import org.springframework.web.reactive.function.client.ExchangeFunction; import reactor.core.publisher.Mono; +import java.util.ArrayList; +import java.util.List; + /** * @author Rob Winch * @since 5.1 */ public class MockExchangeFunction implements ExchangeFunction { - private ClientRequest request; + private List requests = new ArrayList<>(); private ClientResponse response = mock(ClientResponse.class); public ClientRequest getRequest() { - return this.request; + return this.requests.get(this.requests.size() - 1); + } + + public List getRequests() { + return this.requests; + } } @Override public Mono exchange(ClientRequest request) { return Mono.defer(() -> { - this.request = request; + this.requests.add(request); return Mono.just(this.response); }); }