File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
http-client/src/main/java/io/avaje/http/client Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1010/**
1111 * Async processing of the request with responses as CompletableFuture.
1212 *
13+ * <h4>Testing and .join()</h4>
14+ * <p>
15+ * Note that when testing with async requests we frequently use {@code .join()}
16+ * on the {@code CompletableFuture} such that the main thread waits for the async
17+ * processing to complete. After that various asserts can run knowing that the
18+ * async callback code has been executed.
19+ *
20+ * <h4>Example using .join() for testing purposes</h4>
21+ * <pre>{@code
22+ *
23+ * client.request()
24+ * ...
25+ * .POST().async()
26+ * .bean(HelloDto.class)
27+ * .whenComplete((helloDto, throwable) -> {
28+ * ...
29+ * }).join(); // wait for async processing to complete
30+ *
31+ * // can assert now ...
32+ * assertThat(...)
33+ *
34+ * }</pre>
35+ *
1336 * <h4>Example async().bean()</h4>
1437 * <p>
1538 * In this example POST async that will return a bean converted from json response.
You can’t perform that action at this time.
0 commit comments