|
36 | 36 | import java.util.HashMap; |
37 | 37 | import java.util.List; |
38 | 38 | import java.util.Map; |
| 39 | +import java.util.concurrent.atomic.AtomicReference; |
39 | 40 | import java.util.function.Supplier; |
40 | 41 |
|
41 | 42 | import static java.util.Collections.emptyList; |
@@ -229,11 +230,14 @@ private void awaitCallApi(String apiName, |
229 | 230 | CheckedFunction<ClientYamlTestResponse, Boolean, IOException> success, |
230 | 231 | Supplier<String> error) { |
231 | 232 | try { |
232 | | - // The actual method call that sends the API requests returns a Future, but we immediately |
233 | | - // call .get() on it so there's no need for this method to do any other awaiting. |
234 | | - ClientYamlTestResponse response = callApi(apiName, params, bodies, getApiCallHeaders()); |
235 | | - assertEquals(response.getStatusCode(), HttpStatus.SC_OK); |
236 | | - success.apply(response); |
| 233 | + final AtomicReference<ClientYamlTestResponse> response = new AtomicReference<>(); |
| 234 | + assertBusy(() -> { |
| 235 | + // The actual method call that sends the API requests returns a Future, but we immediately |
| 236 | + // call .get() on it so there's no need for this method to do any other awaiting. |
| 237 | + response.set(callApi(apiName, params, bodies, getApiCallHeaders())); |
| 238 | + assertEquals(HttpStatus.SC_OK, response.get().getStatusCode()); |
| 239 | + }); |
| 240 | + success.apply(response.get()); |
237 | 241 | } catch (Exception e) { |
238 | 242 | throw new IllegalStateException(error.get(), e); |
239 | 243 | } |
|
0 commit comments