From d015bf4270a4d7fe2d4d921fa7bca8e4db4e96e8 Mon Sep 17 00:00:00 2001 From: Olivier Perrin Date: Fri, 6 Oct 2023 14:58:02 +0200 Subject: [PATCH] Fix VoltageAngleLimit retrieval by id from a subnetwork (#2743) Signed-off-by: Olivier Perrin (cherry picked from commit 965a415166f7b9b8708433e66677d80b580444ea) --- .../com/powsybl/iidm/network/impl/SubnetworkImpl.java | 4 ++-- .../network/tck/AbstractSubnetworksCreationTest.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/SubnetworkImpl.java b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/SubnetworkImpl.java index 3d5c21273f7..e9ff6d12050 100644 --- a/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/SubnetworkImpl.java +++ b/iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/SubnetworkImpl.java @@ -236,8 +236,8 @@ public Stream getVoltageAngleLimitsStream() { public VoltageAngleLimit getVoltageAngleLimit(String id) { VoltageAngleLimitImpl val = (VoltageAngleLimitImpl) getNetwork().getVoltageAngleLimit(id); boolean valInSubnetwork = val != null - && id.equals(val.getTerminalFrom().getVoltageLevel().getParentNetwork().getId()) - && id.equals(val.getTerminalTo().getVoltageLevel().getParentNetwork().getId()); + && contains(val.getTerminalFrom().getVoltageLevel()) + && contains(val.getTerminalTo().getVoltageLevel()); return valInSubnetwork ? val : null; } diff --git a/iidm/iidm-tck/src/test/java/com/powsybl/iidm/network/tck/AbstractSubnetworksCreationTest.java b/iidm/iidm-tck/src/test/java/com/powsybl/iidm/network/tck/AbstractSubnetworksCreationTest.java index ebe211b0634..a499076dea2 100644 --- a/iidm/iidm-tck/src/test/java/com/powsybl/iidm/network/tck/AbstractSubnetworksCreationTest.java +++ b/iidm/iidm-tck/src/test/java/com/powsybl/iidm/network/tck/AbstractSubnetworksCreationTest.java @@ -364,6 +364,17 @@ public void testAngleVoltageLimitCreation() { vla3.remove(); vla4.remove(); + // Test VoltageAngleLimit retrieval + assertEquals(vla0, network.getVoltageAngleLimit("vla0")); + assertEquals(vla1, network.getVoltageAngleLimit("vla1")); + assertEquals(vla2, network.getVoltageAngleLimit("vla2")); + assertNull(subnetwork1.getVoltageAngleLimit("vla0")); + assertEquals(vla1, subnetwork1.getVoltageAngleLimit("vla1")); + assertNull(subnetwork1.getVoltageAngleLimit("vla2")); + assertNull(subnetwork2.getVoltageAngleLimit("vla0")); + assertNull(subnetwork2.getVoltageAngleLimit("vla1")); + assertEquals(vla2, subnetwork2.getVoltageAngleLimit("vla2")); + // Detach all assertTrue(subnetwork1.isDetachable()); assertTrue(subnetwork2.isDetachable());