99
1010import com .powsybl .iidm .network .Network ;
1111import com .powsybl .iidm .network .ShuntCompensatorLinearModel ;
12+ import com .powsybl .iidm .network .VoltageLevel ;
13+ import com .powsybl .iidm .network .extensions .ConnectablePosition ;
1214import lombok .SneakyThrows ;
1315import org .gridsuite .modification .server .NetworkModificationException ;
1416import org .gridsuite .modification .server .dto .*;
2022
2123import static org .gridsuite .modification .server .NetworkModificationException .Type .SHUNT_COMPENSATOR_NOT_FOUND ;
2224import static org .gridsuite .modification .server .NetworkModificationException .Type .VOLTAGE_LEVEL_NOT_FOUND ;
25+ import static org .gridsuite .modification .server .utils .NetworkUtil .createShuntCompensator ;
2326import static org .gridsuite .modification .server .utils .TestUtils .assertLogMessage ;
2427import static org .junit .Assert .assertEquals ;
2528import static org .junit .Assert .assertNotNull ;
@@ -67,14 +70,35 @@ public void testWrongVoltageLevelId() {
6770
6871 @ SneakyThrows
6972 @ Test
70- public void testCreateModificationWithShuntCompensatorType () {
73+ public void testShuntCompensatorWithMultipleSections () {
7174 var shuntCompensator = getNetwork ().getShuntCompensator ("v5shunt" );
75+
76+ ShuntCompensatorModificationInfos modificationInfos = ShuntCompensatorModificationInfos .builder ()
77+ .equipmentId ("v5shunt" )
78+ .voltageLevelId ("v5" )
79+ .shuntCompensatorType (new AttributeModification <>(ShuntCompensatorType .REACTOR , OperationType .SET ))
80+ .build ();
81+
82+ mockMvc .perform (post (getNetworkModificationUri ()).content (mapper .writeValueAsString (modificationInfos )).contentType (MediaType .APPLICATION_JSON ))
83+ .andExpect (status ().isOk ());
84+
85+ assertLogMessage ("It is currently not possible to modify the multi sections shunt compensator with id=v5shunt" ,
86+ "shuntCompensatorModificationMultiSections" , reportService );
87+ }
88+
89+ @ SneakyThrows
90+ @ Test
91+ public void testCreateModificationWithShuntCompensatorType () {
92+ VoltageLevel v5 = getNetwork ().getVoltageLevel ("v5" );
93+ createShuntCompensator (v5 , "v7shunt" , "v7shunt" , 6 , 225. , 10 , true , 1 , 1 , 2 , 1 , "feeder_v7shunt" , 40 , ConnectablePosition .Direction .BOTTOM );
94+
95+ var shuntCompensator = getNetwork ().getShuntCompensator ("v7shunt" );
7296 var model = shuntCompensator .getModel (ShuntCompensatorLinearModel .class );
7397 assertNotNull (model );
7498
7599 assertEquals (1.0 , model .getBPerSection (), 0 );
76100 ShuntCompensatorModificationInfos modificationInfos = ShuntCompensatorModificationInfos .builder ()
77- .equipmentId ("v5shunt " )
101+ .equipmentId ("v7shunt " )
78102 .voltageLevelId ("v5" )
79103 .shuntCompensatorType (new AttributeModification <>(ShuntCompensatorType .REACTOR , OperationType .SET ))
80104 .build ();
@@ -88,13 +112,16 @@ public void testCreateModificationWithShuntCompensatorType() {
88112 @ SneakyThrows
89113 @ Test
90114 public void testCreateModificationWithSusceptancePerSection () {
91- var shuntCompensator = getNetwork ().getShuntCompensator ("v5shunt" );
115+ VoltageLevel v5 = getNetwork ().getVoltageLevel ("v5" );
116+ createShuntCompensator (v5 , "v7shunt" , "v7shunt" , 6 , 225. , 10 , true , 1 , 1 , 2 , 0 , "feeder_v7shunt" , 40 , ConnectablePosition .Direction .BOTTOM );
117+
118+ var shuntCompensator = getNetwork ().getShuntCompensator ("v7shunt" );
92119 var model = shuntCompensator .getModel (ShuntCompensatorLinearModel .class );
93120 assertNotNull (model );
94121
95122 assertEquals (1.0 , model .getBPerSection (), 0 );
96123 ShuntCompensatorModificationInfos modificationInfos = ShuntCompensatorModificationInfos .builder ()
97- .equipmentId ("v5shunt " )
124+ .equipmentId ("v7shunt " )
98125 .voltageLevelId ("v5" )
99126 .susceptancePerSection (AttributeModification .toAttributeModification (3.0 , OperationType .SET ))
100127 .build ();
@@ -103,20 +130,26 @@ public void testCreateModificationWithSusceptancePerSection() {
103130 .andExpect (status ().isOk ());
104131
105132 assertEquals (3.0 , model .getBPerSection (), 0 );
133+ assertEquals (1 , shuntCompensator .getSectionCount ());
106134 }
107135
108136 @ SneakyThrows
109137 @ Test
110138 public void testCreateModificationWithQAtNominalV () {
139+ VoltageLevel v5 = getNetwork ().getVoltageLevel ("v5" );
140+ createShuntCompensator (v5 , "v7shunt" , "v7shunt" , 6 , 225. , 10 , true , 1 , 1 , 2 , 1 , "feeder_v7shunt" , 40 , ConnectablePosition .Direction .BOTTOM );
141+ VoltageLevel v6 = getNetwork ().getVoltageLevel ("v6" );
142+ createShuntCompensator (v6 , "v8shunt" , "v8shunt" , 6 , 225. , 10 , true , 1 , 1 , 2 , 1 , "feeder_v8shunt" , 50 , ConnectablePosition .Direction .BOTTOM );
143+
111144 ShuntCompensatorModificationInfos modificationInfos1 = ShuntCompensatorModificationInfos .builder ()
112- .equipmentId ("v5shunt " )
145+ .equipmentId ("v7shunt " )
113146 .voltageLevelId ("v5" )
114147 .qAtNominalV (new AttributeModification <>(30.5 , OperationType .SET ))
115148 .shuntCompensatorType (new AttributeModification <>(ShuntCompensatorType .REACTOR , OperationType .SET ))
116149 .build ();
117150
118151 ShuntCompensatorModificationInfos modificationInfos2 = ShuntCompensatorModificationInfos .builder ()
119- .equipmentId ("v6shunt " )
152+ .equipmentId ("v8shunt " )
120153 .voltageLevelId ("v6" )
121154 .qAtNominalV (new AttributeModification <>(30.5 , OperationType .SET ))
122155 .shuntCompensatorType (new AttributeModification <>(ShuntCompensatorType .CAPACITOR , OperationType .SET ))
@@ -128,21 +161,24 @@ public void testCreateModificationWithQAtNominalV() {
128161 mockMvc .perform (post (getNetworkModificationUri ()).content (mapper .writeValueAsString (modificationInfos2 )).contentType (MediaType .APPLICATION_JSON ))
129162 .andExpect (status ().isOk ());
130163
131- var shuntCompensator1 = getNetwork ().getShuntCompensator ("v5shunt " );
164+ var shuntCompensator1 = getNetwork ().getShuntCompensator ("v7shunt " );
132165 var model = shuntCompensator1 .getModel (ShuntCompensatorLinearModel .class );
133166 assertNotNull (model );
134167 assertEquals (-2.1121E-4 , model .getBPerSection (), 0.0001 );
135168
136- var shuntCompensator2 = getNetwork ().getShuntCompensator ("v6shunt " );
169+ var shuntCompensator2 = getNetwork ().getShuntCompensator ("v8shunt " );
137170 var model2 = shuntCompensator2 .getModel (ShuntCompensatorLinearModel .class );
138171 assertNotNull (model2 );
139172 assertEquals (2.1121E-4 , model2 .getBPerSection (), 0.0001 );
140173 }
141174
142175 @ Override
143176 protected ModificationInfos buildModification () {
177+ VoltageLevel v2 = getNetwork ().getVoltageLevel ("v2" );
178+ createShuntCompensator (v2 , "v7shunt" , "v7shunt" , 15 , 225. , 10 , true , 1 , 1 , 2 , 1 , "feeder_v7shunt" , 40 , ConnectablePosition .Direction .BOTTOM );
179+
144180 return ShuntCompensatorModificationInfos .builder ()
145- .equipmentId ("v2shunt " )
181+ .equipmentId ("v7shunt " )
146182 .shuntCompensatorType (new AttributeModification <>(ShuntCompensatorType .CAPACITOR , OperationType .SET ))
147183 .qAtNominalV (new AttributeModification <>(15.0 , OperationType .SET ))
148184 .voltageLevelId ("v2" )
@@ -161,7 +197,7 @@ protected ModificationInfos buildModificationUpdate() {
161197
162198 @ Override
163199 protected void assertNetworkAfterCreation () {
164- var shuntCompensator = getNetwork ().getShuntCompensator ("v2shunt " );
200+ var shuntCompensator = getNetwork ().getShuntCompensator ("v7shunt " );
165201 var model = shuntCompensator .getModel (ShuntCompensatorLinearModel .class );
166202 assertNotNull (model );
167203 assertEquals (2.9629E-4 , model .getBPerSection (), 0.0001 );
0 commit comments