Skip to content
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

Fix unit tests #348

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -10,10 +10,7 @@
import com.powsybl.sld.NetworkGraphBuilder;
import com.powsybl.sld.iidm.AbstractTestCaseIidm;
import com.powsybl.sld.iidm.extensions.ConnectablePosition;
import com.powsybl.sld.model.Edge;
import com.powsybl.sld.model.FeederNode;
import com.powsybl.sld.model.Node;
import com.powsybl.sld.model.VoltageLevelGraph;
import com.powsybl.sld.model.*;
import com.powsybl.sld.svg.DefaultDiagramLabelProvider;
import com.powsybl.sld.svg.DiagramStyles;
import com.powsybl.sld.svg.FeederInfo;
Expand Down Expand Up @@ -104,7 +101,7 @@ public List<FeederInfo> getFeederInfos(FeederNode node) {

@Test
public void testAttributes() {
// construction des graphes
// building graphs
VoltageLevelGraph graph1 = graphBuilder.buildVoltageLevelGraph(vl1.getId(), true);
VoltageLevelGraph graph2 = graphBuilder.buildVoltageLevelGraph(vl2.getId(), true);
VoltageLevelGraph graph3 = graphBuilder.buildVoltageLevelGraph(vl3.getId(), true);
Expand Down Expand Up @@ -146,21 +143,24 @@ public void testAttributes() {
}

@Test
public void testVl1() {
VoltageLevelGraph graph1 = graphBuilder.buildVoltageLevelGraph(vl1.getId(), true);
assertEquals(toString("/vl1_nominal_voltage_style.svg"), toSVG(graph1, "/vl1_nominal_voltage_style.svg", new NoFeederInfoProvider(), styleProvider));
public void testSubstation() {
SubstationGraph graph = graphBuilder.buildSubstationGraph(substation.getId());
substationGraphLayout(graph);
assertEquals(toString("/nominal_voltage_style_substation.svg"), toSVG(graph, "/nominal_voltage_style_substation.svg", new NoFeederInfoProvider(), styleProvider));
}

@Test
public void testVl2() {
VoltageLevelGraph graph2 = graphBuilder.buildVoltageLevelGraph(vl2.getId(), true);
assertEquals(toString("/vl2_nominal_voltage_style.svg"), toSVG(graph2, "/vl2_nominal_voltage_style.svg", new NoFeederInfoProvider(), styleProvider));
voltageLevelGraphLayout(graph2);
assertEquals(toString("/nominal_voltage_style_vl2.svg"), toSVG(graph2, "/nominal_voltage_style_vl2.svg", new NoFeederInfoProvider(), styleProvider));
}

@Test
public void testVl3() {
VoltageLevelGraph graph3 = graphBuilder.buildVoltageLevelGraph(vl3.getId(), true);
assertEquals(toString("/vl3_nominal_voltage_style.svg"), toSVG(graph3, "/vl3_nominal_voltage_style.svg", new NoFeederInfoProvider(), styleProvider));
voltageLevelGraphLayout(graph3);
assertEquals(toString("/nominal_voltage_style_vl3.svg"), toSVG(graph3, "/nominal_voltage_style_vl3.svg", new NoFeederInfoProvider(), styleProvider));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,20 @@
*/
package com.powsybl.sld.util;

import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
import com.powsybl.iidm.network.*;
import com.powsybl.sld.NetworkGraphBuilder;
import com.powsybl.sld.iidm.AbstractTestCaseIidm;
import com.powsybl.sld.iidm.extensions.ConnectablePosition;
import com.powsybl.sld.model.Edge;
import com.powsybl.sld.model.SubstationGraph;
import com.powsybl.sld.model.VoltageLevelGraph;
import com.powsybl.sld.model.Node;
import com.powsybl.sld.svg.DiagramStyleProvider;
import com.powsybl.sld.svg.DiagramStyles;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

import static org.junit.Assert.assertEquals;
Expand All @@ -37,8 +34,6 @@ public class TopologicalStyleTest extends AbstractTestCaseIidm {
VoltageLevel vl1;
VoltageLevel vl2;
VoltageLevel vl3;
private FileSystem fileSystem;
private Path tmpDir;

@Before
public void setUp() throws IOException {
Expand Down Expand Up @@ -84,14 +79,16 @@ public void setUp() throws IOException {
createSwitch(vl2, "b3WT_2", "b3WT_2", SwitchKind.BREAKER, true, true, true, 3, 4);
createSwitch(vl3, "d3WT_3", "d3WT_3", SwitchKind.DISCONNECTOR, false, false, true, 0, 2);
createSwitch(vl3, "b3WT_3", "b3WT_3", SwitchKind.BREAKER, true, false, true, 1, 2);
}

fileSystem = Jimfs.newFileSystem(Configuration.unix());
tmpDir = Files.createDirectory(fileSystem.getPath("/tmp"));
@Override
protected DiagramStyleProvider getDefaultDiagramStyleProvider() {
return new TopologicalStyleProvider(network);
}

@Test
public void test() throws IOException {
// construction des graphes
// building graphs
VoltageLevelGraph graph1 = graphBuilder.buildVoltageLevelGraph(vl1.getId(), true);
VoltageLevelGraph graph2 = graphBuilder.buildVoltageLevelGraph(vl2.getId(), true);
VoltageLevelGraph graph3 = graphBuilder.buildVoltageLevelGraph(vl3.getId(), true);
Expand Down Expand Up @@ -140,6 +137,12 @@ public void test() throws IOException {
assertEquals(2, nodeStyle3.size());
assertTrue(nodeStyle3.contains("sld-busbar-section"));
assertTrue(nodeStyle3.contains(DiagramStyles.DISCONNECTED_STYLE_CLASS));
}

@Test
public void testSubstation() {
SubstationGraph graph = graphBuilder.buildSubstationGraph(substation.getId());
substationGraphLayout(graph);
assertEquals(toString("/topological_style_substation.svg"), toSVG(graph, "/topological_style_substation.svg"));
}
}
Loading