diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c3b2e4a..d9c5541 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 Alliander N.V. +# SPDX-FileCopyrightText: 2022 Alliander N.V. # # SPDX-License-Identifier: Apache-2.0 diff --git a/.github/workflows/automate-projects.yml b/.github/workflows/automate-projects.yml index a34159b..3c61af0 100644 --- a/.github/workflows/automate-projects.yml +++ b/.github/workflows/automate-projects.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 Alliander N.V. +# SPDX-FileCopyrightText: 2022 Alliander N.V. # # SPDX-License-Identifier: Apache-2.0 @@ -12,31 +12,17 @@ jobs: if: ${{ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || (github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target') }} steps: - - name: add-new-issues-to-repository-based-project-column - uses: docker://takanabe/github-actions-automate-projects:v0.0.1 - if: github.event_name == 'issues' && github.event.action == 'opened' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PROJECT_URL: https://github.com/com-pas/compas-scl-auto-alignment/projects/1 - GITHUB_PROJECT_COLUMN_NAME: To do - - name: add-new-pull-request-to-repository-based-project-column - uses: docker://takanabe/github-actions-automate-projects:v0.0.1 - if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'opened' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PROJECT_URL: https://github.com/com-pas/compas-scl-auto-alignment/projects/1 - GITHUB_PROJECT_COLUMN_NAME: To do - name: add-new-issues-to-organization-based-project-column - uses: docker://takanabe/github-actions-automate-projects:v0.0.1 if: github.event_name == 'issues' && github.event.action == 'opened' - env: - GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_ACTION_SECRET }} - GITHUB_PROJECT_URL: https://github.com/orgs/com-pas/projects/1 - GITHUB_PROJECT_COLUMN_NAME: To do + uses: alex-page/github-project-automation-plus@v0.8.1 + with: + project: CoMPAS Issues Overview Board + column: To do + repo-token: ${{ secrets.ORG_GITHUB_ACTION_SECRET }} - name: add-new-pull-request-to-organization-based-project-column - uses: docker://takanabe/github-actions-automate-projects:v0.0.1 if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'opened' - env: - GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_ACTION_SECRET }} - GITHUB_PROJECT_URL: https://github.com/orgs/com-pas/projects/2 - GITHUB_PROJECT_COLUMN_NAME: To do + uses: alex-page/github-project-automation-plus@v0.8.1 + with: + project: CoMPAS Pull Request Overview Board + column: To do + repo-token: ${{ secrets.ORG_GITHUB_ACTION_SECRET }} diff --git a/.github/workflows/build-project.yml b/.github/workflows/build-project.yml index a53620c..493a335 100644 --- a/.github/workflows/build-project.yml +++ b/.github/workflows/build-project.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 Alliander N.V. +# SPDX-FileCopyrightText: 2022 Alliander N.V. # # SPDX-License-Identifier: Apache-2.0 @@ -22,9 +22,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 + - name: Cache Docker Register uses: actions/cache@v3 with: @@ -37,8 +35,11 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 - name: Set up JDK 17 - uses: actions/setup-java@v3.4.1 + uses: actions/setup-java@v3.5.0 with: distribution: 'zulu' java-version: '17' diff --git a/.github/workflows/release-project.yml b/.github/workflows/release-project.yml index fcbf15e..652f0e4 100644 --- a/.github/workflows/release-project.yml +++ b/.github/workflows/release-project.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 Alliander N.V. +# SPDX-FileCopyrightText: 2022 Alliander N.V. # # SPDX-License-Identifier: Apache-2.0 @@ -16,14 +16,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Cache Docker Register uses: actions/cache@v3 with: @@ -39,13 +32,22 @@ jobs: - name: Extract tag name id: extract_tagname shell: bash - # Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/. + # Extract the tag name from the git reference, value of GITHUB_REF will be something like refs/tags/. run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})" + - name: Set up JDK 17 - uses: actions/setup-java@v3.4.1 + uses: actions/setup-java@v3.5.0 with: distribution: 'zulu' java-version: '17' + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} - name: Create custom Maven Settings.xml uses: whelk-io/maven-settings-xml-action@v20 diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml index 70730a7..9ebd56d 100644 --- a/.github/workflows/reuse.yml +++ b/.github/workflows/reuse.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 Alliander N.V. +# SPDX-FileCopyrightText: 2022 Alliander N.V. # # SPDX-License-Identifier: Apache-2.0 diff --git a/.github/workflows/sonarcloud-analysis.yml b/.github/workflows/sonarcloud-analysis.yml index 77f69b0..95a23a2 100644 --- a/.github/workflows/sonarcloud-analysis.yml +++ b/.github/workflows/sonarcloud-analysis.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2021 Alliander N.V. +# SPDX-FileCopyrightText: 2022 Alliander N.V. # # SPDX-License-Identifier: Apache-2.0 @@ -30,11 +30,6 @@ jobs: with: fetch-depth: 0 - - name: Set up JDK 17 - uses: actions/setup-java@v3.4.1 - with: - distribution: 'zulu' - java-version: '17' - name: Cache SonarCloud packages uses: actions/cache@v3 with: @@ -48,20 +43,43 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Set up JDK 17 + uses: actions/setup-java@v3.5.0 + with: + distribution: 'zulu' + java-version: '17' + + - name: Set Common Sonar Variables + id: sonar_env + run: | + echo "##[set-output name=sonar_opts;]$(echo -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.projectKey=com-pas_compas-scl-auto-alignment \ + -Dsonar.organization=com-pas )" - name: Create custom Maven Settings.xml uses: whelk-io/maven-settings-xml-action@v20 with: output_file: custom_maven_settings.xml servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]' - - name: Build and analyze + - name: Build and analyze (Pull Request) + if: ${{ github.event_name == 'pull_request' || (github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + ./mvnw -B -s custom_maven_settings.xml -Psonar \ + ${{ steps.sonar_env.outputs.sonar_opts }} \ + -Dsonar.pullrequest.branch=${{ github.ref_name }} \ + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \ + -Dsonar.pullrequest.base=${{ github.base_ref }} \ + -Dsonar.scm.revision=${{ github.event.pull_request.head.sha }} \ + clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar + - name: Build and analyze (Push) + if: ${{ github.event_name == 'push' }} env: - GITHUB_USERNAME: "OWNER" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - ./mvnw -s custom_maven_settings.xml -B -Psonar \ - -Dsonar.projectKey=com-pas_compas-scl-auto-alignment \ - -Dsonar.organization=com-pas \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \ - clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar + ./mvnw -B -s custom_maven_settings.xml -Psonar \ + ${{ steps.sonar_env.outputs.sonar_opts }} \ + -Dsonar.branch.name=${{ github.ref_name }} \ + clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar diff --git a/pom.xml b/pom.xml index 7841a6b..75ba5e7 100644 --- a/pom.xml +++ b/pom.xml @@ -23,11 +23,11 @@ SPDX-License-Identifier: Apache-2.0 3.0.0-M7 3.2.0 - 0.9.1 + 0.9.3 - 2.11.2.Final - 1.7.36 - 2.12.0 + 2.12.2.Final + 2.0.1 + 2.13.0 2.9.1 0.9.1 @@ -147,7 +147,7 @@ SPDX-License-Identifier: Apache-2.0 org.apache.maven.plugins maven-jar-plugin - 3.2.2 + 3.3.0 @@ -229,7 +229,7 @@ SPDX-License-Identifier: Apache-2.0 org.apache.maven.plugins maven-javadoc-plugin - 3.4.0 + 3.4.1 attach-javadocs diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/SubstationGraphBuilder.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/SubstationGraphBuilder.java index aac9f2b..dadec0a 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/SubstationGraphBuilder.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/SubstationGraphBuilder.java @@ -5,8 +5,7 @@ import com.powsybl.sld.model.graphs.NodeFactory; import com.powsybl.sld.model.graphs.SubstationGraph; -import com.powsybl.sld.model.nodes.Feeder2WTLegNode; -import com.powsybl.sld.model.nodes.Feeder3WTLegNode; +import com.powsybl.sld.model.nodes.FeederNode; import com.powsybl.sld.model.nodes.Node; import org.lfenergy.compas.scl.auto.alignment.exception.SclAutoAlignmentException; import org.lfenergy.compas.scl.auto.alignment.model.*; @@ -70,8 +69,8 @@ private void createPowerTransformer(GenericPowerTransformer powerTransformer) { NodeFactory.createMiddle2WTNode(getGraph(), powerTransformer.getFullName(), powerTransformer.getFullName(), - getFeeder2WTLegNode(tws.get(0)), - getFeeder2WTLegNode(tws.get(1)), + getFeederNode(tws.get(0)), + getFeederNode(tws.get(1)), getVoltageLevelBuilder(tws.get(0)).getGraph().getVoltageLevelInfos(), getVoltageLevelBuilder(tws.get(1)).getGraph().getVoltageLevelInfos(), false)); @@ -81,19 +80,14 @@ private void createPowerTransformer(GenericPowerTransformer powerTransformer) { NodeFactory.createMiddle3WTNode(getGraph(), powerTransformer.getFullName(), powerTransformer.getFullName(), - getFeeder3WTLegNode(tws.get(0)), - getFeeder3WTLegNode(tws.get(1)), - getFeeder3WTLegNode(tws.get(2)))); + getFeederNode(tws.get(0)), + getFeederNode(tws.get(1)), + getFeederNode(tws.get(2)))); } } - private Feeder2WTLegNode getFeeder2WTLegNode(GenericTransformerWinding transformerWinding) { + private FeederNode getFeederNode(GenericTransformerWinding transformerWinding) { var connectivityNode = transformerWinding.getTerminals().get(0).getConnectivityNode(); - return (Feeder2WTLegNode) getNodeByPath(connectivityNode); - } - - private Feeder3WTLegNode getFeeder3WTLegNode(GenericTransformerWinding transformerWinding) { - var connectivityNode = transformerWinding.getTerminals().get(0).getConnectivityNode(); - return (Feeder3WTLegNode) getNodeByPath(connectivityNode); + return (FeederNode) getNodeByPath(connectivityNode); } } diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/VoltageLevelGraphBuilder.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/VoltageLevelGraphBuilder.java index 198fc41..78f601e 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/VoltageLevelGraphBuilder.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/VoltageLevelGraphBuilder.java @@ -3,7 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 package org.lfenergy.compas.scl.auto.alignment.builder; -import com.powsybl.sld.library.ComponentTypeName; import com.powsybl.sld.model.coordinate.Direction; import com.powsybl.sld.model.graphs.BaseGraph; import com.powsybl.sld.model.graphs.NodeFactory; @@ -85,7 +84,7 @@ private void createConnectivityNode(GenericConnectivityNode connectivityNode) { } }, () -> addNode(connectivityNode.getPathName(), - createFictitiousNode(connectivityNode.getPathName())) + createConnectivityNode(connectivityNode.getPathName())) ); } @@ -135,8 +134,8 @@ private void connectNode(Node node1, Node node2) { getGraph().addEdge(node1, node2); } - private FictitiousNode createFictitiousNode(String id) { - return NodeFactory.createFictitiousNode(getGraph(), id, id, id, ComponentTypeName.LINE); + private ConnectivityNode createConnectivityNode(String id) { + return NodeFactory.createConnectivityNode(getGraph(), id); } private FeederNode createLoad(String id, int order) { @@ -145,16 +144,16 @@ private FeederNode createLoad(String id, int order) { return fn; } - public Feeder2WTLegNode createFeeder2WTLegNode(String id, FeederWithSideNode.Side side, int order, - Direction direction) { - Feeder2WTLegNode f2WTe = NodeFactory.createFeeder2WTLegNode(getGraph(), id + "_" + side, id, id, side); + public FeederNode createFeeder2WTLegNode(String id, NodeSide side, int order, + Direction direction) { + var f2WTe = NodeFactory.createFeeder2WTLegNode(getGraph(), id + "_" + side, id, id, side); commonFeederSetting(f2WTe, id, order, direction); return f2WTe; } - public Feeder3WTLegNode createFeeder3WTLegNode(String id, FeederWithSideNode.Side side, int order, - Direction direction) { - Feeder3WTLegNode f3WTe = NodeFactory.createFeeder3WTLegNodeForSubstationDiagram(getGraph(), id + "_" + side, id, id, side); + public FeederNode createFeeder3WTLegNode(String id, NodeSide side, int order, + Direction direction) { + var f3WTe = NodeFactory.createFeeder3WTLegNodeForSubstationDiagram(getGraph(), id + "_" + side, id, id, side); commonFeederSetting(f3WTe, id + side.getIntValue(), order, direction); return f3WTe; } diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/common/CommonUtil.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/common/CommonUtil.java index 28d9a18..3355cd9 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/common/CommonUtil.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/common/CommonUtil.java @@ -6,7 +6,6 @@ import org.w3c.dom.Attr; import org.w3c.dom.Element; -import java.util.stream.Collectors; import java.util.stream.IntStream; import static org.lfenergy.compas.scl.auto.alignment.SclAutoAlignmentConstants.SCLXY_NS_URI; @@ -34,7 +33,7 @@ public static void cleanSXYDeclarationAndAttributes(Element element) { .filter(Attr.class::isInstance) .map(Attr.class::cast) .filter(attr -> SCLXY_NS_URI.equals(attr.getNamespaceURI())) - .collect(Collectors.toList()); + .toList(); // Remove the attribute from the element. attributesToRemove.forEach(element::removeAttributeNode); diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericBay.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericBay.java index 2cd3b96..7cc0526 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericBay.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericBay.java @@ -6,7 +6,6 @@ import org.w3c.dom.Element; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.IntStream; public class GenericBay extends AbstractGenericNameEntity { @@ -33,7 +32,7 @@ public List getConnectivityNodes() { if (connectivityNodes == null) { connectivityNodes = getElementsStream("ConnectivityNode") .map(element -> new GenericConnectivityNode(this, element)) - .collect(Collectors.toList()); + .toList(); } return connectivityNodes; } @@ -42,7 +41,7 @@ public List getConductingEquipments() { if (conductingEquipments == null) { conductingEquipments = getElementsStream("ConductingEquipment") .map(element -> new GenericConductingEquipment(this, element)) - .collect(Collectors.toList()); + .toList(); } return conductingEquipments; } diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericConductingEquipment.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericConductingEquipment.java index 2fd031f..fba8258 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericConductingEquipment.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericConductingEquipment.java @@ -6,11 +6,10 @@ import org.w3c.dom.Element; import java.util.List; -import java.util.stream.Collectors; public class GenericConductingEquipment extends AbstractGenericNameEntity { private List terminals; - + public GenericConductingEquipment(GenericBay parent, Element element) { super(parent, element); } @@ -23,7 +22,7 @@ public List getTerminals() { if (terminals == null) { terminals = getElementsStream("Terminal") .map(element -> new GenericTerminal(this, element)) - .collect(Collectors.toList()); + .toList(); } return terminals; } diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericPowerTransformer.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericPowerTransformer.java index 639cb48..2963333 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericPowerTransformer.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericPowerTransformer.java @@ -3,12 +3,11 @@ // SPDX-License-Identifier: Apache-2.0 package org.lfenergy.compas.scl.auto.alignment.model; -import com.powsybl.sld.model.nodes.FeederWithSideNode; +import com.powsybl.sld.model.nodes.NodeSide; import org.w3c.dom.Element; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; public class GenericPowerTransformer extends AbstractGenericNameEntity { private List transformerWindings; @@ -21,7 +20,7 @@ public List getTransformerWindings() { if (transformerWindings == null) { transformerWindings = getElementsStream("TransformerWinding") .map(element -> new GenericTransformerWinding(this, element)) - .collect(Collectors.toList()); + .toList(); } return transformerWindings; } @@ -45,17 +44,17 @@ public boolean isFeeder3WT() { return getTransformerWindings().size() == 3; } - public FeederWithSideNode.Side getSide(String connectivityNode) { + public NodeSide getSide(String connectivityNode) { var ptw = getTransformerWindingByConnectivityNode(connectivityNode); var index = getTransformerWindings().indexOf(ptw); switch (index) { case 0: - return FeederWithSideNode.Side.ONE; + return NodeSide.ONE; case 1: - return FeederWithSideNode.Side.TWO; + return NodeSide.TWO; case 2: - return FeederWithSideNode.Side.THREE; + return NodeSide.THREE; default: return null; } diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericSCL.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericSCL.java index 3ef883c..1349c6c 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericSCL.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericSCL.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import static org.lfenergy.compas.scl.auto.alignment.SclAutoAlignmentConstants.*; @@ -39,7 +38,7 @@ public List getSubstations() { if (substations == null) { substations = ElementUtil.getElementsStream(element, "Substation") .map(substationElement -> new GenericSubstation(this, substationElement)) - .collect(Collectors.toList()); + .toList(); } return substations; } diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericSubstation.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericSubstation.java index 0338790..1eb4a6e 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericSubstation.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericSubstation.java @@ -9,7 +9,6 @@ import java.util.Collection; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; public class GenericSubstation extends AbstractGenericNameEntity { private List powerTransformers; @@ -28,7 +27,7 @@ public List getPowerTransformers() { if (powerTransformers == null) { powerTransformers = getElementsStream("PowerTransformer") .map(element -> new GenericPowerTransformer(this, element)) - .collect(Collectors.toList()); + .toList(); } return powerTransformers; } @@ -51,7 +50,7 @@ public List getVoltageLevels() { if (voltageLevels == null) { voltageLevels = getElementsStream("VoltageLevel") .map(element -> new GenericVoltageLevel(this, element)) - .collect(Collectors.toList()); + .toList(); } return voltageLevels; } diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericTransformerWinding.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericTransformerWinding.java index 929b99e..e9577f4 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericTransformerWinding.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericTransformerWinding.java @@ -6,7 +6,6 @@ import org.w3c.dom.Element; import java.util.List; -import java.util.stream.Collectors; public class GenericTransformerWinding extends AbstractGenericNameEntity { private List terminals; @@ -19,7 +18,7 @@ public List getTerminals() { if (terminals == null) { terminals = getElementsStream("Terminal") .map(element -> new GenericTerminal(this, element)) - .collect(Collectors.toList()); + .toList(); } return terminals; } diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericVoltageLevel.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericVoltageLevel.java index 93263f8..97de822 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericVoltageLevel.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericVoltageLevel.java @@ -7,7 +7,6 @@ import org.w3c.dom.Element; import java.util.List; -import java.util.stream.Collectors; import static org.lfenergy.compas.scl.auto.alignment.exception.SclAutoAlignmentErrorCode.NO_VOLTAGE_FOUND_ERROR_CODE; @@ -30,7 +29,7 @@ public List getBays() { if (bays == null) { bays = getElementsStream("Bay") .map(element -> new GenericBay(this, element)) - .collect(Collectors.toList()); + .toList(); } return bays; } diff --git a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentDiagramLabelProvider.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentDiagramLabelProvider.java index 3f1b7d2..3d7cc42 100644 --- a/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentDiagramLabelProvider.java +++ b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentDiagramLabelProvider.java @@ -5,13 +5,13 @@ import com.powsybl.sld.library.ComponentTypeName; import com.powsybl.sld.model.coordinate.Direction; +import com.powsybl.sld.model.coordinate.Side; import com.powsybl.sld.model.graphs.SubstationGraph; +import com.powsybl.sld.model.graphs.VoltageLevelGraph; +import com.powsybl.sld.model.nodes.BusNode; import com.powsybl.sld.model.nodes.FeederNode; import com.powsybl.sld.model.nodes.Node; -import com.powsybl.sld.svg.DiagramLabelProvider; -import com.powsybl.sld.svg.DirectionalFeederInfo; -import com.powsybl.sld.svg.FeederInfo; -import com.powsybl.sld.svg.LabelPosition; +import com.powsybl.sld.svg.*; import org.apache.commons.lang3.StringUtils; import java.util.*; @@ -46,7 +46,27 @@ public List getNodeLabels(Node node, Direction direction) { @Override public List getNodeDecorators(Node node, Direction direction) { - return new ArrayList<>(); + return Collections.emptyList(); + } + + @Override + public String getTooltip(Node node) { + return null; + } + + @Override + public List getElectricalNodesInfos(VoltageLevelGraph voltageLevelGraph) { + return Collections.emptyList(); + } + + @Override + public Optional getBusInfo(BusNode busNode) { + return Optional.empty(); + } + + @Override + public Map getBusInfoSides(VoltageLevelGraph voltageLevelGraph) { + return Collections.emptyMap(); } String stripLabel(String id) { diff --git a/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/AbstractGenericEntityTest.java b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/AbstractGenericEntityTest.java index f38e95c..9eb036d 100644 --- a/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/AbstractGenericEntityTest.java +++ b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/AbstractGenericEntityTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.api.Test; import java.io.IOException; -import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.*; import static org.lfenergy.compas.scl.auto.alignment.SclAutoAlignmentConstants.SCLXY_NS_URI; @@ -35,7 +34,7 @@ void constructor_WhenCreated_ThenElementSet() { @Test void getElementsStream_WhenCallingForKnownElement_ThenReturnElements() { var result = entity.getElementsStream("Bay") - .collect(Collectors.toList()); + .toList(); assertEquals(8, result.size()); } @@ -43,7 +42,7 @@ void getElementsStream_WhenCallingForKnownElement_ThenReturnElements() { @Test void getElementsStream_WhenCallingForUnknownElement_ThenReturnEmptyList() { var result = entity.getElementsStream("Unknown") - .collect(Collectors.toList()); + .toList(); assertTrue(result.isEmpty()); } diff --git a/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/GenericHeaderTest.java b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/GenericHeaderTest.java index c024ede..f8d3004 100644 --- a/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/GenericHeaderTest.java +++ b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/GenericHeaderTest.java @@ -9,7 +9,6 @@ import org.lfenergy.compas.scl.auto.alignment.common.ElementUtil; import java.io.IOException; -import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -52,7 +51,7 @@ void addHistoryItem_WhenCalled_ThenAllElementsAreCreated() { var history = ElementUtil.getElementsStream(header.getElement(), "History").findFirst().orElse(null); assertNotNull(history); - var historyItems = ElementUtil.getElementsStream(header.getElement(), "Hitem").collect(Collectors.toList()); + var historyItems = ElementUtil.getElementsStream(header.getElement(), "Hitem").toList(); var historyItem = historyItems.get(historyItems.size() - 1); assertNotNull(historyItem); assertNotNull(historyItem.getAttribute("revision")); diff --git a/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/GenericPowerTransformerTest.java b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/GenericPowerTransformerTest.java index c9d673b..abdd884 100644 --- a/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/GenericPowerTransformerTest.java +++ b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/model/GenericPowerTransformerTest.java @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 package org.lfenergy.compas.scl.auto.alignment.model; -import com.powsybl.sld.model.nodes.FeederWithSideNode; +import com.powsybl.sld.model.nodes.NodeSide; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -77,9 +77,9 @@ void isFeederXWT_WhenCalledWithOtherPowerTransformer_ThenItWillBeA2WT() throws I @Test void getSide_WhenCalledWithDifferentConnectivityNodes_ThenCorrectSidesAreReturned() { - assertEquals(FeederWithSideNode.Side.ONE, powerTransformer.getSide("_af9a4ae3-ba2e-4c34-8e47-5af894ee20f4/S1 30kV/BAY_T4_0/CONNECTIVITY_NODE78")); - assertEquals(FeederWithSideNode.Side.TWO, powerTransformer.getSide("_af9a4ae3-ba2e-4c34-8e47-5af894ee20f4/S1 110kV/BAY_T4_1/CONNECTIVITY_NODE81")); - assertEquals(FeederWithSideNode.Side.THREE, powerTransformer.getSide("_af9a4ae3-ba2e-4c34-8e47-5af894ee20f4/S1 380kV/BAY_T4_2/CONNECTIVITY_NODE85")); + assertEquals(NodeSide.ONE, powerTransformer.getSide("_af9a4ae3-ba2e-4c34-8e47-5af894ee20f4/S1 30kV/BAY_T4_0/CONNECTIVITY_NODE78")); + assertEquals(NodeSide.TWO, powerTransformer.getSide("_af9a4ae3-ba2e-4c34-8e47-5af894ee20f4/S1 110kV/BAY_T4_1/CONNECTIVITY_NODE81")); + assertEquals(NodeSide.THREE, powerTransformer.getSide("_af9a4ae3-ba2e-4c34-8e47-5af894ee20f4/S1 380kV/BAY_T4_2/CONNECTIVITY_NODE85")); assertNull(powerTransformer.getSide("UNKNOWN")); } diff --git a/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentDiagramLabelProviderTest.java b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentDiagramLabelProviderTest.java new file mode 100644 index 0000000..1ccca04 --- /dev/null +++ b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentDiagramLabelProviderTest.java @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: 2022 Alliander N.V. +// +// SPDX-License-Identifier: Apache-2.0 +package org.lfenergy.compas.scl.auto.alignment.service; + +import com.powsybl.sld.model.graphs.SubstationGraph; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class SclAutoAlignmentDiagramLabelProviderTest { + private SclAutoAlignmentDiagramLabelProvider provider; + + @BeforeEach + void setup() { + provider = new SclAutoAlignmentDiagramLabelProvider(SubstationGraph.create("Dummy")); + } + + @Test + void getNodeDecorators_whenCalled_ThenAlwaysReturnEmptyList() { + var result = provider.getNodeDecorators(null, null); + + assertNotNull(result); + assertTrue(result.isEmpty()); + } + + @Test + void getTooltip_whenCalled_ThenAlwaysReturnNull() { + var result = provider.getTooltip(null); + + assertNull(result); + } + + @Test + void getElectricalNodesInfos_whenCalled_ThenAlwaysReturnEmptyList() { + var result = provider.getElectricalNodesInfos(null); + + assertNotNull(result); + assertTrue(result.isEmpty()); + } + + @Test + void getBusInfo_whenCalled_ThenAlwaysReturnEmptyOptional() { + var result = provider.getBusInfo(null); + + assertNotNull(result); + assertTrue(result.isEmpty()); + } + + @Test + void getBusInfoSides_whenCalled_ThenAlwaysReturnEmptyMap() { + var result = provider.getBusInfoSides(null); + + assertNotNull(result); + assertTrue(result.isEmpty()); + } +} \ No newline at end of file diff --git a/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentServiceTest.java b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentServiceTest.java index 61c9ac4..b25753b 100644 --- a/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentServiceTest.java +++ b/service/src/test/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentServiceTest.java @@ -38,8 +38,8 @@ void updateSCL_WhenPassingCase1_ThenUpdatedSCLReturned() throws Exception { var rootElement = toElement(result); assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='J1']", 2, 4); - assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='J1']/scl:Bay[@name='BusBar A']", 1, 15); - assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='J1']/scl:Bay[@name='Bay 1S']", 2, 13); + assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='J1']/scl:Bay[@name='BusBar A']", 1, 14); + assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='J1']/scl:Bay[@name='Bay 1S']", 2, 12); assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='J1']/scl:Bay[@name='Bay 1S']/scl:ConductingEquipment[@name='CBR1']", 1, 1); } @@ -55,9 +55,9 @@ void updateSCL_WhenPassingCase2_ThenUpdatedSCLReturned() throws Exception { var rootElement = toElement(result); assertXYCoordinates(rootElement, "//scl:PowerTransformer[@name='T4']", 27, 3); assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='S1 380kV']", 2, 7); - assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='S1 380kV']/scl:Bay[@name='BUSBAR10']", 1, 12); + assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='S1 380kV']/scl:Bay[@name='BUSBAR10']", 1, 10); assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='S1 380kV']/scl:Bay[@name='BAY_T4_2']", 1, 4); - assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='S1 380kV']/scl:Bay[@name='BAY_T4_2']/scl:ConductingEquipment[@name='BREAKER25']", 1, 4); + assertXYCoordinates(rootElement, "//scl:VoltageLevel[@name='S1 380kV']/scl:Bay[@name='BAY_T4_2']/scl:ConductingEquipment[@name='BREAKER25']", 1, 2); } @Test