From 4acf224790e323a0cd87f1005252a4b074189246 Mon Sep 17 00:00:00 2001 From: David Turanski Date: Thu, 13 Aug 2020 15:01:31 -0400 Subject: [PATCH] Wait for data --- applications/processor/http-request-processor/README.adoc | 5 +++-- functions/consumer/mongodb-consumer/pom.xml | 5 +++++ .../fn/consumer/mongo/MongoDbConsumerApplicationTests.java | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/applications/processor/http-request-processor/README.adoc b/applications/processor/http-request-processor/README.adoc index 6687e745..f35708aa 100644 --- a/applications/processor/http-request-processor/README.adoc +++ b/applications/processor/http-request-processor/README.adoc @@ -46,8 +46,9 @@ The **$$http-request$$** $$processor$$ has the following options: $$http.request.body-expression$$:: $$A SpEL expression to derive the request body from the incoming message.$$ *($$Expression$$, default: `$$$$`)* $$http.request.expected-response-type$$:: $$The type used to interpret the response.$$ *($$Class$$, default: `$$$$`)* $$http.request.headers-expression$$:: $$A SpEL expression used to derive the http headers map to use.$$ *($$Expression$$, default: `$$$$`)* -$$http.request.http-method-expression$$:: $$A SpEL expression to derive the request method from the incoming message.$$ *($$Expression$$, default: `$$'GET'$$`)* -$$http.request.reply-expression$$:: $$A SpEL expression used to compute the final result, applied against the whole http {@link org.springframework.http.ResponseEntity}.$$ *($$Expression$$, default: `$$body$$`)* +$$http.request.http-method-expression$$:: $$A SpEL expression to derive the request method from the incoming message.$$ *($$Expression$$, default: `$$$$`)* +$$http.request.maximum-buffer-size$$:: $$Maximum buffer size in bytes allocated for input stream buffers. Defaults to 256k. Increase, as necessary, for posting or getting large binary content.$$ *($$Integer$$, default: `$$0$$`)* +$$http.request.reply-expression$$:: $$A SpEL expression used to compute the final result, applied against the whole http {@link org.springframework.http.ResponseEntity}.$$ *($$Expression$$, default: `$$$$`)* $$http.request.timeout$$:: $$Request timeout in milliseconds.$$ *($$Long$$, default: `$$30000$$`)* $$http.request.url-expression$$:: $$A SpEL expression against incoming message to determine the URL to use.$$ *($$Expression$$, default: `$$$$`)* //end::configuration-properties[] diff --git a/functions/consumer/mongodb-consumer/pom.xml b/functions/consumer/mongodb-consumer/pom.xml index 2799602e..0ab63380 100644 --- a/functions/consumer/mongodb-consumer/pom.xml +++ b/functions/consumer/mongodb-consumer/pom.xml @@ -48,6 +48,11 @@ de.flapdoodle.embed.mongo test + + org.awaitility + awaitility + test + org.springframework.boot spring-boot-configuration-processor diff --git a/functions/consumer/mongodb-consumer/src/test/java/org/springframework/cloud/fn/consumer/mongo/MongoDbConsumerApplicationTests.java b/functions/consumer/mongodb-consumer/src/test/java/org/springframework/cloud/fn/consumer/mongo/MongoDbConsumerApplicationTests.java index 421ec335..b667203b 100644 --- a/functions/consumer/mongodb-consumer/src/test/java/org/springframework/cloud/fn/consumer/mongo/MongoDbConsumerApplicationTests.java +++ b/functions/consumer/mongodb-consumer/src/test/java/org/springframework/cloud/fn/consumer/mongo/MongoDbConsumerApplicationTests.java @@ -35,6 +35,7 @@ import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; /** * @author David Turanski @@ -70,7 +71,11 @@ class MongoDbConsumerApplicationTests { messages.map(message -> { mongodbConsumer.accept(message); return message; - }).blockLast(Duration.ofSeconds(30)); + + }).subscribe(); + + await().timeout(Duration.ofSeconds(10)) + .until(() -> mongoTemplate.findAll(Document.class, properties.getCollection()).count().block() == 3L); StepVerifier.create(this.mongoTemplate.findAll(Document.class, properties.getCollection()) .sort(Comparator.comparing(d -> d.get("_id").toString())))