|
46 | 46 | import org.gridsuite.study.server.service.*;
|
47 | 47 | import org.gridsuite.study.server.service.client.dynamicsecurityanalysis.DynamicSecurityAnalysisClient;
|
48 | 48 | import org.gridsuite.study.server.service.client.dynamicsimulation.DynamicSimulationClient;
|
49 |
| -import org.gridsuite.study.server.service.LoadFlowService; |
50 | 49 | import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService;
|
51 | 50 | import org.gridsuite.study.server.utils.*;
|
52 | 51 | import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch;
|
|
58 | 57 | import org.junit.jupiter.api.extension.ExtendWith;
|
59 | 58 | import org.junit.jupiter.params.ParameterizedTest;
|
60 | 59 | import org.junit.jupiter.params.provider.EnumSource;
|
| 60 | +import org.mockito.stubbing.Answer; |
61 | 61 | import org.slf4j.Logger;
|
62 | 62 | import org.slf4j.LoggerFactory;
|
63 | 63 | import org.springframework.beans.factory.annotation.Autowired;
|
|
76 | 76 | import org.springframework.test.web.servlet.MvcResult;
|
77 | 77 |
|
78 | 78 | import java.util.*;
|
| 79 | +import java.util.concurrent.CompletableFuture; |
79 | 80 |
|
80 | 81 | import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
|
81 | 82 | import static org.gridsuite.study.server.StudyConstants.HEADER_ERROR_MESSAGE;
|
|
86 | 87 | import static org.gridsuite.study.server.utils.SendInput.POST_ACTION_SEND_INPUT;
|
87 | 88 | import static org.hamcrest.MatcherAssert.assertThat;
|
88 | 89 | import static org.junit.jupiter.api.Assertions.*;
|
| 90 | +import static org.mockito.ArgumentMatchers.any; |
89 | 91 | import static org.mockito.Mockito.doReturn;
|
90 | 92 | import static org.mockito.Mockito.when;
|
91 | 93 | import static org.springframework.http.MediaType.APPLICATION_JSON;
|
@@ -234,6 +236,9 @@ class NetworkModificationTest {
|
234 | 236 | @Autowired
|
235 | 237 | private TestUtils studyTestUtils;
|
236 | 238 |
|
| 239 | + @SpyBean |
| 240 | + private StudyServerExecutionService studyServerExecutionService; |
| 241 | + |
237 | 242 | @Autowired
|
238 | 243 | private ObjectMapper objectMapper;
|
239 | 244 |
|
@@ -261,6 +266,12 @@ void setup(final MockWebServer server) {
|
261 | 266 |
|
262 | 267 | when(networkStoreService.getNetwork(NETWORK_UUID)).thenReturn(network);
|
263 | 268 |
|
| 269 | + // Synchronize for tests |
| 270 | + when(studyServerExecutionService.runAsyncAndComplete(any(Runnable.class))).thenAnswer((Answer<CompletableFuture>) invocation -> { |
| 271 | + ((Runnable) invocation.getArguments()[0]).run(); |
| 272 | + return CompletableFuture.completedFuture(null); |
| 273 | + }); |
| 274 | + |
264 | 275 | wireMockServer = new WireMockServer(wireMockConfig().dynamicPort().extensions(new SendInput(input)));
|
265 | 276 | wireMockUtils = new WireMockUtils(wireMockServer);
|
266 | 277 |
|
|
0 commit comments