7474import static org .gridsuite .modification .server .impacts .TestImpactUtils .*;
7575import static org .gridsuite .modification .server .report .NetworkModificationServerReportResourceBundle .ERROR_MESSAGE_KEY ;
7676import static org .gridsuite .modification .server .utils .TestUtils .assertLogMessage ;
77+ import static org .gridsuite .modification .server .utils .TestUtils .runRequestAsync ;
7778import static org .gridsuite .modification .server .utils .assertions .Assertions .assertThat ;
7879import static org .junit .jupiter .api .Assertions .*;
7980import static org .mockito .ArgumentMatchers .*;
@@ -1034,14 +1035,7 @@ void testDuplicateModificationGroup() throws Exception {
10341035 MvcResult mvcResult ;
10351036 VoltageLevelCreationInfos vl1 = ModificationCreation .getCreationVoltageLevel ("s1" , "vl1Id" , "vl1Name" );
10361037 String bodyJson = getJsonBody (vl1 , TEST_NETWORK_BUS_BREAKER_ID , null );
1037- ResultActions mockMvcResultActions = mockMvc .perform (
1038- post (NETWORK_MODIFICATION_URI )
1039- .content (bodyJson )
1040- .contentType (MediaType .APPLICATION_JSON ))
1041- .andExpect (request ().asyncStarted ());
1042- mockMvc .perform (asyncDispatch (mockMvcResultActions .andReturn ()))
1043- .andExpect (status ().isOk ())
1044- .andReturn ().getResponse ().getContentAsString ();
1038+ runRequestAsync (mockMvc , post (NETWORK_MODIFICATION_URI ).content (bodyJson ).contentType (MediaType .APPLICATION_JSON ), status ().isOk ());
10451039
10461040 // create new line in voltage levels with node/breaker topology
10471041 // between voltage level "v1" and busbar section "bus1" and
@@ -1072,14 +1066,7 @@ void testDuplicateModificationGroup() throws Exception {
10721066 .build ();
10731067 bodyJson = getJsonBody (lineCreationInfos , TEST_NETWORK_BUS_BREAKER_ID , null );
10741068
1075- mockMvcResultActions = mockMvc .perform (
1076- post (NETWORK_MODIFICATION_URI )
1077- .content (bodyJson )
1078- .contentType (MediaType .APPLICATION_JSON ))
1079- .andExpect (request ().asyncStarted ());
1080- mvcResult = mockMvc .perform (asyncDispatch (mockMvcResultActions .andReturn ()))
1081- .andExpect (status ().isOk ())
1082- .andReturn ();
1069+ mvcResult = runRequestAsync (mockMvc , post (NETWORK_MODIFICATION_URI ).content (bodyJson ).contentType (MediaType .APPLICATION_JSON ), status ().isOk ());
10831070 assertApplicationStatusOK (mvcResult );
10841071 String resultAsString = mvcResult .getResponse ().getContentAsString ();
10851072 testBranchCreationImpacts (mapper , resultAsString , Set .of ("s1" , "s2" ));
@@ -1097,13 +1084,7 @@ void testDuplicateModificationGroup() throws Exception {
10971084 10.0 , "AttPointId" , "attPointName" , null , "v4" ,
10981085 "1.A" , attachmentLine , "nl1" , "NewLine1" , "nl2" , "NewLine2" );
10991086 String bodyJson2 = getJsonBody (lineAttachToVL , TEST_NETWORK_ID , NetworkCreation .VARIANT_ID );
1100- mockMvcResultActions = mockMvc .perform (
1101- post (NETWORK_MODIFICATION_URI )
1102- .content (bodyJson2 )
1103- .contentType (MediaType .APPLICATION_JSON ))
1104- .andExpect (request ().asyncStarted ());
1105- mvcResult = mockMvc .perform (asyncDispatch (mockMvcResultActions .andReturn ()))
1106- .andExpect (status ().isOk ()).andReturn ();
1087+ mvcResult = runRequestAsync (mockMvc , post (NETWORK_MODIFICATION_URI ).content (bodyJson2 ).contentType (MediaType .APPLICATION_JSON ), status ().isOk ());
11071088 assertApplicationStatusOK (mvcResult );
11081089
11091090 testNetworkModificationsCount (TEST_GROUP_ID , 3 );
@@ -1112,24 +1093,12 @@ void testDuplicateModificationGroup() throws Exception {
11121093 LineSplitWithVoltageLevelInfos lineSplitWoVL = new LineSplitWithVoltageLevelInfos ("line1" , 10.0 , null , "v4" , "1.A" ,
11131094 "nl11" , "NewLine11" , "nl12" , "NewLine12" );
11141095 bodyJson2 = getJsonBody (lineSplitWoVL , TEST_NETWORK_ID , NetworkCreation .VARIANT_ID );
1115- mockMvcResultActions = mockMvc .perform (
1116- post (NETWORK_MODIFICATION_URI )
1117- .content (bodyJson2 )
1118- .contentType (MediaType .APPLICATION_JSON ))
1119- .andExpect (request ().asyncStarted ());
1120- mvcResult = mockMvc .perform (asyncDispatch (mockMvcResultActions .andReturn ()))
1121- .andExpect (status ().isOk ()).andReturn ();
1096+ mvcResult = runRequestAsync (mockMvc , post (NETWORK_MODIFICATION_URI ).content (bodyJson2 ).contentType (MediaType .APPLICATION_JSON ), status ().isOk ());
11221097 assertApplicationStatusOK (mvcResult );
11231098 //create a generator
11241099 GeneratorCreationInfos generatorCreationInfos = ModificationCreation .getCreationGenerator ("v2" , "idGenerator1" , "nameGenerator1" , "1B" , "v2load" , "LOAD" , "v1" );
11251100 bodyJson2 = getJsonBody (generatorCreationInfos , TEST_NETWORK_ID , NetworkCreation .VARIANT_ID );
1126- mockMvcResultActions = mockMvc .perform (
1127- post (NETWORK_MODIFICATION_URI )
1128- .content (bodyJson2 )
1129- .contentType (MediaType .APPLICATION_JSON ))
1130- .andExpect (request ().asyncStarted ());
1131- mvcResult = mockMvc .perform (asyncDispatch (mockMvcResultActions .andReturn ()))
1132- .andExpect (status ().isOk ()).andReturn ();
1101+ mvcResult = runRequestAsync (mockMvc , post (NETWORK_MODIFICATION_URI ).content (bodyJson2 ).contentType (MediaType .APPLICATION_JSON ), status ().isOk ());
11331102 assertApplicationStatusOK (mvcResult );
11341103 testNetworkModificationsCount (TEST_GROUP_ID , 5 );
11351104
@@ -2031,19 +2000,13 @@ void testSearchModificationInfos() throws Exception {
20312000 .equipmentName (AttributeModification .toAttributeModification ("newSubstationName" , OperationType .SET ))
20322001 .build ();
20332002 String substationModificationInfosJson = getJsonBody (substationModificationInfos , TEST_NETWORK_ID , null );
2034- ResultActions mockMvcResultActions1 = mockMvc .perform (post (NETWORK_MODIFICATION_URI ).content (substationModificationInfosJson ).contentType (MediaType .APPLICATION_JSON ))
2035- .andExpect (request ().asyncStarted ());
2036- MvcResult mvcResult1 = mockMvc .perform (asyncDispatch (mockMvcResultActions1 .andReturn ()))
2037- .andExpect (status ().isOk ()).andReturn ();
2003+ MvcResult mvcResult1 = runRequestAsync (mockMvc , post (NETWORK_MODIFICATION_URI ).content (substationModificationInfosJson ).contentType (MediaType .APPLICATION_JSON ), status ().isOk ());
20382004 assertApplicationStatusOK (mvcResult1 );
20392005
20402006 // Generator Creation ID : v2
20412007 GeneratorCreationInfos generatorCreationInfos = ModificationCreation .getCreationGenerator ("v2" , "idGenerator1" , "nameGenerator1" , "1B" , "v2load" , "LOAD" , "v1" );
20422008 String generatorCreationInfosJson = getJsonBody (generatorCreationInfos , TEST_NETWORK_ID , null );
2043- ResultActions mockMvcResultActions2 = mockMvc .perform (post (NETWORK_MODIFICATION_URI ).content (generatorCreationInfosJson ).contentType (MediaType .APPLICATION_JSON ))
2044- .andExpect (request ().asyncStarted ());
2045- MvcResult mvcResult2 = mockMvc .perform (asyncDispatch (mockMvcResultActions2 .andReturn ()))
2046- .andExpect (status ().isOk ()).andReturn ();
2009+ MvcResult mvcResult2 = runRequestAsync (mockMvc , post (NETWORK_MODIFICATION_URI ).content (generatorCreationInfosJson ).contentType (MediaType .APPLICATION_JSON ), status ().isOk ());
20472010 assertNotNull (network .getGenerator ("idGenerator1" ));
20482011 assertApplicationStatusOK (mvcResult2 );
20492012
@@ -2053,11 +2016,7 @@ void testSearchModificationInfos() throws Exception {
20532016 .equipmentId ("v5load" )
20542017 .build ();
20552018 String equipmentDeletionInfosJson = getJsonBody (equipmentDeletionInfos , TEST_NETWORK_ID , null );
2056- ResultActions mockMvcResultActions3 = mockMvc .perform (post (NETWORK_MODIFICATION_URI ).content (equipmentDeletionInfosJson ).contentType (MediaType .APPLICATION_JSON ))
2057- .andExpect (request ().asyncStarted ());
2058- MvcResult mvcResult3 = mockMvc .perform (asyncDispatch (mockMvcResultActions3 .andReturn ())).andExpect (status ().isOk ()).andReturn ();
2059- assertApplicationStatusOK (mvcResult3 );
2060-
2019+ MvcResult mvcResult3 = runRequestAsync (mockMvc , post (NETWORK_MODIFICATION_URI ).content (equipmentDeletionInfosJson ).contentType (MediaType .APPLICATION_JSON ), status ().isOk ());
20612020 MvcResult mvcModificationResult ;
20622021 Map <UUID , List <ModificationsSearchResult >> networkModificationsResult ;
20632022 List <ModificationsSearchResult > modificationsSearchResult ;
0 commit comments