diff --git a/src/main/java/org/gridsuite/network/map/NetworkMapController.java b/src/main/java/org/gridsuite/network/map/NetworkMapController.java index b85a6d90..58655760 100644 --- a/src/main/java/org/gridsuite/network/map/NetworkMapController.java +++ b/src/main/java/org/gridsuite/network/map/NetworkMapController.java @@ -16,6 +16,7 @@ import lombok.AllArgsConstructor; import org.gridsuite.network.map.dto.*; import org.gridsuite.network.map.dto.definition.hvdc.HvdcShuntCompensatorsInfos; +import org.gridsuite.network.map.dto.definition.topology.TopologyInfos; import org.gridsuite.network.map.services.NetworkMapService; import org.springframework.context.annotation.ComponentScan; import org.springframework.web.bind.annotation.*; @@ -98,6 +99,15 @@ public List getVoltageLevelSwitches(@Parameter(description = "Netwo return networkMapService.getVoltageLevelSwitches(networkUuid, voltageLevelId, variantId); } + @GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/topology", produces = APPLICATION_JSON_VALUE) + @Operation(summary = "Get the voltage level topology description") + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Network topology information retrieved")}) + public TopologyInfos getVoltageLevelTopology(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid, + @Parameter(description = "Voltage level id") @PathVariable("voltageLevelId") String voltageLevelId, + @Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId) { + return networkMapService.getVoltageLevelTopology(networkUuid, voltageLevelId, variantId); + } + @GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/substation-id", produces = APPLICATION_JSON_VALUE) @Operation(summary = "Get substation ID for a voltage level") @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "substation ID for a voltage level")}) diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/topology/FeederBayInfos.java similarity index 90% rename from src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java rename to src/main/java/org/gridsuite/network/map/dto/definition/topology/FeederBayInfos.java index 0a22a6ca..b268c116 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/FeederBayInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/topology/FeederBayInfos.java @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package org.gridsuite.network.map.dto.definition.voltagelevel; +package org.gridsuite.network.map.dto.definition.topology; import com.powsybl.iidm.network.TwoSides; import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/topology/TopologyInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/topology/TopologyInfos.java new file mode 100644 index 00000000..23012d59 --- /dev/null +++ b/src/main/java/org/gridsuite/network/map/dto/definition/topology/TopologyInfos.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2025, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.gridsuite.network.map.dto.definition.topology; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.powsybl.iidm.network.SwitchKind; +import com.powsybl.iidm.network.TopologyKind; +import lombok.Getter; +import lombok.experimental.SuperBuilder; + +import java.util.List; +import java.util.Map; + +/** + * @author Etienne Lesot + */ +@SuperBuilder +@Getter +public class TopologyInfos { + @JsonInclude(JsonInclude.Include.NON_NULL) + private TopologyKind topologyKind; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer busbarCount; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer sectionCount; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private List switchKinds; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private Boolean isSymmetrical; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private Boolean isBusbarSectionPositionExtensionFound; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map> busBarSectionsInfos; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private Map> feederBaysInfos; +} diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java index 9ede0d8b..2700df97 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/voltagelevel/VoltageLevelFormInfos.java @@ -7,15 +7,12 @@ package org.gridsuite.network.map.dto.definition.voltagelevel; import com.fasterxml.jackson.annotation.JsonInclude; -import com.powsybl.iidm.network.SwitchKind; import com.powsybl.iidm.network.TopologyKind; import lombok.Getter; import lombok.experimental.SuperBuilder; import org.gridsuite.network.map.dto.ElementInfosWithProperties; import org.gridsuite.network.map.dto.definition.extension.IdentifiableShortCircuitInfos; -import java.util.List; -import java.util.Map; import java.util.Optional; /** @@ -41,25 +38,4 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties { @JsonInclude(JsonInclude.Include.NON_ABSENT) private Optional identifiableShortCircuit; - - @JsonInclude(JsonInclude.Include.NON_NULL) - private Integer busbarCount; - - @JsonInclude(JsonInclude.Include.NON_NULL) - private Integer sectionCount; - - @JsonInclude(JsonInclude.Include.NON_NULL) - private List switchKinds; - - @JsonInclude(JsonInclude.Include.NON_NULL) - private Boolean isRetrievedBusbarSections; - - @JsonInclude(JsonInclude.Include.NON_NULL) - private Boolean isBusbarSectionPositionFound; - - @JsonInclude(JsonInclude.Include.NON_NULL) - private Map> busBarSectionInfos; - - @JsonInclude(JsonInclude.Include.NON_NULL) - private Map> feederBaysInfos; } diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java index 76547d09..411a7c05 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/VoltageLevelInfosMapper.java @@ -6,25 +6,17 @@ */ package org.gridsuite.network.map.dto.mapper; -import com.powsybl.iidm.network.*; -import com.powsybl.iidm.network.extensions.BusbarSectionPosition; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; +import com.powsybl.iidm.network.Identifiable; +import com.powsybl.iidm.network.Substation; +import com.powsybl.iidm.network.VoltageLevel; import org.gridsuite.network.map.dto.ElementInfos; import org.gridsuite.network.map.dto.InfoTypeParameters; -import org.gridsuite.network.map.dto.definition.busbarsection.BusBarSectionFormInfos; -import org.gridsuite.network.map.dto.definition.voltagelevel.FeederBayInfos; import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelFormInfos; import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelMapInfos; import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelTabInfos; import org.gridsuite.network.map.dto.utils.ElementUtils; import org.gridsuite.network.map.dto.utils.ExtensionUtils; -import java.util.*; -import java.util.stream.Collectors; - -import static com.powsybl.iidm.network.Terminal.getConnectableSide; import static org.gridsuite.network.map.dto.utils.ElementUtils.*; /** @@ -44,53 +36,9 @@ public static ElementInfos toData(Identifiable identifiable, InfoTypeParamete }; } - private static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLevel) { - Map nbSectionsPerBusbar = new HashMap<>(); - List busbarSectionInfos = new ArrayList<>(); - int maxBusbarIndex = 1; - int maxSectionIndex = 1; - boolean busbarSectionPositionFound = true; - for (BusbarSection bbs : voltageLevel.getNodeBreakerView().getBusbarSections()) { - var extension = bbs.getExtension(BusbarSectionPosition.class); - if (extension == null) { - busbarSectionPositionFound = false; - break; - } - int busbarIndex = extension.getBusbarIndex(); - int sectionIndex = extension.getSectionIndex(); - maxBusbarIndex = Math.max(maxBusbarIndex, busbarIndex); - maxSectionIndex = Math.max(maxSectionIndex, sectionIndex); - nbSectionsPerBusbar.merge(busbarIndex, 1, Integer::sum); - busbarSectionInfos.add(BusBarSectionFormInfos.builder() - .id(bbs.getId()) - .vertPos(sectionIndex) - .horizPos(busbarIndex) - .build()); - } - VoltageLevelTopologyInfos voltageLevelTopologyInfos = createDefaultTopologyInfosBuilder().build(); - if (!busbarSectionPositionFound) { - return voltageLevelTopologyInfos; - } - - voltageLevelTopologyInfos.setBusbarSections(busbarSectionInfos); - voltageLevelTopologyInfos.setBusbarSectionPositionFound(true); - - boolean isSymmetrical = maxBusbarIndex == 1 || - nbSectionsPerBusbar.values().stream().distinct().count() == 1 - && nbSectionsPerBusbar.values().stream().findFirst().orElse(0).equals(maxSectionIndex); - - if (isSymmetrical) { - voltageLevelTopologyInfos.setBusbarCount(maxBusbarIndex); - voltageLevelTopologyInfos.setSectionCount(maxSectionIndex); - voltageLevelTopologyInfos.setRetrievedBusbarSections(true); - voltageLevelTopologyInfos.setSwitchKinds(Collections.nCopies(maxSectionIndex - 1, SwitchKind.DISCONNECTOR)); - } - return voltageLevelTopologyInfos; - } - static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) { VoltageLevel voltageLevel = (VoltageLevel) identifiable; - VoltageLevelFormInfos.VoltageLevelFormInfosBuilder builder = VoltageLevelFormInfos.builder() + return VoltageLevelFormInfos.builder() .name(voltageLevel.getOptionalName().orElse(null)) .id(voltageLevel.getId()) .topologyKind(voltageLevel.getTopologyKind()) @@ -98,44 +46,9 @@ static VoltageLevelFormInfos toFormInfos(Identifiable identifiable) { .nominalV(voltageLevel.getNominalV()) .lowVoltageLimit(Double.isNaN(voltageLevel.getLowVoltageLimit()) ? null : voltageLevel.getLowVoltageLimit()) .highVoltageLimit(Double.isNaN(voltageLevel.getHighVoltageLimit()) ? null : voltageLevel.getHighVoltageLimit()) - .properties(getProperties(voltageLevel)); - - if (voltageLevel.getTopologyKind().equals(TopologyKind.NODE_BREAKER)) { - VoltageLevelTopologyInfos vlTopologyInfos = getTopologyInfos(voltageLevel); - builder.busbarCount(vlTopologyInfos.getBusbarCount()); - builder.sectionCount(vlTopologyInfos.getSectionCount()); - builder.switchKinds(vlTopologyInfos.getSwitchKinds()); - builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections()); - builder.isBusbarSectionPositionFound(vlTopologyInfos.isBusbarSectionPositionFound()); - builder.busBarSectionInfos(vlTopologyInfos.getBusBarSectionInfosGrouped()); - builder.feederBaysInfos(getFeederBaysInfos(voltageLevel)); - } - - builder.identifiableShortCircuit(ExtensionUtils.toIdentifiableShortCircuit(voltageLevel)); - - return builder.build(); - } - - private static Map> getFeederBaysInfos(VoltageLevel voltageLevel) { - Map> feederBayInfos = new HashMap<>(); - String currentVoltageLevelId = voltageLevel.getId(); - voltageLevel.getConnectableStream() - .filter(connectable -> !(connectable instanceof BusbarSection)) - .forEach(connectable -> { - List connections = new ArrayList<>(); - for (Object obj : connectable.getTerminals()) { - Terminal terminal = (Terminal) obj; - if (terminal.getVoltageLevel().getId().equals(currentVoltageLevelId)) { - connections.add(new FeederBayInfos( - getBusOrBusbarSection(terminal), - getConnectablePosition(connectable, FeederSide.from(getConnectableSide(terminal))), - getConnectableSide(terminal).map(ThreeSides::toTwoSides).orElse(null) - )); - } - } - feederBayInfos.put(connectable.getId(), connections); - }); - return feederBayInfos; + .properties(getProperties(voltageLevel)) + .identifiableShortCircuit(ExtensionUtils.toIdentifiableShortCircuit(voltageLevel)) + .build(); } static VoltageLevelMapInfos toMapInfos(Identifiable identifiable) { @@ -165,36 +78,4 @@ static VoltageLevelTabInfos toTabInfos(Identifiable identifiable) { return builder.build(); } - - private static VoltageLevelTopologyInfos.VoltageLevelTopologyInfosBuilder createDefaultTopologyInfosBuilder() { - return VoltageLevelTopologyInfos.builder() - .busbarCount(1).sectionCount(1).isRetrievedBusbarSections(false) - .switchKinds(List.of()).busbarSections(List.of()).isBusbarSectionPositionFound(false); - } - - @Builder - @Getter - @Setter - public static class VoltageLevelTopologyInfos { - private List busbarSections; - private boolean isRetrievedBusbarSections; // true if busbar sections are symmetrical - private boolean isBusbarSectionPositionFound; - private int busbarCount; - private int sectionCount; - private List switchKinds; - - public Map> getBusBarSectionInfosGrouped() { - return busbarSections.stream() - .collect(Collectors.groupingBy( - section -> String.valueOf(section.getHorizPos()), - Collectors.collectingAndThen( - Collectors.toList(), - list -> list.stream() - .sorted(Comparator.comparing(BusBarSectionFormInfos::getVertPos)) - .map(BusBarSectionFormInfos::getId) - .toList() - ) - )); - } - } } diff --git a/src/main/java/org/gridsuite/network/map/dto/utils/TopologyUtils.java b/src/main/java/org/gridsuite/network/map/dto/utils/TopologyUtils.java new file mode 100644 index 00000000..14edead4 --- /dev/null +++ b/src/main/java/org/gridsuite/network/map/dto/utils/TopologyUtils.java @@ -0,0 +1,117 @@ +/** + * Copyright (c) 2025, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.gridsuite.network.map.dto.utils; + +import com.powsybl.iidm.network.*; +import com.powsybl.iidm.network.extensions.BusbarSectionPosition; +import org.gridsuite.network.map.dto.definition.busbarsection.BusBarSectionFormInfos; +import org.gridsuite.network.map.dto.definition.topology.FeederBayInfos; +import org.gridsuite.network.map.dto.definition.topology.TopologyInfos; + +import java.util.*; +import java.util.stream.Collectors; + +import static com.powsybl.iidm.network.Terminal.getConnectableSide; +import static org.gridsuite.network.map.dto.utils.ElementUtils.getBusOrBusbarSection; +import static org.gridsuite.network.map.dto.utils.ElementUtils.getConnectablePosition; + +/** + * @author Etienne Lesot + */ +public final class TopologyUtils { + + private TopologyUtils() { + } + + public static TopologyInfos getTopologyInfos(VoltageLevel voltageLevel) { + Map nbSectionsPerBusbar = new HashMap<>(); + List busbarSectionInfos = new ArrayList<>(); + int maxBusbarIndex = 1; + int maxSectionIndex = 1; + boolean busbarSectionPositionFound = true; + for (BusbarSection bbs : voltageLevel.getNodeBreakerView().getBusbarSections()) { + var extension = bbs.getExtension(BusbarSectionPosition.class); + if (extension == null) { + busbarSectionPositionFound = false; + break; + } + int busbarIndex = extension.getBusbarIndex(); + int sectionIndex = extension.getSectionIndex(); + maxBusbarIndex = Math.max(maxBusbarIndex, busbarIndex); + maxSectionIndex = Math.max(maxSectionIndex, sectionIndex); + nbSectionsPerBusbar.merge(busbarIndex, 1, Integer::sum); + busbarSectionInfos.add(BusBarSectionFormInfos.builder() + .id(bbs.getId()) + .vertPos(sectionIndex) + .horizPos(busbarIndex) + .build()); + } + TopologyInfos.TopologyInfosBuilder voltageLevelTopologyInfos = createDefaultTopologyInfosBuilder(); + if (!busbarSectionPositionFound) { + return voltageLevelTopologyInfos.build(); + } + + voltageLevelTopologyInfos.busBarSectionsInfos(busbarSectionInfos.stream() + .collect(Collectors.groupingBy( + section -> String.valueOf(section.getHorizPos()), + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.stream() + .sorted(Comparator.comparing(BusBarSectionFormInfos::getVertPos)) + .map(BusBarSectionFormInfos::getId) + .toList() + ) + ))); + voltageLevelTopologyInfos.isBusbarSectionPositionExtensionFound(true); + + boolean isSymmetrical = maxBusbarIndex == 1 || + nbSectionsPerBusbar.values().stream().distinct().count() == 1 + && nbSectionsPerBusbar.values().stream().findFirst().orElse(0).equals(maxSectionIndex); + + if (isSymmetrical) { + voltageLevelTopologyInfos.busbarCount(maxBusbarIndex); + voltageLevelTopologyInfos.sectionCount(maxSectionIndex); + voltageLevelTopologyInfos.isSymmetrical(true); + voltageLevelTopologyInfos.switchKinds(Collections.nCopies(maxSectionIndex - 1, SwitchKind.DISCONNECTOR)); + } + voltageLevelTopologyInfos.feederBaysInfos(getFeederBaysInfos(voltageLevel)); + return voltageLevelTopologyInfos.build(); + } + + public static Map> getFeederBaysInfos(VoltageLevel voltageLevel) { + Map> feederBayInfos = new HashMap<>(); + String currentVoltageLevelId = voltageLevel.getId(); + voltageLevel.getConnectableStream() + .filter(connectable -> !(connectable instanceof BusbarSection)) + .forEach(connectable -> { + List connections = new ArrayList<>(); + for (Object obj : connectable.getTerminals()) { + Terminal terminal = (Terminal) obj; + if (terminal.getVoltageLevel().getId().equals(currentVoltageLevelId)) { + connections.add(new FeederBayInfos( + getBusOrBusbarSection(terminal), + getConnectablePosition(connectable, ElementUtils.FeederSide.from(getConnectableSide(terminal))), + getConnectableSide(terminal).map(ThreeSides::toTwoSides).orElse(null) + )); + } + } + feederBayInfos.put(connectable.getId(), connections); + }); + return feederBayInfos; + } + + private static TopologyInfos.TopologyInfosBuilder createDefaultTopologyInfosBuilder() { + return TopologyInfos.builder() + .busbarCount(1) + .sectionCount(1) + .isSymmetrical(false) + .switchKinds(List.of()) + .busBarSectionsInfos(Map.of()) + .isBusbarSectionPositionExtensionFound(false) + .topologyKind(TopologyKind.NODE_BREAKER); + } +} diff --git a/src/main/java/org/gridsuite/network/map/services/NetworkMapService.java b/src/main/java/org/gridsuite/network/map/services/NetworkMapService.java index 95a26f6b..9b178805 100644 --- a/src/main/java/org/gridsuite/network/map/services/NetworkMapService.java +++ b/src/main/java/org/gridsuite/network/map/services/NetworkMapService.java @@ -14,8 +14,10 @@ import lombok.AllArgsConstructor; import org.gridsuite.network.map.dto.*; import org.gridsuite.network.map.dto.definition.hvdc.HvdcShuntCompensatorsInfos; +import org.gridsuite.network.map.dto.definition.topology.TopologyInfos; import org.gridsuite.network.map.dto.mapper.ElementInfosMapper; import org.gridsuite.network.map.dto.mapper.HvdcInfosMapper; +import org.gridsuite.network.map.dto.utils.TopologyUtils; import org.springframework.context.annotation.ComponentScan; import org.springframework.http.HttpStatus; import org.springframework.lang.NonNull; @@ -136,6 +138,15 @@ public List getVoltageLevelSwitches(UUID networkUuid, String voltag return switchInfosList; } + public TopologyInfos getVoltageLevelTopology(UUID networkUuid, String voltageLevelId, String variantId) { + Network network = getNetwork(networkUuid, PreloadingStrategy.NONE, variantId); + VoltageLevel voltageLevel = network.getVoltageLevel(voltageLevelId); + if (voltageLevel.getTopologyKind().equals(TopologyKind.NODE_BREAKER)) { + return TopologyUtils.getTopologyInfos(voltageLevel); + } + return TopologyInfos.builder().topologyKind(TopologyKind.BUS_BREAKER).build(); + } + public String getVoltageLevelSubstationID(UUID networkUuid, String voltageLevelId, String variantId) { Network network = getNetwork(networkUuid, PreloadingStrategy.NONE, variantId); return network.getVoltageLevel(voltageLevelId).getSubstation().map(Substation::getId).orElse(null); diff --git a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java index 12cede0e..11098064 100644 --- a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java +++ b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java @@ -1421,6 +1421,15 @@ private static String resourceToString(String resource) throws IOException { return new String(ByteStreams.toByteArray(NetworkMapControllerTest.class.getResourceAsStream(resource)), StandardCharsets.UTF_8); } + private void succeedingTestForTopologyInfosWithElementId(UUID networkUuid, String variantId, String voltageLevelId, String expectedJson) throws Exception { + MvcResult res = mvc.perform(get("/v1/networks/{networkUuid}/voltage-levels/{voltageLevelId}/topology", networkUuid, voltageLevelId) + .queryParam(QUERY_PARAM_VARIANT_ID, variantId) + ) + .andExpect(status().isOk()) + .andReturn(); + JSONAssert.assertEquals(expectedJson, res.getResponse().getContentAsString(), JSONCompareMode.NON_EXTENSIBLE); + } + private void succeedingTestForElementInfosWithElementId(UUID networkUuid, String variantId, ElementType elementType, InfoType infoType, String elementId, String expectedJson) throws Exception { MvcResult res = mvc.perform(get("/v1/networks/{networkUuid}/elements/{elementId}", networkUuid, elementId) .queryParam(QUERY_PARAM_VARIANT_ID, variantId) @@ -1429,7 +1438,6 @@ private void succeedingTestForElementInfosWithElementId(UUID networkUuid, String ) .andExpect(status().isOk()) .andReturn(); - JSONAssert.assertEquals(expectedJson, res.getResponse().getContentAsString(), JSONCompareMode.NON_EXTENSIBLE); } @@ -2320,11 +2328,12 @@ void shouldReturnVoltageLevelFormData() throws Exception { @Test void shouldReturnVoltageLevelFormDataWithFeederBaysInfos() throws Exception { - succeedingTestForElementInfosWithElementId(NETWORK_UUID, null, ElementType.VOLTAGE_LEVEL, InfoType.FORM, "VLGEN5", resourceToString("/voltage-level-form-data-feederbays.json")); + succeedingTestForTopologyInfosWithElementId(NETWORK_UUID, null, "VLGEN5", resourceToString("/voltage-level-form-data-feederbays.json")); + succeedingTestForTopologyInfosWithElementId(NETWORK_UUID, null, "VLGEN4", resourceToString("/topology-info.json")); } @Test - void shouldReturnVotlageLevelNonSymmetricalBusbarsFormData() throws Exception { + void shouldReturnVoltageLevelNonSymmetricalBusbarsFormData() throws Exception { succeedingTestForElementInfosWithElementId(NETWORK_UUID, null, ElementType.VOLTAGE_LEVEL, InfoType.FORM, "VLGEN5", resourceToString("/voltage-level-non-symmetrical-busbars-form-data.json")); succeedingTestForElementInfosWithElementId(NETWORK_UUID, VARIANT_ID, ElementType.VOLTAGE_LEVEL, InfoType.FORM, "VLGEN5", resourceToString("/voltage-level-non-symmetrical-busbars-form-data.json")); } diff --git a/src/test/resources/substations-form-data.json b/src/test/resources/substations-form-data.json index 345e9493..4559fe6a 100644 --- a/src/test/resources/substations-form-data.json +++ b/src/test/resources/substations-form-data.json @@ -1,9 +1,4 @@ [ - { - "id": "P0", - "country": "FR", - "voltageLevels": [] - }, { "id": "P1", "name": "P1_Name", @@ -14,18 +9,18 @@ "voltageLevels": [ { "id": "VLGEN", + "name": "VLGEN_Name", + "properties": { + "Country": "FR" + }, "topologyKind": "BUS_BREAKER", "substationId": "P1", "nominalV": 24.0, - "name": "VLGEN_Name", "lowVoltageLimit": 200.0, "highVoltageLimit": 400.0, "identifiableShortCircuit": { "ipMin": 10.0, "ipMax": 120.0 - }, - "properties": { - "Country": "FR" } }, { @@ -36,12 +31,12 @@ }, { "id": "VLNEW2", - "topologyKind": "BUS_BREAKER", - "substationId": "P1", - "nominalV": 225.0, "properties": { "Country": "FR" - } + }, + "topologyKind": "BUS_BREAKER", + "substationId": "P1", + "nominalV": 225.0 } ] }, @@ -62,6 +57,11 @@ } ] }, + { + "id": "P0", + "country": "FR", + "voltageLevels": [] + }, { "id": "P3", "properties": { @@ -97,46 +97,7 @@ "id": "VLGEN4", "topologyKind": "NODE_BREAKER", "substationId": "P4", - "nominalV": 24.0, - "busbarCount": 1, - "sectionCount": 2, - "switchKinds": ["DISCONNECTOR"], - "isRetrievedBusbarSections": true, - "isBusbarSectionPositionFound": true, - "busBarSectionInfos" : { - "1" : ["NGEN4"] - }, - "feederBaysInfos": { - "SHUNT_VLNB": [ - { - "busbarSectionId": "NGEN4", - "connectablePositionInfos": { - "connectionDirection": null - }, - "connectionSide": null - } - ], - "LINE7": [ - { - "busbarSectionId": "NGEN4", - "connectablePositionInfos": { - "connectionDirection": "BOTTOM", - "connectionPosition": 5, - "connectionName": "LINE7_Side_VLGEN4" - }, - "connectionSide": "ONE" - } - ], - "SHUNT_NON_LINEAR": [ - { - "busbarSectionId": "NGEN4", - "connectablePositionInfos": { - "connectionDirection": null - }, - "connectionSide": null - } - ] - } + "nominalV": 24.0 } ] }, @@ -154,26 +115,7 @@ "identifiableShortCircuit": { "ipMin": 0.0, "ipMax": 100.0 - }, - "busbarCount": 1, - "sectionCount": 1, - "switchKinds": [], - "isRetrievedBusbarSections": false, - "isBusbarSectionPositionFound": true, - "busBarSectionInfos" : { - "1" : [ "NGEN5"], - "2" : [ "NGEN5_2_1", "NGEN5_2_2"] - }, - "busBarSectionInfos": { - "1": [ - "NGEN5" - ], - "2": [ - "NGEN5_2_1", - "NGEN5_2_2" - ] - }, - "feederBaysInfos": {} + } }, { "id": "VLGEN7", @@ -181,26 +123,7 @@ "substationId": "P5", "nominalV": 24.0, "lowVoltageLimit": 20.0, - "highVoltageLimit": 30.0, - "busbarCount": 1, - "sectionCount": 1, - "switchKinds": [], - "isRetrievedBusbarSections": false, - "isBusbarSectionPositionFound": false, - "busBarSectionInfos": {}, - "feederBaysInfos": { - "LINE7": [ - { - "busbarSectionId": "NGEN7", - "connectablePositionInfos": { - "connectionDirection": "TOP", - "connectionPosition": 3, - "connectionName": "LINE7_Side_VLGEN8" - }, - "connectionSide": "TWO" - } - ] - } + "highVoltageLimit": 30.0 } ] } diff --git a/src/test/resources/topology-info.json b/src/test/resources/topology-info.json new file mode 100644 index 00000000..ec122c51 --- /dev/null +++ b/src/test/resources/topology-info.json @@ -0,0 +1,46 @@ +{ + "topologyKind": "NODE_BREAKER", + "busbarCount": 1, + "sectionCount": 2, + "switchKinds": [ + "DISCONNECTOR" + ], + "isSymmetrical": true, + "isBusbarSectionPositionExtensionFound": true, + "busBarSectionsInfos": { + "1": [ + "NGEN4" + ] + }, + "feederBaysInfos": { + "SHUNT_VLNB": [ + { + "busbarSectionId": "NGEN4", + "connectablePositionInfos": { + "connectionDirection": null + }, + "connectionSide": null + } + ], + "LINE7": [ + { + "busbarSectionId": "NGEN4", + "connectablePositionInfos": { + "connectionDirection": "BOTTOM", + "connectionPosition": 5, + "connectionName": "LINE7_Side_VLGEN4" + }, + "connectionSide": "ONE" + } + ], + "SHUNT_NON_LINEAR": [ + { + "busbarSectionId": "NGEN4", + "connectablePositionInfos": { + "connectionDirection": null + }, + "connectionSide": null + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/voltage-level-form-data-feederbays.json b/src/test/resources/voltage-level-form-data-feederbays.json index 5c2833b7..92f900f3 100644 --- a/src/test/resources/voltage-level-form-data-feederbays.json +++ b/src/test/resources/voltage-level-form-data-feederbays.json @@ -1,20 +1,11 @@ { - "id": "VLGEN5", "topologyKind": "NODE_BREAKER", - "substationId": "P5", - "nominalV": 24.0, - "lowVoltageLimit": 20.0, - "highVoltageLimit": 30.0, - "identifiableShortCircuit": { - "ipMin": 0.0, - "ipMax": 100.0 - }, "busbarCount": 1, "sectionCount": 1, "switchKinds": [], - "isRetrievedBusbarSections": false, - "isBusbarSectionPositionFound": true, - "busBarSectionInfos": { + "isSymmetrical": false, + "isBusbarSectionPositionExtensionFound": true, + "busBarSectionsInfos": { "1": [ "NGEN5" ], diff --git a/src/test/resources/voltage-level-form-data.json b/src/test/resources/voltage-level-form-data.json index 6d10ba78..42d3d322 100644 --- a/src/test/resources/voltage-level-form-data.json +++ b/src/test/resources/voltage-level-form-data.json @@ -1,45 +1,6 @@ { "id": "VLGEN4", - "substationId": "P4", - "nominalV": 24.0, "topologyKind": "NODE_BREAKER", - "busbarCount": 1, - "sectionCount": 2, - "switchKinds": ["DISCONNECTOR"], - "isRetrievedBusbarSections": true, - "isBusbarSectionPositionFound": true, - "busBarSectionInfos" : { - "1" : [ "NGEN4"] - }, - "feederBaysInfos": { - "SHUNT_VLNB": [ - { - "busbarSectionId": "NGEN4", - "connectablePositionInfos": { - "connectionDirection": null - }, - "connectionSide": null - } - ], - "LINE7": [ - { - "busbarSectionId": "NGEN4", - "connectablePositionInfos": { - "connectionDirection": "BOTTOM", - "connectionPosition": 5, - "connectionName": "LINE7_Side_VLGEN4" - }, - "connectionSide": "ONE" - } - ], - "SHUNT_NON_LINEAR": [ - { - "busbarSectionId": "NGEN4", - "connectablePositionInfos": { - "connectionDirection": null - }, - "connectionSide": null - } - ] - } -} + "substationId": "P4", + "nominalV": 24.0 +} \ No newline at end of file diff --git a/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json b/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json index 655749e4..fa5a8bee 100644 --- a/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json +++ b/src/test/resources/voltage-level-non-symmetrical-busbars-form-data.json @@ -8,15 +8,5 @@ "identifiableShortCircuit": { "ipMin": 0.0, "ipMax": 100.0 - }, - "busbarCount": 1, - "sectionCount": 1, - "switchKinds": [], - "isRetrievedBusbarSections": false, - "isBusbarSectionPositionFound": true, - "busBarSectionInfos" : { - "1" : [ "NGEN5"], - "2" : [ "NGEN5_2_1","NGEN5_2_2"] - }, - "feederBaysInfos": {} -} + } +} \ No newline at end of file diff --git a/src/test/resources/voltage-levels-form-data.json b/src/test/resources/voltage-levels-form-data.json index 1b3f7e25..ad6a4979 100644 --- a/src/test/resources/voltage-levels-form-data.json +++ b/src/test/resources/voltage-levels-form-data.json @@ -1,111 +1,74 @@ [ - { - "id": "VL", - "name":"VL", - "nominalV": 24.0, - "topologyKind": "BUS_BREAKER" - }, { "id": "VLGEN", + "name": "VLGEN_Name", + "properties": { + "Country": "FR" + }, + "topologyKind": "BUS_BREAKER", "substationId": "P1", "nominalV": 24.0, - "topologyKind": "BUS_BREAKER", - "name": "VLGEN_Name", "lowVoltageLimit": 200.0, "highVoltageLimit": 400.0, "identifiableShortCircuit": { "ipMin": 10.0, "ipMax": 120.0 - }, - "properties": { - "Country": "FR" } }, { "id": "VLHV1", + "topologyKind": "BUS_BREAKER", "substationId": "P1", - "nominalV": 380.0, - "topologyKind": "BUS_BREAKER" + "nominalV": 380.0 }, { "id": "VLHV2", + "topologyKind": "BUS_BREAKER", "substationId": "P2", - "nominalV": 380.0, - "topologyKind": "BUS_BREAKER" + "nominalV": 380.0 }, { "id": "VLLOAD", + "topologyKind": "BUS_BREAKER", "substationId": "P2", - "nominalV": 150.0, - "topologyKind": "BUS_BREAKER" + "nominalV": 150.0 }, { "id": "VLNEW2", - "substationId": "P1", - "nominalV": 225.0, - "topologyKind": "BUS_BREAKER", "properties": { "Country": "FR" - } + }, + "topologyKind": "BUS_BREAKER", + "substationId": "P1", + "nominalV": 225.0 }, { "id": "VLGEN3", + "topologyKind": "BUS_BREAKER", "substationId": "P3", - "nominalV": 24.0, - "topologyKind": "BUS_BREAKER" + "nominalV": 24.0 + }, + { + "id": "VLGEN6", + "topologyKind": "BUS_BREAKER", + "substationId": "P6", + "nominalV": 24.0 + }, + { + "id": "VL", + "name": "VL", + "topologyKind": "BUS_BREAKER", + "nominalV": 24.0 }, { "id": "VLGEN4", - "substationId": "P4", - "nominalV": 24.0, "topologyKind": "NODE_BREAKER", - "busbarCount": 1, - "sectionCount": 2, - "switchKinds": ["DISCONNECTOR"], - "isRetrievedBusbarSections": true, - "isBusbarSectionPositionFound": true, - "busBarSectionInfos" : { - "1" : [ "NGEN4" ] - }, - "busBarSectionInfos": { - "1": [ - "NGEN4" - ] - }, - "feederBaysInfos": { - "SHUNT_VLNB": [ - { - "busbarSectionId": "NGEN4", - "connectablePositionInfos": { - "connectionDirection": null - }, - "connectionSide": null - } - ], - "LINE7": [ - { - "busbarSectionId": "NGEN4", - "connectablePositionInfos": { - "connectionDirection": "BOTTOM", - "connectionPosition": 5, - "connectionName": "LINE7_Side_VLGEN4" - }, - "connectionSide": "ONE" - } - ], - "SHUNT_NON_LINEAR": [ - { - "busbarSectionId": "NGEN4", - "connectablePositionInfos": { - "connectionDirection": null - }, - "connectionSide": null - } - ] - } + "substationId": "P4", + "nominalV": 24.0 }, { "id": "VLGEN5", + "topologyKind": "NODE_BREAKER", "substationId": "P5", "nominalV": 24.0, "lowVoltageLimit": 20.0, @@ -113,24 +76,7 @@ "identifiableShortCircuit": { "ipMin": 0.0, "ipMax": 100.0 - }, - "topologyKind": "NODE_BREAKER", - "busbarCount": 1, - "sectionCount": 1, - "switchKinds": [], - "isRetrievedBusbarSections": false, - "isBusbarSectionPositionFound": true, - "busBarSectionInfos" : { - "1" : [ "NGEN5"], - "2" : [ "NGEN5_2_1", "NGEN5_2_2" ] - }, - "feederBaysInfos": {} - }, - { - "id": "VLGEN6", - "topologyKind": "BUS_BREAKER", - "substationId": "P6", - "nominalV": 24.0 + } }, { "id": "VLGEN7", @@ -138,25 +84,6 @@ "substationId": "P5", "nominalV": 24.0, "lowVoltageLimit": 20.0, - "highVoltageLimit": 30.0, - "busbarCount": 1, - "sectionCount": 1, - "switchKinds": [], - "isRetrievedBusbarSections": false, - "isBusbarSectionPositionFound": false, - "busBarSectionInfos": {}, - "feederBaysInfos": { - "LINE7": [ - { - "busbarSectionId": "NGEN7", - "connectablePositionInfos": { - "connectionDirection": "TOP", - "connectionPosition": 3, - "connectionName": "LINE7_Side_VLGEN8" - }, - "connectionSide": "TWO" - } - ] - } + "highVoltageLimit": 30.0 } ] \ No newline at end of file