Skip to content

Commit

Permalink
Sonar be happy
Browse files Browse the repository at this point in the history
Signed-off-by: BAUDRIER Dimitri <dimitri.baudrier@rte-france.com>
  • Loading branch information
BAUDRIER Dimitri committed Nov 18, 2022
1 parent 173ae6f commit 11910e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class DynawoResultsMergeLoads {
private static final String MERGE_LOAD_PREFIX_ID = "merged_load_.";
private final String idNetwork;
private final Map<String, List<InfoLoad>> mapLoadsToMergePerBus = new HashMap<>();
private final String WRONG_NETWORK_ASSOCIATION = "Not associated to the right network. Linked to ";
private static final String WRONG_NETWORK_ASSOCIATION = "Not associated to the right network. Linked to ";

class InfoLoad {
private final Load load;
Expand Down Expand Up @@ -86,7 +86,7 @@ public DynawoResultsMergeLoads(String idNetwork) {
}

public void mergeLoads(Network network) throws PowsyblException {
if (idNetwork != network.getId()) {
if (!idNetwork.equals(network.getId())) {
throw new PowsyblException(WRONG_NETWORK_ASSOCIATION + idNetwork);
}
if (mapLoadsToMergePerBus.size() != 0) {
Expand All @@ -98,7 +98,7 @@ public void mergeLoads(Network network) throws PowsyblException {
}

public void unmergeLoads(Network network) throws PowsyblException {
if (idNetwork != network.getId()) {
if (!idNetwork.equals(network.getId())) {
throw new PowsyblException(WRONG_NETWORK_ASSOCIATION + idNetwork);
}
if (mapLoadsToMergePerBus.size() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import org.junit.Test;

import static com.powsybl.commons.ComparisonUtils.compareTxt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.nio.file.Files;
Expand All @@ -25,7 +25,7 @@ public void exceptionWhenMergingWrongNetwork() {
Network network = Importers.importData("XIIDM", new ResourceDataSource("MicroAssembled", new ResourceSet("/MicroAssembled", "MicroAssembled.xiidm")), null);
DynawoResultsMergeLoads dynawoResultsMergeLoads = new DynawoResultsMergeLoads(network.getId());

Network otherNetwork = Importers.importData("XIIDM", new ResourceDataSource("dummy_network", new ResourceSet("/","dummy_network.xiidm")), null);
Network otherNetwork = Importers.importData("XIIDM", new ResourceDataSource("dummy_network", new ResourceSet("/", "dummy_network.xiidm")), null);

assertThrows("Not associated to the right network. Linked to " + network.getId(), PowsyblException.class, () -> dynawoResultsMergeLoads.mergeLoads(otherNetwork));
}
Expand All @@ -36,7 +36,7 @@ public void exceptionWhenUnmergingWrongNetwork() {
DynawoResultsMergeLoads dynawoResultsMergeLoads = new DynawoResultsMergeLoads(network.getId());
dynawoResultsMergeLoads.mergeLoads(network);

Network otherNetwork = Importers.importData("XIIDM", new ResourceDataSource("dummy_network", new ResourceSet("/","dummy_network.xiidm")), null);
Network otherNetwork = Importers.importData("XIIDM", new ResourceDataSource("dummy_network", new ResourceSet("/", "dummy_network.xiidm")), null);

assertThrows("Not associated to the right network. Linked to " + network.getId(), PowsyblException.class, () -> dynawoResultsMergeLoads.unmergeLoads(otherNetwork));
}
Expand Down Expand Up @@ -67,7 +67,7 @@ public void unmergeLoadsMicroAssembled() throws IOException {
dynawoResultsMergeLoads.mergeLoads(network);
dynawoResultsMergeLoads.unmergeLoads(network);

assertTrue(2 == network.getBusBreakerView().getBus("_81b0e447-181e-4aec-8921-f1dd7813bebc").getLoadStream().count());
assertEquals(2, network.getBusBreakerView().getBus("_81b0e447-181e-4aec-8921-f1dd7813bebc").getLoadStream().count());
Network expectedIidm = Importers.importData("XIIDM", new ResourceDataSource("MicroAssembled", new ResourceSet("/MicroAssembled", "MicroAssembled.xiidm")), null);

compare(expectedIidm, network);
Expand All @@ -90,7 +90,7 @@ public void unmergeLoadsSmallBusBranch() throws IOException {
dynawoResultsMergeLoads.mergeLoads(network);
dynawoResultsMergeLoads.unmergeLoads(network);

assertTrue(2 == network.getBusBreakerView().getBus("_04483c26-c766-11e1-8775-005056c00008").getLoadStream().count());
assertEquals(2, network.getBusBreakerView().getBus("_04483c26-c766-11e1-8775-005056c00008").getLoadStream().count());
Network expectedIidm = Importers.importData("XIIDM", new ResourceDataSource("SmallBusBranch", new ResourceSet("/SmallBusBranch", "SmallBusBranch.xiidm")), null);

compare(expectedIidm, network);
Expand All @@ -113,7 +113,7 @@ public void unmergeLoadsSmallNodeBreaker() throws IOException {
dynawoResultsMergeLoads.mergeLoads(network);
dynawoResultsMergeLoads.unmergeLoads(network);

assertTrue(2 == network.getVoltageLevel("_0476c639-c766-11e1-8775-005056c00008").getLoadStream().count());
assertEquals(2, network.getVoltageLevel("_0476c639-c766-11e1-8775-005056c00008").getLoadStream().count());
Network expectedIidm = Importers.importData("XIIDM", new ResourceDataSource("SmallNodeBreaker_fix_line_044bbe91", new ResourceSet("/SmallNodeBreaker", "SmallNodeBreaker_fix_line_044bbe91.xiidm")), null);

compare(expectedIidm, network);
Expand Down

0 comments on commit 11910e1

Please sign in to comment.