Skip to content

Commit

Permalink
Fix traverser in CalculatedBusImpl to handle properly internal connec…
Browse files Browse the repository at this point in the history
…tions (#838) (#841)

Signed-off-by: Mathieu BAGUE <[email protected]>
  • Loading branch information
Mathieu BAGUE authored and miovd committed Jun 25, 2019
1 parent 204e081 commit c434837
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static NodeTerminal findTerminal(NodeBreakerVoltageLevel voltageLevel, T

// Traverse the graph until a valid NodeTerminal is found
VoltageLevel.NodeBreakerView.Traverser traverser = (node1, sw, node2) -> {
if (sw.isOpen()) {
if (sw != null && sw.isOpen()) {
return false;
}
terminal[0] = (NodeTerminal) voltageLevel.getNodeBreakerView().getTerminal(node2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

/**
* ArrayIndexOutOfBoundsException fix test
Expand Down Expand Up @@ -48,4 +49,27 @@ public void test() {
network = createNetwork(true);
assertEquals(2, network.getVoltageLevel("VL").getBusBreakerView().getBusStream().count());
}

@Test
public void testNullPointer() {
Network network = createNetwork(true);

VoltageLevel vl = network.getVoltageLevel("VL");
vl.getNodeBreakerView()
.setNodeCount(3)
.newInternalConnection()
.setId("IC")
.setNode1(1)
.setNode2(2)
.add();

Load l1 = vl.newLoad()
.setId("L1")
.setNode(0)
.setP0(100.0)
.setQ0(50.0)
.add();

assertNotNull(l1.getTerminal().getBusBreakerView().getBus());
}
}

0 comments on commit c434837

Please sign in to comment.