|
39 | 39 | import java.util.HashMap; |
40 | 40 | import java.util.List; |
41 | 41 | import java.util.Map; |
| 42 | +import java.util.concurrent.atomic.AtomicReference; |
42 | 43 | import java.util.function.Supplier; |
43 | 44 |
|
44 | 45 | import static java.util.Collections.emptyList; |
@@ -284,11 +285,14 @@ private void awaitCallApi(String apiName, |
284 | 285 | CheckedFunction<ClientYamlTestResponse, Boolean, IOException> success, |
285 | 286 | Supplier<String> error) { |
286 | 287 | try { |
287 | | - // The actual method call that sends the API requests returns a Future, but we immediately |
288 | | - // call .get() on it so there's no need for this method to do any other awaiting. |
289 | | - ClientYamlTestResponse response = callApi(apiName, params, bodies, getApiCallHeaders()); |
290 | | - assertEquals(response.getStatusCode(), HttpStatus.SC_OK); |
291 | | - success.apply(response); |
| 288 | + final AtomicReference<ClientYamlTestResponse> response = new AtomicReference<>(); |
| 289 | + assertBusy(() -> { |
| 290 | + // The actual method call that sends the API requests returns a Future, but we immediately |
| 291 | + // call .get() on it so there's no need for this method to do any other awaiting. |
| 292 | + response.set(callApi(apiName, params, bodies, getApiCallHeaders())); |
| 293 | + assertEquals(HttpStatus.SC_OK, response.get().getStatusCode()); |
| 294 | + }); |
| 295 | + success.apply(response.get()); |
292 | 296 | } catch (Exception e) { |
293 | 297 | throw new IllegalStateException(error.get(), e); |
294 | 298 | } |
|
0 commit comments