diff --git a/src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java b/src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java index fec6afbbb..a83902c62 100644 --- a/src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java +++ b/src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java @@ -55,8 +55,6 @@ public final class ModificationUtils { public static final String CONNECTION_DIRECTION_FIELD_NAME = "Connection direction"; public static final String CONNECTION_POSITION_FIELD_NAME = "Connection position"; - public static final String ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG = "Angle droop active power control, Droop and P0 must be provided together"; - private ModificationUtils() { } @@ -1307,20 +1305,5 @@ public static void insertReportNode(ReportNode parent, ReportNode child) { } } - public static void checkHvdcDroop(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) { - // all fields should be filled => OK extension will be created - if (isPresentAngleDroopActivePowerControl && isPresentDroop && isPresentP0) { - return; - } - // at least one field is filled but not for others => NOT OK - if (isPresentAngleDroopActivePowerControl || isPresentDroop || isPresentP0) { - throw new NetworkModificationException(WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL, ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG); - } - // all fields are not filled => OK extension will not be created - } - - public static boolean shouldCreateHvdcDroopActivePowerControlExtension(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) { - return isPresentAngleDroopActivePowerControl && isPresentDroop && isPresentP0; - } } diff --git a/src/main/java/org/gridsuite/modification/server/modifications/VscCreation.java b/src/main/java/org/gridsuite/modification/server/modifications/VscCreation.java index 60158922e..6e5e283f3 100644 --- a/src/main/java/org/gridsuite/modification/server/modifications/VscCreation.java +++ b/src/main/java/org/gridsuite/modification/server/modifications/VscCreation.java @@ -24,8 +24,8 @@ import static org.gridsuite.modification.server.NetworkModificationException.Type.CREATE_VSC_ERROR; import static org.gridsuite.modification.server.NetworkModificationException.Type.HVDC_LINE_ALREADY_EXISTS; -import static org.gridsuite.modification.server.modifications.ModificationUtils.checkHvdcDroop; -import static org.gridsuite.modification.server.modifications.ModificationUtils.shouldCreateHvdcDroopActivePowerControlExtension; +import static org.gridsuite.modification.server.modifications.VscModification.checkHvdcDroop; +import static org.gridsuite.modification.server.modifications.VscModification.shouldCreateHvdcDroopActivePowerControlExtension; /** * @author Seddik Yengui diff --git a/src/main/java/org/gridsuite/modification/server/modifications/VscModification.java b/src/main/java/org/gridsuite/modification/server/modifications/VscModification.java index 00cd95a0b..5ecd9b08c 100644 --- a/src/main/java/org/gridsuite/modification/server/modifications/VscModification.java +++ b/src/main/java/org/gridsuite/modification/server/modifications/VscModification.java @@ -21,10 +21,7 @@ import javax.annotation.Nonnull; import java.util.*; -import static org.gridsuite.modification.server.NetworkModificationException.Type.MODIFY_BATTERY_ERROR; -import static org.gridsuite.modification.server.NetworkModificationException.Type.MODIFY_VSC_ERROR; -import static org.gridsuite.modification.server.modifications.ModificationUtils.checkHvdcDroop; -import static org.gridsuite.modification.server.modifications.ModificationUtils.shouldCreateHvdcDroopActivePowerControlExtension; +import static org.gridsuite.modification.server.NetworkModificationException.Type.*; import static org.gridsuite.modification.server.modifications.VscCreation.VSC_CHARACTERISTICS; import static org.gridsuite.modification.server.modifications.VscCreation.VSC_SETPOINTS; @@ -37,6 +34,7 @@ public class VscModification extends AbstractModification { public static final String ANGLE_DROOP_ACTIVE_POWER_CONTROL_FIELD = "AngleDroopActivePowerControl"; public static final String DROOP_FIELD = "Droop"; public static final String P0_FIELD = "P0"; + public static final String ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG = "Angle droop active power control, Droop and P0 must be provided together"; private final VscModificationInfos modificationInfos; @@ -44,6 +42,22 @@ public VscModification(VscModificationInfos vscModificationInfos) { this.modificationInfos = vscModificationInfos; } + public static void checkHvdcDroop(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) { + // all fields should be filled => OK extension will be created + if (isPresentAngleDroopActivePowerControl && isPresentDroop && isPresentP0) { + return; + } + // at least one field is filled but not for others => NOT OK + if (isPresentAngleDroopActivePowerControl || isPresentDroop || isPresentP0) { + throw new NetworkModificationException(WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL, ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG); + } + // all fields are not filled => OK extension will not be created + } + + public static boolean shouldCreateHvdcDroopActivePowerControlExtension(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) { + return isPresentAngleDroopActivePowerControl && isPresentDroop && isPresentP0; + } + protected void checkConverterStation(@Nonnull ConverterStationModificationInfos converterStationModificationInfos, @Nonnull VscConverterStation vscConverterStation) { String errorMessage = "Converter station '" + converterStationModificationInfos.getEquipmentId() + "' : "; ModificationUtils.getInstance().checkReactiveLimit(vscConverterStation, converterStationModificationInfos.getMinQ(), converterStationModificationInfos.getMaxQ(), diff --git a/src/test/java/org/gridsuite/modification/server/modifications/VscCreationTest.java b/src/test/java/org/gridsuite/modification/server/modifications/VscCreationTest.java index 9c5148c8e..7db6ece80 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/VscCreationTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/VscCreationTest.java @@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.gridsuite.modification.server.NetworkModificationException.Type.*; -import static org.gridsuite.modification.server.modifications.ModificationUtils.ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG; +import static org.gridsuite.modification.server.modifications.VscModification.ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG; import static org.gridsuite.modification.server.utils.TestUtils.assertLogMessage; import static org.junit.Assert.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; diff --git a/src/test/java/org/gridsuite/modification/server/modifications/VscModificationTest.java b/src/test/java/org/gridsuite/modification/server/modifications/VscModificationTest.java index 435805e24..d72762455 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/VscModificationTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/VscModificationTest.java @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.gridsuite.modification.server.NetworkModificationException.Type.WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL; -import static org.gridsuite.modification.server.modifications.ModificationUtils.ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG; +import static org.gridsuite.modification.server.modifications.VscModification.ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @@ -244,39 +244,6 @@ public void testActivateHvdcAngleDroopActivePowerControl() throws Exception { Assert.assertTrue(activePowerControl.isEnabled()); } -// @ParameterizedTest(name = "Test modification with absent droop infos when extension does not yet exist [{index}] {0}, {1}, {2}") -// @CsvSource({ -// "true,false,false", -// "true,true,false", -// "true,false,true", -// "false,true,false", -// "false,true,true", -// "false,false,true", -// }) -// void testHvdcAngleDroopActivePowerControlWithAbsentInfos(boolean isPresentAngleDroopActivePowerControl, boolean isPresentDroop, boolean isPresentP0) { -// var networkuuid = UUID.randomUUID(); -// Network networkWithoutExt = NetworkCreation.createWithVSC(networkuuid, false); -// VscModificationInfos modificationInfos = (VscModificationInfos) buildModification(); -// -// // reset null depending to test arguments -// if (!isPresentAngleDroopActivePowerControl) { -// modificationInfos.setAngleDroopActivePowerControl(null); -// } -// if (!isPresentDroop) { -// modificationInfos.setDroop(null); -// } -// if (!isPresentP0) { -// modificationInfos.setP0(null); -// } -// -// VscModification wrongVscModification = new VscModification(modificationInfos); -// String message = Assert.assertThrows(NetworkModificationException.class, -// () -> wrongVscModification.check(networkWithoutExt)) -// .getMessage(); -// assertThat(message).isEqualTo(WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL.name() + " : " -// + ACTIVE_POWER_CONTROL_DROOP_P0_REQUIRED_ERROR_MSG); -// } - @Test public void testAngleDroopActivePowerControlWithAbsentInfos() { var networkuuid = UUID.randomUUID();