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

implement remove for danglingLines #54

Merged
merged 11 commits into from
Mar 25, 2020
Prev Previous commit
Next Next commit
fix and increase test coverage
Signed-off-by: AbdelHedhili <abdelsalem.hedhili@rte-france.com>
AbdelHedhili committed Mar 4, 2020
commit e1cb0228f480e651b1f5aaba77aa5218312db7a5
Original file line number Diff line number Diff line change
@@ -506,11 +506,13 @@ public int getDanglingLineCount(UUID networkUuid) {

@Override
public void removeDanglingLine(UUID networkUuid, String danglingLineId) {
resources.delete("/networks/{networkUuid}/dangling-lines/{danglingLineId}");
resources.delete("/networks/{networkUuid}/dangling-lines/{danglingLineId}", networkUuid, danglingLineId);
}

public void removeDanglingLines(UUID networkUuid, List<String> danglingLinesId) {
danglingLinesId.forEach(danglingLineId -> removeDanglingLine(networkUuid, danglingLineId));
if (!danglingLinesId.isEmpty()) {
danglingLinesId.forEach(danglingLineId -> removeDanglingLine(networkUuid, danglingLineId));
}
}

//ConfiguredBus
Original file line number Diff line number Diff line change
@@ -776,6 +776,35 @@ public void testDanglingLineRemove() {
assertEquals(1, networkIds.size());
Network readNetwork = service.getNetwork(networkIds.keySet().stream().findFirst().get());
assertEquals(1, readNetwork.getDanglingLineCount());
service.flush(readNetwork);
}

try (NetworkStoreService service = new NetworkStoreService(getBaseUrl())) {
Map<UUID, String> networkIds = service.getNetworkIds();
assertEquals(1, networkIds.size());
Network readNetwork = service.getNetwork(networkIds.keySet().stream().findFirst().get());
assertEquals(1, readNetwork.getDanglingLineCount());
readNetwork.getDanglingLine("dl1").remove();
readNetwork.getVoltageLevel("VL1").newDanglingLine().setName("dl1").setId("dl1").add();
readNetwork.getVoltageLevel("VL1").newDanglingLine().setName("dl2").setId("dl2").add();
service.flush(readNetwork);
}

try (NetworkStoreService service = new NetworkStoreService(getBaseUrl())) {
Map<UUID, String> networkIds = service.getNetworkIds();
assertEquals(1, networkIds.size());
Network readNetwork = service.getNetwork(networkIds.keySet().stream().findFirst().get());
assertEquals(2, readNetwork.getDanglingLineCount());
readNetwork.getDanglingLine("dl2").remove();
service.flush(readNetwork);
}

try (NetworkStoreService service = new NetworkStoreService(getBaseUrl())) {
Map<UUID, String> networkIds = service.getNetworkIds();
assertEquals(1, networkIds.size());
Network readNetwork = service.getNetwork(networkIds.keySet().stream().findFirst().get());
assertEquals(1, readNetwork.getDanglingLineCount());
assertNotNull(readNetwork.getDanglingLine("dl1"));
}
}

@@ -957,7 +986,6 @@ private Network createRemoveDL(NetworkFactory networkFactory) {
.setId("dl1")
.setName("dl1")
.add();
vl1.getNodeBreakerView().setNodeCount(2);
vl1.newGenerator()
.setId("GEN")
.setNode(1)