Skip to content

Upgrade to powsybl-dependencies v2025.0.0 #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) 2025, 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.tck;

import com.powsybl.iidm.network.tck.AbstractAreaTest;
import com.powsybl.network.store.server.NetworkStoreApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;

/**
* @author Etienne Lesot <etienne.lesot at rte-france.com>
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = {"spring.config.location=classpath:application.yaml"})
@ContextHierarchy({@ContextConfiguration(classes = {NetworkStoreApplication.class})})
public class AreaIt extends AbstractAreaTest {
@Override
public void mergeAndFlatten() {
// merge is not implemented
}

@Override
public void throwAddVoltageLevelOtherNetwork() {
// problem
}

@Override
public void removeArea() {
// removed equipments is managed differently in powsybl core implementation
}

@Override
public void throwRemovedVoltageLevel() {
// removed equipments is managed differently in powsybl core implementation
}

@Override
public void testGetAreaBoundary() {
// problem with removal
}

@Override
public void testSetterGetterInMultiVariants() {
// problem with removal
}

@Override
public void throwBoundaryOtherNetwork() {
// creation of subnetwork needed
}

@Override
public void removeEquipmentRemovesAreaBoundaryMergeAndDetach() {
// merge is not implemented
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.powsybl.cgmes.conversion.CgmesImport;
import com.powsybl.cgmes.extensions.*;
import com.powsybl.cgmes.model.CgmesMetadataModel;
import com.powsybl.cgmes.model.CgmesNames;
import com.powsybl.cgmes.model.CgmesSubset;
import com.powsybl.commons.PowsyblException;
import com.powsybl.commons.datasource.ReadOnlyDataSource;
Expand Down Expand Up @@ -121,7 +122,7 @@ void testGeneratorShortCircuit() {
assertNull(gen.getExtensionByName(GeneratorShortCircuit.NAME));
assertTrue(gen.getExtensions().isEmpty());
GeneratorShortCircuitAdder circuitAdder = gen.newExtension(GeneratorShortCircuitAdder.class).withDirectTransX(Double.NaN);
assertThrows(PowsyblException.class, () -> circuitAdder.add());
assertThrows(PowsyblException.class, circuitAdder::add);
circuitAdder.withDirectSubtransX(20.)
.withDirectTransX(30.)
.withStepUpTransformerX(50.)
Expand Down Expand Up @@ -150,6 +151,44 @@ void testGeneratorShortCircuit() {
}
}

@Test
void testBatteryShortCircuit() {
try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Network network = BatteryNetworkFactory.create(service.getNetworkFactory());
Battery bat = network.getBattery("BAT");
assertNull(bat.getExtension(BatteryShortCircuit.class));
assertNull(bat.getExtensionByName(BatteryShortCircuit.NAME));
assertTrue(bat.getExtensions().isEmpty());
BatteryShortCircuitAdder circuitAdder = bat.newExtension(BatteryShortCircuitAdder.class).withDirectTransX(Double.NaN);
assertThrows(PowsyblException.class, circuitAdder::add);
circuitAdder.withDirectSubtransX(20.)
.withDirectTransX(30.)
.withStepUpTransformerX(50.)
.add();
service.flush(network);
}

try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Network network = service.getNetwork(service.getNetworkIds().keySet().iterator().next());
Battery bat = network.getBattery("BAT");
BatteryShortCircuit batteryShortCircuit = bat.getExtension(BatteryShortCircuit.class);
assertNotNull(batteryShortCircuit);
assertEquals(20., batteryShortCircuit.getDirectSubtransX(), 0);
assertEquals(30., batteryShortCircuit.getDirectTransX(), 0);
assertEquals(50., batteryShortCircuit.getStepUpTransformerX(), 0);
assertNotNull(bat.getExtensionByName(BatteryShortCircuit.NAME));
assertEquals(BatteryShortCircuit.NAME, batteryShortCircuit.getName());

assertThrows(PowsyblException.class, () -> batteryShortCircuit.setDirectTransX(Double.NaN));
batteryShortCircuit.setDirectSubtransX(23.);
batteryShortCircuit.setDirectTransX(32.);
batteryShortCircuit.setStepUpTransformerX(44.);
assertEquals(23., batteryShortCircuit.getDirectSubtransX(), 0);
assertEquals(32., batteryShortCircuit.getDirectTransX(), 0);
assertEquals(44., batteryShortCircuit.getStepUpTransformerX(), 0);
}
}

@Test
void testIdentifiableShortCircuit() {
try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Expand Down Expand Up @@ -289,7 +328,8 @@ void cgmesExtensionsTest() {
.cgmesTopologyKind(CgmesTopologyKind.BUS_BRANCH)
.build();

((NetworkImpl) readNetwork).updateResource(res -> res.getAttributes().setCimCharacteristics(cimCharacteristicsAttributes));
((NetworkImpl) readNetwork).updateResourceWithoutNotification(res ->
res.getAttributes().setCimCharacteristics(cimCharacteristicsAttributes));

service.flush(readNetwork);
}
Expand Down Expand Up @@ -1023,9 +1063,10 @@ void cgmesControlAreaDanglingLineTest() {
try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
// import new network in the store
Network network = service.importNetwork(CgmesConformity1Catalog.microGridBaseCaseBE().dataSource());
CgmesControlAreas cgmesControlAreas = network.getExtension(CgmesControlAreas.class);
assertNotNull(cgmesControlAreas);
assertEquals(0, cgmesControlAreas.getCgmesControlAreas().size());
Area cgmesControlAreas = network.getArea("ca1");
assertNull(cgmesControlAreas);
List<Area> areas = network.getAreaStream().toList();
assertEquals(0, areas.size());
}

try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Expand All @@ -1034,20 +1075,29 @@ void cgmesControlAreaDanglingLineTest() {
UUID networkUuid = networkIds.keySet().iterator().next();

Network network = service.getNetwork(networkUuid);
CgmesControlAreas cgmesControlAreas = network.getExtension(CgmesControlAreas.class);
assertNotNull(cgmesControlAreas);
assertEquals(0, cgmesControlAreas.getCgmesControlAreas().size());
CgmesControlArea cgmesControlArea = cgmesControlAreas.newCgmesControlArea()
assertEquals(0, network.getAreaStream().toList().size());
Area cgmesControlArea = network.newArea()
.setId("ca1")
.setEnergyIdentificationCodeEic("code")
.setNetInterchange(1000)
.setInterchangeTarget(1000)
.add();
cgmesControlArea.add(network.getGenerator("550ebe0d-f2b2-48c1-991f-cebea43a21aa").getTerminal());
cgmesControlArea.add(network.getDanglingLine("a16b4a6c-70b1-4abf-9a9d-bd0fa47f9fe4").getBoundary());
assertEquals(1, cgmesControlAreas.getCgmesControlAreas().size());
CgmesControlArea ca1 = cgmesControlAreas.getCgmesControlArea("ca1");
cgmesControlArea.addAlias("code", CgmesNames.ENERGY_IDENT_CODE_EIC);
cgmesControlArea.newAreaBoundary()
.setTerminal(network.getGenerator("550ebe0d-f2b2-48c1-991f-cebea43a21aa").getTerminal())
.setAc(true)
.add();
cgmesControlArea.newAreaBoundary()
.setBoundary(network.getDanglingLine("a16b4a6c-70b1-4abf-9a9d-bd0fa47f9fe4").getBoundary())
.setAc(true)
.add();
assertEquals(2, cgmesControlArea.getAreaBoundaryStream().toList().size());
assertEquals(1, network.getAreaStream().toList().size());
Area ca1 = network.getArea("ca1");
assertNotNull(ca1);

assertEquals(2, ca1.getAreaBoundaryStream().toList().size());
assertEquals(-91.19499400000001, ca1.getAcInterchange());
assertEquals(0, ca1.getDcInterchange());
assertEquals("code", ca1.getAliasFromType(CgmesNames.ENERGY_IDENT_CODE_EIC)
.orElse(null));
service.flush(network);
}

Expand All @@ -1057,17 +1107,13 @@ void cgmesControlAreaDanglingLineTest() {
UUID networkUuid = networkIds.keySet().iterator().next();

Network network = service.getNetwork(networkUuid);
CgmesControlAreas cgmesControlAreas = network.getExtension(CgmesControlAreas.class);
assertNotNull(cgmesControlAreas);
assertEquals(1, cgmesControlAreas.getCgmesControlAreas().size());
assertTrue(cgmesControlAreas.containsCgmesControlAreaId("ca1"));
CgmesControlArea cgmesControlArea = cgmesControlAreas.getCgmesControlArea("ca1");
Area cgmesControlArea = network.getArea("ca1");
assertNotNull(cgmesControlArea);
assertEquals(1, network.getAreaStream().toList().size());
assertEquals("ca1", cgmesControlArea.getId());
assertNull(cgmesControlArea.getName());
assertEquals("code", cgmesControlArea.getEnergyIdentificationCodeEIC());
assertEquals(1000, cgmesControlArea.getNetInterchange(), 0);
assertEquals(1, cgmesControlArea.getTerminals().size());
assertEquals(1, cgmesControlArea.getBoundaries().size());
assertTrue(cgmesControlArea.getOptionalName().isEmpty());
assertTrue(cgmesControlArea.getInterchangeTarget().isPresent());
assertEquals(1000, cgmesControlArea.getInterchangeTarget().getAsDouble());
}
}

Expand Down Expand Up @@ -1142,19 +1188,23 @@ void cgmesControlAreaTieLineTest() {
UUID networkUuid = networkIds.keySet().iterator().next();

Network network = service.getNetwork(networkUuid);
CgmesControlAreas cgmesControlAreas = network.getExtension(CgmesControlAreas.class);
assertNotNull(cgmesControlAreas);

assertNotNull(cgmesControlAreas);
assertEquals(0, cgmesControlAreas.getCgmesControlAreas().size());
CgmesControlArea cgmesControlArea = cgmesControlAreas.newCgmesControlArea()
assertEquals(0, network.getAreaStream().toList().size());
Area cgmesControlArea = network.newArea()
.setId("ca2")
.setEnergyIdentificationCodeEic("code2")
.setNetInterchange(800)
.setInterchangeTarget(800)
.addAreaBoundary(network.getTieLine("b18cd1aa-7808-49b9-a7cf-605eaf07b006 + e8acf6b6-99cb-45ad-b8dc-16c7866a4ddc").getDanglingLine1().getBoundary(),
true)
.add();
cgmesControlArea.add(((TieLine) network.getTieLine("b18cd1aa-7808-49b9-a7cf-605eaf07b006 + e8acf6b6-99cb-45ad-b8dc-16c7866a4ddc")).getDanglingLine1().getBoundary());
assertEquals(1, cgmesControlAreas.getCgmesControlAreas().size());

cgmesControlArea.addAlias("code2", CgmesNames.ENERGY_IDENT_CODE_EIC);
assertEquals(1, cgmesControlArea.getAreaBoundaryStream().toList().size());
Area ca2 = network.getArea("ca2");
assertNotNull(ca2);
assertEquals(1, ca2.getAreaBoundaryStream().toList().size());
assertTrue(ca2.getInterchangeTarget().isPresent());
assertEquals(800, ca2.getInterchangeTarget().getAsDouble());
assertEquals(90.07909111485668, ca2.getAcInterchange());
assertEquals("code2", ca2.getAliasFromType(CgmesNames.ENERGY_IDENT_CODE_EIC)
.orElse(null));
service.flush(network);
}

Expand All @@ -1164,13 +1214,15 @@ void cgmesControlAreaTieLineTest() {
UUID networkUuid = networkIds.keySet().iterator().next();

Network network = service.getNetwork(networkUuid);
CgmesControlAreas cgmesControlAreas = network.getExtension(CgmesControlAreas.class);
assertNotNull(cgmesControlAreas);

assertEquals(1, cgmesControlAreas.getCgmesControlAreas().size());
CgmesControlArea cgmesControlArea = cgmesControlAreas.getCgmesControlArea("ca2");
Area cgmesControlArea = network.getAreaStream().findFirst().orElse(null);
assertNotNull(cgmesControlArea);
assertEquals(1, cgmesControlArea.getBoundaries().size());
assertEquals("ca2", cgmesControlArea.getId());
assertTrue(cgmesControlArea.getInterchangeTarget().isPresent());
assertEquals(800, cgmesControlArea.getInterchangeTarget().getAsDouble());
assertEquals(90.07909111485668, cgmesControlArea.getAcInterchange());
assertEquals("code2", cgmesControlArea.getAliasFromType(CgmesNames.ENERGY_IDENT_CODE_EIC)
.orElse(null));
assertEquals(1, cgmesControlArea.getAreaBoundaryStream().toList().size());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ void testSubstationUpdate() {

verify(mockedListener, times(1)).onUpdate(s, "country", INITIAL_VARIANT_ID, Country.FR, Country.BB);
verify(mockedListener, times(1)).onUpdate(s, "tso", INITIAL_VARIANT_ID, null, "New TSO");
verify(mockedListener, times(1)).onPropertyAdded(s, "geographicalTags", "paris");
// verify(mockedListener, times(1)).onPropertyAdded(s, "geographicalTags", "paris");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not working anymore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove if it's the right thing to do


service.flush(readNetwork);
}
Expand Down Expand Up @@ -736,7 +736,7 @@ void substationTest() {

verify(mockedListener, times(1)).onUpdate(s1, "country", INITIAL_VARIANT_ID, Country.FR, Country.BE);
verify(mockedListener, times(1)).onUpdate(s1, "tso", INITIAL_VARIANT_ID, "TSO_FR", "TSO_BE");
verify(mockedListener, times(1)).onPropertyAdded(s1, "geographicalTags", "BELGIUM");
// verify(mockedListener, times(1)).onPropertyAdded(s1, "geographicalTags", "BELGIUM");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not working anymore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove if it's the right thing to do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Franck will watch this it is strange


s1.setProperty("testProperty", "original");
verify(mockedListener, times(1)).onPropertyAdded(s1, "properties[testProperty]", "original");
Expand Down Expand Up @@ -3572,7 +3572,9 @@ void testVariants() {
// check removal GEN2 in initial variant
assertNull(network.getGenerator("GEN2"));
// check that GEN2 object is not usable anymore
PowsyblException e = assertThrows(PowsyblException.class, gen2::getId);
PowsyblException e = assertThrows(PowsyblException.class, gen2::getEnergySource);
// id persits even with remove
assertEquals("GEN2", gen2.getId());
assertEquals("Object has been removed in current variant", e.getMessage());

// update a generator before clone, should be updated in both variants
Expand Down Expand Up @@ -3604,7 +3606,7 @@ void testVariants() {
// check removal on "v" variant
assertNull(network.getGenerator("GEN2"));
// check that GENERATOR2 object is not usable anymore
PowsyblException e1 = assertThrows(PowsyblException.class, gen2::getId);
PowsyblException e1 = assertThrows(PowsyblException.class, gen2::getEnergySource);
assertEquals("Object has been removed in current variant", e1.getMessage());

// check that GENERATOR is modified
Expand Down Expand Up @@ -3658,7 +3660,7 @@ void testVariants() {
assertNull(network.getLoad("LOAD"));

// check that LOAD object is not usable anymore
PowsyblException e = assertThrows(PowsyblException.class, load::getId);
PowsyblException e = assertThrows(PowsyblException.class, load::getP0);
assertEquals("Object has been removed in current variant", e.getMessage());

// switch to "v" variant and check LOAD exists again
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public enum ExternalAttributesType {
PERMANENT_LIMIT,
REACTIVE_CAPABILITY_CURVE_POINT,
REGULATING_POINT,
TAP_CHANGER_STEP
TAP_CHANGER_STEP,
AREA_BOUNDARIES
}
Loading
Loading