diff --git a/lombok.config b/lombok.config deleted file mode 100644 index df71bb6a0..000000000 --- a/lombok.config +++ /dev/null @@ -1,2 +0,0 @@ -config.stopBubbling = true -lombok.addLombokGeneratedAnnotation = true diff --git a/network-store-client-distribution/pom.xml b/network-store-client-distribution/pom.xml index 2fbe7021c..eb382b4ab 100644 --- a/network-store-client-distribution/pom.xml +++ b/network-store-client-distribution/pom.xml @@ -15,7 +15,7 @@ com.powsybl powsybl-network-store-client-parent - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT powsybl-network-store-client-distribution diff --git a/network-store-client/pom.xml b/network-store-client/pom.xml index b4ac298cd..ca330907c 100644 --- a/network-store-client/pom.xml +++ b/network-store-client/pom.xml @@ -15,7 +15,7 @@ com.powsybl powsybl-network-store-client-parent - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT powsybl-network-store-client diff --git a/network-store-iidm-impl/.mvn/lombok-config-copy.marker b/network-store-iidm-impl/.mvn/lombok-config-copy.marker new file mode 100644 index 000000000..e69de29bb diff --git a/network-store-iidm-impl/lombok.config b/network-store-iidm-impl/lombok.config new file mode 100644 index 000000000..4fa82504b --- /dev/null +++ b/network-store-iidm-impl/lombok.config @@ -0,0 +1 @@ +import target/configs/powsybl-build-tools.jar!powsybl-build-tools/lombok.config diff --git a/network-store-iidm-impl/pom.xml b/network-store-iidm-impl/pom.xml index 2b693f056..f57005357 100644 --- a/network-store-iidm-impl/pom.xml +++ b/network-store-iidm-impl/pom.xml @@ -1,11 +1,9 @@ powsybl-network-store-client-parent com.powsybl - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT powsybl-network-store-iidm-impl Network store IIDM impl + + + org.projectlombok + lombok + provided + + com.powsybl @@ -70,11 +75,6 @@ slf4j-simple test - - nl.jqno.equalsverifier - equalsverifier - test - com.powsybl diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/BusbarSectionPositionImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/BusbarSectionPositionImpl.java index 7878b3885..f6aea7f33 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/BusbarSectionPositionImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/BusbarSectionPositionImpl.java @@ -8,6 +8,8 @@ import com.powsybl.commons.extensions.AbstractExtension; import com.powsybl.iidm.network.BusbarSection; +import com.powsybl.iidm.network.Validable; +import com.powsybl.iidm.network.ValidationException; import com.powsybl.iidm.network.extensions.BusbarSectionPosition; import com.powsybl.network.store.model.BusbarSectionAttributes; import com.powsybl.network.store.model.BusbarSectionPositionAttributes; @@ -20,13 +22,13 @@ public class BusbarSectionPositionImpl extends AbstractExtension public BusbarSectionPositionImpl(BusbarSectionImpl busbarSectionImpl) { super(busbarSectionImpl); - checkIndex(getBusbarIndex()); - checkIndex(getSectionIndex()); + checkIndex(busbarSectionImpl, getBusbarIndex(), "Busbar"); + checkIndex(busbarSectionImpl, getSectionIndex(), "Section"); } - private static int checkIndex(int index) { + private static int checkIndex(Validable validable, int index, String equipmentTypeLabel) { if (index < 0) { - throw new IllegalArgumentException("Busbar index has to be greater or equals to zero"); + throw new ValidationException(validable, equipmentTypeLabel + " index has to be greater or equals to zero"); } return index; } @@ -50,7 +52,7 @@ private BusbarSectionPositionAttributes getPositionAttributes(Resource getPositionAttributes(res).setBusbarIndex(checkIndex(busbarIndex))); + getBusbarSection().updateResource(res -> getPositionAttributes(res).setBusbarIndex(checkIndex(getBusbarSection(), busbarIndex, "Busbar"))); return this; } @@ -61,7 +63,7 @@ public int getSectionIndex() { @Override public BusbarSectionPosition setSectionIndex(int sectionIndex) { - getBusbarSection().updateResource(res -> getPositionAttributes(res).setSectionIndex(checkIndex(sectionIndex))); + getBusbarSection().updateResource(res -> getPositionAttributes(res).setSectionIndex(checkIndex(getBusbarSection(), sectionIndex, "Section"))); return this; } } diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/PhaseTapChangerAdderImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/PhaseTapChangerAdderImpl.java index 6daa89e23..a8ef3e752 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/PhaseTapChangerAdderImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/PhaseTapChangerAdderImpl.java @@ -212,7 +212,8 @@ public PhaseTapChanger add() { if (tapChangerParentAttributes.getRatioTapChangerAttributes() != null) { LOGGER.warn("{} has both Ratio and Phase Tap Changer", tapChangerParentAttributes); } - tapChangerParentAttributes.setPhaseTapChangerAttributes(phaseTapChangerAttributes); + + tapChangerParent.setPhaseTapChanger(phaseTapChangerAttributes); return new PhaseTapChangerImpl(tapChangerParent, index, attributesGetter); } diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/PhaseTapChangerImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/PhaseTapChangerImpl.java index c74b6aab0..17f73cd0a 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/PhaseTapChangerImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/PhaseTapChangerImpl.java @@ -106,8 +106,7 @@ public PhaseTapChangerStep getCurrentStep() { @Override public void remove() { - //TODO - throw new UnsupportedOperationException("TODO"); + parent.setPhaseTapChanger(null); } protected String getTapChangerAttribute() { diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/RatioTapChangerAdderImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/RatioTapChangerAdderImpl.java index 7cb25a758..bb0aa9ec7 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/RatioTapChangerAdderImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/RatioTapChangerAdderImpl.java @@ -197,7 +197,8 @@ public RatioTapChanger add() { if (tapChangerParentAttributes.getPhaseTapChangerAttributes() != null) { LOGGER.warn("{} has both Ratio and Phase Tap Changer", tapChangerParentAttributes); } - tapChangerParentAttributes.setRatioTapChangerAttributes(ratioTapChangerAttributes); + + tapChangerParent.setRatioTapChanger(ratioTapChangerAttributes); return new RatioTapChangerImpl(tapChangerParent, index, attributesGetter); } diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/RatioTapChangerImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/RatioTapChangerImpl.java index 594d8d56e..4ad27bc93 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/RatioTapChangerImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/RatioTapChangerImpl.java @@ -114,8 +114,7 @@ public RatioTapChangerStep getCurrentStep() { @Override public void remove() { - //TODO - throw new UnsupportedOperationException("TODO"); + parent.setRatioTapChanger(null); } protected String getTapChangerAttribute() { diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TapChangerParent.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TapChangerParent.java index c61d58d0c..1e791bec1 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TapChangerParent.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TapChangerParent.java @@ -10,6 +10,8 @@ import com.powsybl.iidm.network.RatioTapChanger; import com.powsybl.iidm.network.TapChanger; import com.powsybl.iidm.network.Validable; +import com.powsybl.network.store.model.PhaseTapChangerAttributes; +import com.powsybl.network.store.model.RatioTapChangerAttributes; import java.util.HashSet; import java.util.Set; @@ -41,4 +43,8 @@ public interface TapChangerParent extends Validable { PhaseTapChanger getPhaseTapChanger(); RatioTapChanger getRatioTapChanger(); + + void setPhaseTapChanger(PhaseTapChangerAttributes attributes); + + void setRatioTapChanger(RatioTapChangerAttributes attributes); } diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ThreeWindingsTransformerImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ThreeWindingsTransformerImpl.java index e3ef5b8fc..1f5551194 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ThreeWindingsTransformerImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ThreeWindingsTransformerImpl.java @@ -226,6 +226,20 @@ public RatioTapChangerAdder newRatioTapChanger() { return new RatioTapChangerAdderImpl(this, index, attributes -> legGetter.apply((ThreeWindingsTransformerAttributes) attributes)); } + @Override + public void setPhaseTapChanger(PhaseTapChangerAttributes attributes) { + PhaseTapChangerAttributes oldValue = getLegAttributes().getPhaseTapChangerAttributes(); + transformer.updateResource(res -> legGetter.apply(res.getAttributes()).setPhaseTapChangerAttributes(attributes)); + index.notifyUpdate(transformer, "phaseTapChanger", oldValue, attributes); + } + + @Override + public void setRatioTapChanger(RatioTapChangerAttributes attributes) { + RatioTapChangerAttributes oldValue = getLegAttributes().getRatioTapChangerAttributes(); + transformer.updateResource(res -> legGetter.apply(res.getAttributes()).setRatioTapChangerAttributes(attributes)); + index.notifyUpdate(transformer, "ratioTapChanger", oldValue, attributes); + } + @Override public PhaseTapChanger getPhaseTapChanger() { return getLegAttributes().getPhaseTapChangerAttributes() != null diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TwoWindingsTransformerImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TwoWindingsTransformerImpl.java index eae96f029..02781cbb7 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TwoWindingsTransformerImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TwoWindingsTransformerImpl.java @@ -12,6 +12,8 @@ import com.powsybl.iidm.network.extensions.TwoWindingsTransformerPhaseAngleClock; import com.powsybl.network.store.iidm.impl.extensions.CgmesTapChangersImpl; import com.powsybl.network.store.iidm.impl.extensions.TwoWindingsTransformerPhaseAngleClockImpl; +import com.powsybl.network.store.model.PhaseTapChangerAttributes; +import com.powsybl.network.store.model.RatioTapChangerAttributes; import com.powsybl.network.store.model.Resource; import com.powsybl.network.store.model.TapChangerParentAttributes; import com.powsybl.network.store.model.TwoWindingsTransformerAttributes; @@ -62,6 +64,20 @@ public PhaseTapChangerAdder newPhaseTapChanger() { return new PhaseTapChangerAdderImpl(this, index, TapChangerParentAttributes.class::cast); } + @Override + public void setPhaseTapChanger(PhaseTapChangerAttributes attributes) { + PhaseTapChangerAttributes oldValue = getResource().getAttributes().getPhaseTapChangerAttributes(); + updateResource(res -> res.getAttributes().setPhaseTapChangerAttributes(attributes)); + index.notifyUpdate(this, "phaseTapChanger", oldValue, attributes); + } + + @Override + public void setRatioTapChanger(RatioTapChangerAttributes attributes) { + RatioTapChangerAttributes oldValue = getResource().getAttributes().getRatioTapChangerAttributes(); + updateResource(res -> res.getAttributes().setRatioTapChangerAttributes(attributes)); + index.notifyUpdate(this, "ratioTapChanger", oldValue, attributes); + } + @Override public RatioTapChanger getRatioTapChanger() { var resource = getResource(); diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/extensions/StandbyAutomatonAdderImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/extensions/StandbyAutomatonAdderImpl.java index 695856ac9..e86664b36 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/extensions/StandbyAutomatonAdderImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/extensions/StandbyAutomatonAdderImpl.java @@ -36,7 +36,7 @@ public StandbyAutomatonAdderImpl(StaticVarCompensator svc) { @Override protected StandbyAutomaton createExtension(StaticVarCompensator svc) { - var attributes = StandbyAutomatonImpl.createAttributes(b0, standby, + var attributes = StandbyAutomatonImpl.createAttributes((StaticVarCompensatorImpl) svc, b0, standby, lowVoltageSetpoint, highVoltageSetpoint, lowVoltageThreshold, highVoltageThreshold); ((StaticVarCompensatorImpl) svc).updateResource(res -> res.getAttributes().setStandbyAutomaton(attributes)); return new StandbyAutomatonImpl(svc); diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/extensions/StandbyAutomatonImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/extensions/StandbyAutomatonImpl.java index 84c6581f3..9b0c07c1a 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/extensions/StandbyAutomatonImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/extensions/StandbyAutomatonImpl.java @@ -8,6 +8,8 @@ import com.powsybl.commons.extensions.AbstractExtension; import com.powsybl.iidm.network.StaticVarCompensator; +import com.powsybl.iidm.network.Validable; +import com.powsybl.iidm.network.ValidationException; import com.powsybl.iidm.network.extensions.StandbyAutomaton; import com.powsybl.network.store.iidm.impl.StaticVarCompensatorImpl; import com.powsybl.network.store.model.Resource; @@ -23,29 +25,29 @@ public class StandbyAutomatonImpl extends AbstractExtension= highVoltageThreshold) { - throw new IllegalArgumentException("Inconsistent low (" + lowVoltageThreshold + ") and high (" + highVoltageThreshold + ") voltage thresholds"); + throw new ValidationException(validable, "Inconsistent low (" + lowVoltageThreshold + ") and high (" + highVoltageThreshold + ") voltage thresholds"); } if (lowVoltageSetpoint < lowVoltageThreshold) { LOGGER.warn("Invalid low voltage setpoint {} < threshold {}", lowVoltageSetpoint, lowVoltageThreshold); @@ -55,19 +57,10 @@ private static void checkVoltageConfig(double lowVoltageSetpoint, double highVol } } - public static StandbyAutomatonAttributes createAttributes(StandbyAutomaton standbyAutomaton) { - return createAttributes(standbyAutomaton.getB0(), - standbyAutomaton.isStandby(), - standbyAutomaton.getLowVoltageSetpoint(), - standbyAutomaton.getHighVoltageSetpoint(), - standbyAutomaton.getLowVoltageThreshold(), - standbyAutomaton.getHighVoltageThreshold()); - } - - public static StandbyAutomatonAttributes createAttributes(double b0, boolean standby, double lowVoltageSetpoint, double highVoltageSetpoint, + public static StandbyAutomatonAttributes createAttributes(Validable validable, double b0, boolean standby, double lowVoltageSetpoint, double highVoltageSetpoint, double lowVoltageThreshold, double highVoltageThreshold) { - checkVoltageConfig(lowVoltageSetpoint, highVoltageSetpoint, lowVoltageThreshold, highVoltageThreshold); - checkB0(b0); + checkVoltageConfig(validable, lowVoltageSetpoint, highVoltageSetpoint, lowVoltageThreshold, highVoltageThreshold); + checkB0(validable, b0); return StandbyAutomatonAttributes.builder() .b0(b0) .standby(standby) @@ -112,7 +105,7 @@ public double getB0() { @Override public StandbyAutomatonImpl setB0(double b0) { - getSvc().updateResource(res -> getAttributes(res).setB0(checkB0(b0))); + getSvc().updateResource(res -> getAttributes(res).setB0(checkB0(getSvc(), b0))); return this; } @@ -123,7 +116,7 @@ public double getHighVoltageSetpoint() { @Override public StandbyAutomatonImpl setHighVoltageSetpoint(double highVoltageSetpoint) { - checkVoltageConfig(getLowVoltageSetpoint(), highVoltageSetpoint, getLowVoltageThreshold(), getHighVoltageThreshold()); + checkVoltageConfig(getSvc(), getLowVoltageSetpoint(), highVoltageSetpoint, getLowVoltageThreshold(), getHighVoltageThreshold()); getSvc().updateResource(res -> getAttributes(res).setHighVoltageSetpoint(highVoltageSetpoint)); return this; } @@ -135,7 +128,7 @@ public double getHighVoltageThreshold() { @Override public StandbyAutomatonImpl setHighVoltageThreshold(double highVoltageThreshold) { - checkVoltageConfig(getLowVoltageSetpoint(), getHighVoltageSetpoint(), getLowVoltageThreshold(), highVoltageThreshold); + checkVoltageConfig(getSvc(), getLowVoltageSetpoint(), getHighVoltageSetpoint(), getLowVoltageThreshold(), highVoltageThreshold); getSvc().updateResource(res -> getAttributes(res).setHighVoltageThreshold(highVoltageThreshold)); return this; } @@ -147,7 +140,7 @@ public double getLowVoltageSetpoint() { @Override public StandbyAutomatonImpl setLowVoltageSetpoint(double lowVoltageSetpoint) { - checkVoltageConfig(lowVoltageSetpoint, getHighVoltageSetpoint(), getLowVoltageThreshold(), getHighVoltageThreshold()); + checkVoltageConfig(getSvc(), lowVoltageSetpoint, getHighVoltageSetpoint(), getLowVoltageThreshold(), getHighVoltageThreshold()); getSvc().updateResource(res -> getAttributes(res).setLowVoltageSetpoint(lowVoltageSetpoint)); return this; } @@ -159,7 +152,7 @@ public double getLowVoltageThreshold() { @Override public StandbyAutomatonImpl setLowVoltageThreshold(double lowVoltageThreshold) { - checkVoltageConfig(getLowVoltageSetpoint(), getHighVoltageSetpoint(), lowVoltageThreshold, getHighVoltageThreshold()); + checkVoltageConfig(getSvc(), getLowVoltageSetpoint(), getHighVoltageSetpoint(), lowVoltageThreshold, getHighVoltageThreshold()); getSvc().updateResource(res -> getAttributes(res).setLowVoltageThreshold(lowVoltageThreshold)); return this; } diff --git a/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/BusBreakerCalculatedBusTest.java b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/BusBreakerCalculatedBusTest.java index 27851a090..ac8d1f661 100644 --- a/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/BusBreakerCalculatedBusTest.java +++ b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/BusBreakerCalculatedBusTest.java @@ -7,7 +7,6 @@ package com.powsybl.network.store.iidm.impl; import com.powsybl.iidm.network.*; -import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.Test; import java.util.Arrays; @@ -20,17 +19,6 @@ * @author Slimane Amar */ public class BusBreakerCalculatedBusTest { - - @Test - public void equalsContract() { - NetworkObjectIndex index1 = new NetworkObjectIndex(new CachedNetworkStoreClient(new OfflineNetworkStoreClient())); - NetworkObjectIndex index2 = new NetworkObjectIndex(new CachedNetworkStoreClient(new OfflineNetworkStoreClient())); - EqualsVerifier.simple().forClass(CalculatedBus.class).withIgnoredFields("connectedComponent", "synchronousComponent") - .withPrefabValues(NetworkObjectIndex.class, index1, index2) - .withPrefabValues(ComponentImpl.class, new ComponentImpl(null, null), new ComponentImpl(null, null)) - .verify(); - } - @Test public void testCalculatedBusesWithMultiBuses() { Network network = CreateNetworksUtil.createBusBreakerNetworkWithMultiBuses(); diff --git a/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/TwoWindingsTransformerTest.java b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/TwoWindingsTransformerTest.java new file mode 100644 index 000000000..74bc7f070 --- /dev/null +++ b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/TwoWindingsTransformerTest.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2023, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package com.powsybl.network.store.iidm.impl; + +import com.powsybl.cgmes.conformity.CgmesConformity1Catalog; +import com.powsybl.iidm.network.*; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author Ayoub LABIDI + */ +public class TwoWindingsTransformerTest { + + @Test + public void testTapChangerRemoval() { + Network network = Importer.find("CGMES") + .importData(CgmesConformity1Catalog.microGridBaseCaseAssembled().dataSource(), new NetworkFactoryImpl(), null); + //test remove RatioTapChanger + TwoWindingsTransformer twtWithRatioTapChanger = network.getTwoWindingsTransformer("b94318f6-6d24-4f56-96b9-df2531ad6543"); + twtWithRatioTapChanger.getRatioTapChanger().remove(); + assertNull(twtWithRatioTapChanger.getRatioTapChanger()); + + //test remove PhaseTapChanger + TwoWindingsTransformer twtWithPhaseTapChanger = network.getTwoWindingsTransformer("a708c3bc-465d-4fe7-b6ef-6fa6408a62b0"); + twtWithPhaseTapChanger.getPhaseTapChanger().remove(); + assertNull(twtWithPhaseTapChanger.getPhaseTapChanger()); + } +} diff --git a/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/VoltageLevelTest.java b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/VoltageLevelTest.java index 32124045b..1ffe9b351 100644 --- a/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/VoltageLevelTest.java +++ b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/VoltageLevelTest.java @@ -61,27 +61,27 @@ public void testBusbarSectionPositions() { assertNotNull(network.getVoltageLevel("VL").getNodeBreakerView().getBusbarSection("idBBS")); BusbarSectionPositionAdder busbarSectionPositionAdder = bbs.newExtension(BusbarSectionPositionAdder.class); - assertEquals("Busbar index has to be greater or equals to zero", - assertThrows(IllegalArgumentException.class, busbarSectionPositionAdder::add).getMessage()); + assertEquals("Busbar section 'idBBS': Busbar index has to be greater or equals to zero", + assertThrows(ValidationException.class, busbarSectionPositionAdder::add).getMessage()); busbarSectionPositionAdder = bbs.newExtension(BusbarSectionPositionAdder.class).withBusbarIndex(0); - assertEquals("Busbar index has to be greater or equals to zero", - assertThrows(IllegalArgumentException.class, busbarSectionPositionAdder::add).getMessage()); + assertEquals("Busbar section 'idBBS': Section index has to be greater or equals to zero", + assertThrows(ValidationException.class, busbarSectionPositionAdder::add).getMessage()); busbarSectionPositionAdder = bbs.newExtension(BusbarSectionPositionAdder.class).withSectionIndex(0); - assertEquals("Busbar index has to be greater or equals to zero", - assertThrows(IllegalArgumentException.class, busbarSectionPositionAdder::add).getMessage()); + assertEquals("Busbar section 'idBBS': Busbar index has to be greater or equals to zero", + assertThrows(ValidationException.class, busbarSectionPositionAdder::add).getMessage()); busbarSectionPositionAdder = bbs.newExtension(BusbarSectionPositionAdder.class).withBusbarIndex(-1).withSectionIndex(0); - assertEquals("Busbar index has to be greater or equals to zero", - assertThrows(IllegalArgumentException.class, busbarSectionPositionAdder::add).getMessage()); + assertEquals("Busbar section 'idBBS': Busbar index has to be greater or equals to zero", + assertThrows(ValidationException.class, busbarSectionPositionAdder::add).getMessage()); busbarSectionPositionAdder = bbs.newExtension(BusbarSectionPositionAdder.class).withBusbarIndex(0).withSectionIndex(-1); - assertEquals("Busbar index has to be greater or equals to zero", - assertThrows(IllegalArgumentException.class, busbarSectionPositionAdder::add).getMessage()); + assertEquals("Busbar section 'idBBS': Section index has to be greater or equals to zero", + assertThrows(ValidationException.class, busbarSectionPositionAdder::add).getMessage()); busbarSectionPositionAdder = bbs.newExtension(BusbarSectionPositionAdder.class).withBusbarIndex(-1).withSectionIndex(-1); - assertEquals("Busbar index has to be greater or equals to zero", - assertThrows(IllegalArgumentException.class, busbarSectionPositionAdder::add).getMessage()); + assertEquals("Busbar section 'idBBS': Busbar index has to be greater or equals to zero", + assertThrows(ValidationException.class, busbarSectionPositionAdder::add).getMessage()); } } diff --git a/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/tck/extensions/StandbyAutomatonTest.java b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/tck/extensions/StandbyAutomatonTest.java index b8d32096c..aeb0bf9c7 100644 --- a/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/tck/extensions/StandbyAutomatonTest.java +++ b/network-store-iidm-impl/src/test/java/com/powsybl/network/store/iidm/impl/tck/extensions/StandbyAutomatonTest.java @@ -6,7 +6,12 @@ */ package com.powsybl.network.store.iidm.impl.tck.extensions; +import com.powsybl.iidm.network.*; +import com.powsybl.iidm.network.extensions.StandbyAutomatonAdder; import com.powsybl.iidm.network.tck.extensions.AbstractStandbyAutomatonTest; +import org.junit.Test; + +import static org.junit.Assert.*; /** * @author Geoffroy Jamgotchian @@ -16,4 +21,57 @@ public class StandbyAutomatonTest extends AbstractStandbyAutomatonTest { public void variantsCloneTest() { // FIXME } + + @Test + public void testStandbyAutomatonChecks() { + Network network = Network.create("test", "test"); + Substation s = network.newSubstation() + .setId("S") + .setCountry(Country.FR) + .add(); + VoltageLevel vl = s.newVoltageLevel() + .setId("VL") + .setNominalV(400.0) + .setTopologyKind(TopologyKind.BUS_BREAKER) + .add(); + vl.getBusBreakerView().newBus() + .setId("BUS") + .add(); + StaticVarCompensator svc = vl.newStaticVarCompensator() + .setId("SVC") + .setConnectableBus("BUS") + .setBmin(12.2) + .setBmax(32.2) + .setRegulationMode(StaticVarCompensator.RegulationMode.VOLTAGE) + .setVoltageSetpoint(23.8) + .add(); + + StandbyAutomatonAdder standbyAutomatonAdder = svc.newExtension(StandbyAutomatonAdder.class) + .withHighVoltageSetpoint(21.3) + .withLowVoltageSetpoint(1.7) + .withHighVoltageThreshold(0.0) + .withLowVoltageThreshold(0.0); + assertEquals("Static var compensator 'SVC': Inconsistent low (0.0) and high (0.0) voltage thresholds", assertThrows(ValidationException.class, standbyAutomatonAdder::add).getMessage()); + + standbyAutomatonAdder = svc.newExtension(StandbyAutomatonAdder.class).withLowVoltageSetpoint(Double.NaN); + assertEquals("Static var compensator 'SVC': lowVoltageSetpoint is invalid", assertThrows(ValidationException.class, standbyAutomatonAdder::add).getMessage()); + + standbyAutomatonAdder = svc.newExtension(StandbyAutomatonAdder.class).withHighVoltageSetpoint(Double.NaN); + assertEquals("Static var compensator 'SVC': highVoltageSetpoint is invalid", assertThrows(ValidationException.class, standbyAutomatonAdder::add).getMessage()); + + standbyAutomatonAdder = svc.newExtension(StandbyAutomatonAdder.class).withHighVoltageThreshold(Double.NaN); + assertEquals("Static var compensator 'SVC': highVoltageThreshold is invalid", assertThrows(ValidationException.class, standbyAutomatonAdder::add).getMessage()); + + standbyAutomatonAdder = svc.newExtension(StandbyAutomatonAdder.class).withLowVoltageThreshold(Double.NaN); + assertEquals("Static var compensator 'SVC': lowVoltageThreshold is invalid", assertThrows(ValidationException.class, standbyAutomatonAdder::add).getMessage()); + + standbyAutomatonAdder = svc.newExtension(StandbyAutomatonAdder.class) + .withHighVoltageSetpoint(21.3) + .withLowVoltageSetpoint(1.7) + .withHighVoltageThreshold(10.0) + .withLowVoltageThreshold(3.0) + .withB0(Double.NaN); + + assertEquals("Static var compensator 'SVC': b0 is invalid", assertThrows(ValidationException.class, standbyAutomatonAdder::add).getMessage()); + } } diff --git a/network-store-model/.mvn/lombok-config-copy.marker b/network-store-model/.mvn/lombok-config-copy.marker new file mode 100644 index 000000000..e69de29bb diff --git a/network-store-model/lombok.config b/network-store-model/lombok.config new file mode 100644 index 000000000..4fa82504b --- /dev/null +++ b/network-store-model/lombok.config @@ -0,0 +1 @@ +import target/configs/powsybl-build-tools.jar!powsybl-build-tools/lombok.config diff --git a/network-store-model/pom.xml b/network-store-model/pom.xml index 5ed335591..a50444292 100644 --- a/network-store-model/pom.xml +++ b/network-store-model/pom.xml @@ -1,11 +1,9 @@ com.powsybl powsybl-network-store-client-parent - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT powsybl-network-store-model @@ -47,6 +45,7 @@ org.projectlombok lombok + provided com.fasterxml.jackson.core @@ -88,11 +87,6 @@ junit test - - nl.jqno.equalsverifier - equalsverifier - test - org.slf4j slf4j-simple diff --git a/network-store-model/src/test/java/com/powsybl/network/store/model/AttributesTest.java b/network-store-model/src/test/java/com/powsybl/network/store/model/AttributesTest.java deleted file mode 100644 index 292aaea45..000000000 --- a/network-store-model/src/test/java/com/powsybl/network/store/model/AttributesTest.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2021, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package com.powsybl.network.store.model; - -import nl.jqno.equalsverifier.EqualsVerifier; -import org.junit.Test; - -/** - * @author Etienne Homer - */ -public class AttributesTest { - @Test - public void equalsContract() { - EqualsVerifier.simple().forClass(RemoteReactivePowerControlAttributes.class).verify(); - } -} diff --git a/pom.xml b/pom.xml index 37fc6dc8b..62636f6f4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,9 @@ com.powsybl powsybl-parent - 11 + 12 powsybl-network-store-client-parent - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT pom Network store client parent @@ -49,9 +47,7 @@ - 1.18.24 2.7.3 - 3.10 3.9 2023.2.1 1.5.0 @@ -91,21 +87,11 @@ - - nl.jqno.equalsverifier - equalsverifier - ${equalsverifier.version} - com.powsybl powsybl-ws-commons ${powsybl-ws-commons.version} - - org.projectlombok - lombok - ${lombok.version} - org.apache.commons commons-lang3 @@ -114,6 +100,15 @@ + + + + org.projectlombok + lombok + provided + + +