9
9
import com .fasterxml .jackson .databind .ObjectMapper ;
10
10
import com .powsybl .commons .PowsyblException ;
11
11
import com .powsybl .computation .CompletableFutureTask ;
12
+ import com .powsybl .computation .ComputationManager ;
12
13
import com .powsybl .iidm .modification .GeneratorModification ;
13
14
import com .powsybl .iidm .modification .ShuntCompensatorModification ;
14
15
import com .powsybl .iidm .modification .StaticVarCompensatorModification ;
20
21
import com .powsybl .network .store .client .NetworkStoreService ;
21
22
import com .powsybl .network .store .client .PreloadingStrategy ;
22
23
import com .powsybl .network .store .iidm .impl .NetworkFactoryImpl ;
24
+ import com .powsybl .openreac .OpenReacConfig ;
25
+ import com .powsybl .openreac .OpenReacRunner ;
23
26
import com .powsybl .openreac .parameters .OpenReacAmplIOFiles ;
24
- import com .powsybl .openreac .parameters .input .* ;
27
+ import com .powsybl .openreac .parameters .input .OpenReacParameters ;
25
28
import com .powsybl .openreac .parameters .output .OpenReacResult ;
26
29
import com .powsybl .openreac .parameters .output .OpenReacStatus ;
27
30
import lombok .SneakyThrows ;
67
70
import java .util .Map ;
68
71
import java .util .Objects ;
69
72
import java .util .UUID ;
70
- import java .util .concurrent .Callable ;
71
- import java .util .concurrent .Executor ;
72
73
import java .util .concurrent .ForkJoinPool ;
73
74
74
75
import static com .powsybl .network .store .model .NetworkStoreApi .VERSION ;
75
- import static org .gridsuite .voltageinit .server .service .NotificationService .HEADER_USER_ID ;
76
76
import static org .gridsuite .voltageinit .server .service .NotificationService .CANCEL_MESSAGE ;
77
- import static org .junit .Assert .*;
77
+ import static org .gridsuite .voltageinit .server .service .NotificationService .HEADER_USER_ID ;
78
+ import static org .junit .Assert .assertEquals ;
79
+ import static org .junit .Assert .assertNotNull ;
78
80
import static org .mockito .ArgumentMatchers .any ;
81
+ import static org .mockito .ArgumentMatchers .eq ;
79
82
import static org .mockito .BDDMockito .given ;
80
83
import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .*;
81
84
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .content ;
@@ -95,8 +98,6 @@ public class VoltageInitControllerTest {
95
98
private static final UUID RESULT_UUID = UUID .fromString ("0c8de370-3e6c-4d72-b292-d355a97e0d5d" );
96
99
private static final UUID REPORT_UUID = UUID .fromString ("0c4de370-3e6a-4d72-b292-d355a97e0d53" );
97
100
private static final UUID OTHER_RESULT_UUID = UUID .fromString ("0c8de370-3e6c-4d72-b292-d355a97e0d5a" );
98
- private static final UUID NETWORK_FOR_MERGING_VIEW_UUID = UUID .fromString ("11111111-7977-4592-ba19-88027e4254e4" );
99
- private static final UUID OTHER_NETWORK_FOR_MERGING_VIEW_UUID = UUID .fromString ("22222222-7977-4592-ba19-88027e4254e4" );
100
101
private static final Map <String , String > INDICATORS = Map .of ("defaultPmax" , "1000.000000" , "defaultQmax" , "300.000000" , "minimalQPrange" , "1.000000" );
101
102
private static final UUID MODIFICATIONS_GROUP_UUID = UUID .fromString ("33333333-aaaa-bbbb-cccc-dddddddddddd" );
102
103
private static final String FILTER_EQUIPMENT_JSON = "[{\" filterId\" :\" cf399ef3-7f14-4884-8c82-1c90300da329\" ,\" identifiableAttributes\" :[{\" id\" :\" VL1\" ,\" type\" :\" VOLTAGE_LEVEL\" }],\" notFoundEquipments\" :[]}]" ;
@@ -220,12 +221,6 @@ public void setUp() throws Exception {
220
221
given (networkStoreService .getNetwork (NETWORK_UUID , PreloadingStrategy .COLLECTION )).willReturn (network );
221
222
given (networkStoreService .getNetwork (OTHER_NETWORK_UUID , PreloadingStrategy .ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW )).willThrow (new PowsyblException ("Not found" ));
222
223
223
- networkForMergingView = new NetworkFactoryImpl ().createNetwork ("mergingView" , "test" );
224
- given (networkStoreService .getNetwork (NETWORK_FOR_MERGING_VIEW_UUID , PreloadingStrategy .ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW )).willReturn (networkForMergingView );
225
-
226
- otherNetworkForMergingView = new NetworkFactoryImpl ().createNetwork ("other" , "test 2" );
227
- given (networkStoreService .getNetwork (OTHER_NETWORK_FOR_MERGING_VIEW_UUID , PreloadingStrategy .ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW )).willReturn (otherNetworkForMergingView );
228
-
229
224
network1 = EurostagTutorialExample1Factory .createWithMoreGenerators (new NetworkFactoryImpl ());
230
225
network1 .getVariantManager ().cloneVariant (VariantManagerConstants .INITIAL_VARIANT_ID , VARIANT_2_ID );
231
226
@@ -282,8 +277,8 @@ public void tearDown() {
282
277
283
278
@ Test
284
279
public void runTest () throws Exception {
285
- try (MockedStatic <CompletableFutureTask > openReacRunnerMockedStatic = Mockito .mockStatic (CompletableFutureTask .class )) {
286
- openReacRunnerMockedStatic .when (() -> CompletableFutureTask .runAsync (any (Callable .class ), any (Executor .class )))
280
+ try (MockedStatic <OpenReacRunner > openReacRunnerMockedStatic = Mockito .mockStatic (OpenReacRunner .class )) {
281
+ openReacRunnerMockedStatic .when (() -> OpenReacRunner .runAsync (eq ( network ), eq ( VARIANT_2_ID ), any (OpenReacParameters .class ), any (OpenReacConfig . class ), any ( ComputationManager .class )))
287
282
.thenReturn (completableFutureResultsTask );
288
283
289
284
MvcResult result = mockMvc .perform (post (
@@ -366,8 +361,6 @@ public void runWrongNetworkTest() throws Exception {
366
361
367
362
@ Test
368
363
public void runWithReportTest () throws Exception {
369
- String resultAsString ;
370
-
371
364
MvcResult result = mockMvc .perform (post (
372
365
"/" + VERSION + "/networks/{networkUuid}/run-and-save?receiver=me&variantId={variantId}&reportType=VoltageInit&reportUuid=" + REPORT_UUID + "&reporterId=" + UUID .randomUUID (), NETWORK_UUID , VARIANT_2_ID )
373
366
.header (HEADER_USER_ID , "userId" ))
@@ -378,8 +371,8 @@ public void runWithReportTest() throws Exception {
378
371
379
372
@ Test
380
373
public void stopTest () throws Exception {
381
- try (MockedStatic <CompletableFutureTask > openReacRunnerMockedStatic = Mockito .mockStatic (CompletableFutureTask .class )) {
382
- openReacRunnerMockedStatic .when (() -> CompletableFutureTask .runAsync (any (Callable .class ), any (Executor .class )))
374
+ try (MockedStatic <OpenReacRunner > openReacRunnerMockedStatic = Mockito .mockStatic (OpenReacRunner .class )) {
375
+ openReacRunnerMockedStatic .when (() -> OpenReacRunner .runAsync (eq ( network ), eq ( VARIANT_2_ID ), any (OpenReacParameters .class ), any (OpenReacConfig . class ), any ( ComputationManager .class )))
383
376
.thenReturn (completableFutureResultsTask );
384
377
385
378
mockMvc .perform (post (
@@ -403,24 +396,6 @@ public void stopTest() throws Exception {
403
396
}
404
397
}
405
398
406
- @ SneakyThrows
407
- @ Test
408
- public void mergingViewTest () {
409
- try (MockedStatic <CompletableFutureTask > openReacRunnerMockedStatic = Mockito .mockStatic (CompletableFutureTask .class )) {
410
- openReacRunnerMockedStatic .when (() -> CompletableFutureTask .runAsync (any (Callable .class ), any (Executor .class )))
411
- .thenReturn (completableFutureResultsTask );
412
-
413
- MvcResult result = mockMvc .perform (post (
414
- "/" + VERSION + "/networks/{networkUuid}/run-and-save?receiver=me&networkUuid=" + NETWORK_FOR_MERGING_VIEW_UUID , OTHER_NETWORK_FOR_MERGING_VIEW_UUID )
415
- .header (HEADER_USER_ID , "userId" ))
416
- .andExpect (status ().isOk ())
417
- .andExpect (content ().contentType (MediaType .APPLICATION_JSON ))
418
- .andReturn ();
419
-
420
- assertEquals (RESULT_UUID , mapper .readValue (result .getResponse ().getContentAsString (), UUID .class ));
421
- }
422
- }
423
-
424
399
@ SneakyThrows
425
400
@ Test
426
401
public void getStatusTest () {
0 commit comments