From c01cf5a763ea90f6ba3fc67e1a6934a7f3f69e87 Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Wed, 10 Aug 2022 12:41:43 +0200 Subject: [PATCH 01/16] Fixed sonar code smells. Signed-off-by: Dennis Labordus --- .../compas/scl/auto/alignment/common/CommonUtil.java | 3 +-- .../lfenergy/compas/scl/auto/alignment/model/GenericBay.java | 5 ++--- .../scl/auto/alignment/model/GenericConductingEquipment.java | 5 ++--- .../scl/auto/alignment/model/GenericPowerTransformer.java | 3 +-- .../lfenergy/compas/scl/auto/alignment/model/GenericSCL.java | 3 +-- .../compas/scl/auto/alignment/model/GenericSubstation.java | 5 ++--- .../scl/auto/alignment/model/GenericTransformerWinding.java | 3 +-- .../compas/scl/auto/alignment/model/GenericVoltageLevel.java | 3 +-- .../scl/auto/alignment/model/AbstractGenericEntityTest.java | 5 ++--- .../compas/scl/auto/alignment/model/GenericHeaderTest.java | 3 +-- 10 files changed, 14 insertions(+), 24 deletions(-) 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..c4daf67 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 @@ -8,7 +8,6 @@ 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; } 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/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")); From 19edb2042cd896c8cfb66cb16b974b55da44b9d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:27:35 +0000 Subject: [PATCH 02/16] Bump maven-javadoc-plugin from 3.4.0 to 3.4.1 Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.4.0...maven-javadoc-plugin-3.4.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: Dennis Labordus --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7841a6b..3165c7a 100644 --- a/pom.xml +++ b/pom.xml @@ -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 From 90551f084d1479d55f8d8d6e9e7106d394be81d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Aug 2022 17:31:08 +0000 Subject: [PATCH 03/16] Bump slf4j-simple from 1.7.36 to 2.0.0 Bumps [slf4j-simple](https://github.com/qos-ch/slf4j) from 1.7.36 to 2.0.0. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_1.7.36...v_2.0.0) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3165c7a..611c1d5 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ SPDX-License-Identifier: Apache-2.0 0.9.1 2.11.2.Final - 1.7.36 + 2.0.0 2.12.0 2.9.1 0.9.1 From 259df031f05d78740205b3153023575a383ed561 Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Tue, 23 Aug 2022 14:07:25 +0200 Subject: [PATCH 04/16] Fixed GitHub Actions. Signed-off-by: Dennis Labordus --- .github/dependabot.yml | 2 +- .github/workflows/automate-projects.yml | 36 ++++++------------ .github/workflows/build-project.yml | 9 +++-- .github/workflows/release-project.yml | 22 ++++++----- .github/workflows/reuse.yml | 2 +- .github/workflows/sonarcloud-analysis.yml | 46 ++++++++++++++++------- 6 files changed, 62 insertions(+), 55 deletions(-) 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..667143e 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,6 +35,9 @@ 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 with: diff --git a/.github/workflows/release-project.yml b/.github/workflows/release-project.yml index fcbf15e..a29b281 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 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..e302175 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.4.1 + 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 From 2b93798571aee43e2172ca6f101ba348aa2bd74f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Aug 2022 17:19:17 +0000 Subject: [PATCH 05/16] Bump quarkus.platform.version from 2.11.2.Final to 2.11.3.Final Bumps `quarkus.platform.version` from 2.11.2.Final to 2.11.3.Final. Updates `quarkus-universe-bom` from 2.11.2.Final to 2.11.3.Final - [Release notes](https://github.com/quarkusio/quarkus-platform/releases) - [Commits](https://github.com/quarkusio/quarkus-platform/compare/2.11.2.Final...2.11.3.Final) Updates `quarkus-maven-plugin` from 2.11.2.Final to 2.11.3.Final --- updated-dependencies: - dependency-name: io.quarkus:quarkus-universe-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: io.quarkus:quarkus-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 611c1d5..d8cb7c4 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ SPDX-License-Identifier: Apache-2.0 0.9.1 - 2.11.2.Final + 2.11.3.Final 2.0.0 2.12.0 2.9.1 From 8942c662ee0d37c831247b968f3d61b2e67ae29e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:25:03 +0000 Subject: [PATCH 06/16] Bump quarkus.platform.version from 2.11.3.Final to 2.12.0.Final Bumps `quarkus.platform.version` from 2.11.3.Final to 2.12.0.Final. Updates `quarkus-universe-bom` from 2.11.3.Final to 2.12.0.Final - [Release notes](https://github.com/quarkusio/quarkus-platform/releases) - [Commits](https://github.com/quarkusio/quarkus-platform/compare/2.11.3.Final...2.12.0.Final) Updates `quarkus-maven-plugin` from 2.11.3.Final to 2.12.0.Final --- updated-dependencies: - dependency-name: io.quarkus:quarkus-universe-bom dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: io.quarkus:quarkus-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d8cb7c4..a054840 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ SPDX-License-Identifier: Apache-2.0 0.9.1 - 2.11.3.Final + 2.12.0.Final 2.0.0 2.12.0 2.9.1 From 158aa82e144097de66b7da3ab467775b1ecbe19a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Sep 2022 17:16:28 +0000 Subject: [PATCH 07/16] Bump quarkus.platform.version from 2.12.0.Final to 2.12.1.Final Bumps `quarkus.platform.version` from 2.12.0.Final to 2.12.1.Final. Updates `quarkus-universe-bom` from 2.12.0.Final to 2.12.1.Final - [Release notes](https://github.com/quarkusio/quarkus-platform/releases) - [Commits](https://github.com/quarkusio/quarkus-platform/compare/2.12.0.Final...2.12.1.Final) Updates `quarkus-maven-plugin` from 2.12.0.Final to 2.12.1.Final --- updated-dependencies: - dependency-name: io.quarkus:quarkus-universe-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: io.quarkus:quarkus-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a054840..26d9f3d 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ SPDX-License-Identifier: Apache-2.0 0.9.1 - 2.12.0.Final + 2.12.1.Final 2.0.0 2.12.0 2.9.1 From 5b0d15d3225e8e060d39aead78bd1fecb194a031 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Sep 2022 17:23:42 +0000 Subject: [PATCH 08/16] Bump actions/setup-java from 3.4.1 to 3.5.0 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.4.1 to 3.5.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3.4.1...v3.5.0) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build-project.yml | 2 +- .github/workflows/release-project.yml | 2 +- .github/workflows/sonarcloud-analysis.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-project.yml b/.github/workflows/build-project.yml index 667143e..493a335 100644 --- a/.github/workflows/build-project.yml +++ b/.github/workflows/build-project.yml @@ -39,7 +39,7 @@ jobs: 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 a29b281..652f0e4 100644 --- a/.github/workflows/release-project.yml +++ b/.github/workflows/release-project.yml @@ -36,7 +36,7 @@ jobs: 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' diff --git a/.github/workflows/sonarcloud-analysis.yml b/.github/workflows/sonarcloud-analysis.yml index e302175..95a23a2 100644 --- a/.github/workflows/sonarcloud-analysis.yml +++ b/.github/workflows/sonarcloud-analysis.yml @@ -44,7 +44,7 @@ jobs: restore-keys: ${{ runner.os }}-m2 - 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' From e8c9bd651475570058979290684362d831f6c132 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Sep 2022 17:23:52 +0000 Subject: [PATCH 09/16] Bump compas.core.version from 0.9.1 to 0.9.2 Bumps `compas.core.version` from 0.9.1 to 0.9.2. Updates `commons` from 0.9.1 to 0.9.2 Updates `jaxrs-commons` from 0.9.1 to 0.9.2 --- updated-dependencies: - dependency-name: org.lfenergy.compas.core:commons dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.lfenergy.compas.core:jaxrs-commons dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 26d9f3d..b3af50f 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ SPDX-License-Identifier: Apache-2.0 3.0.0-M7 3.2.0 - 0.9.1 + 0.9.2 2.12.1.Final 2.0.0 From cfe719ba4c9f38dc362d84fae7fd8d43b7237197 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Sep 2022 17:51:42 +0000 Subject: [PATCH 10/16] Bump quarkus.platform.version from 2.12.1.Final to 2.12.2.Final Bumps `quarkus.platform.version` from 2.12.1.Final to 2.12.2.Final. Updates `quarkus-universe-bom` from 2.12.1.Final to 2.12.2.Final - [Release notes](https://github.com/quarkusio/quarkus-platform/releases) - [Commits](https://github.com/quarkusio/quarkus-platform/compare/2.12.1.Final...2.12.2.Final) Updates `quarkus-maven-plugin` from 2.12.1.Final to 2.12.2.Final --- updated-dependencies: - dependency-name: io.quarkus:quarkus-universe-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: io.quarkus:quarkus-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b3af50f..47b6dbe 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ SPDX-License-Identifier: Apache-2.0 0.9.2 - 2.12.1.Final + 2.12.2.Final 2.0.0 2.12.0 2.9.1 From 73a393c0090db85d37ae1977ffbc55baff834023 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Sep 2022 17:34:29 +0000 Subject: [PATCH 11/16] Bump slf4j-simple from 2.0.0 to 2.0.1 Bumps [slf4j-simple](https://github.com/qos-ch/slf4j) from 2.0.0 to 2.0.1. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.0...v_2.0.1) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 47b6dbe..5d8b1cd 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ SPDX-License-Identifier: Apache-2.0 0.9.2 2.12.2.Final - 2.0.0 + 2.0.1 2.12.0 2.9.1 0.9.1 From 895dafb0e142df1fc183ae0fa4621ead4bfa5318 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Sep 2022 17:32:43 +0000 Subject: [PATCH 12/16] Bump compas.core.version from 0.9.2 to 0.9.3 Bumps `compas.core.version` from 0.9.2 to 0.9.3. Updates `commons` from 0.9.2 to 0.9.3 Updates `jaxrs-commons` from 0.9.2 to 0.9.3 --- updated-dependencies: - dependency-name: org.lfenergy.compas.core:commons dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.lfenergy.compas.core:jaxrs-commons dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5d8b1cd..5f41dae 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ SPDX-License-Identifier: Apache-2.0 3.0.0-M7 3.2.0 - 0.9.2 + 0.9.3 2.12.2.Final 2.0.1 From 84757cc84700060b971a2191734a25fba765c892 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Sep 2022 17:26:02 +0000 Subject: [PATCH 13/16] Bump powsybl-single-line-diagram-core from 2.12.0 to 2.13.0 Bumps [powsybl-single-line-diagram-core](https://github.com/powsybl/powsybl-single-line-diagram) from 2.12.0 to 2.13.0. - [Release notes](https://github.com/powsybl/powsybl-single-line-diagram/releases) - [Commits](https://github.com/powsybl/powsybl-single-line-diagram/compare/v2.12.0...v2.13.0) --- updated-dependencies: - dependency-name: com.powsybl:powsybl-single-line-diagram-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5d8b1cd..e05bc17 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ SPDX-License-Identifier: Apache-2.0 2.12.2.Final 2.0.1 - 2.12.0 + 2.13.0 2.9.1 0.9.1 From 608507454739dd1746e2cc1ff9c18a8cdf66f1f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Sep 2022 17:26:15 +0000 Subject: [PATCH 14/16] Bump maven-jar-plugin from 3.2.2 to 3.3.0 Bumps [maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.2.2 to 3.3.0. - [Release notes](https://github.com/apache/maven-jar-plugin/releases) - [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.2.2...maven-jar-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jar-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5d8b1cd..1822e73 100644 --- a/pom.xml +++ b/pom.xml @@ -147,7 +147,7 @@ SPDX-License-Identifier: Apache-2.0 org.apache.maven.plugins maven-jar-plugin - 3.2.2 + 3.3.0 From 6d0e8ba3a0828cadfd196e99f2910b0cb7d971eb Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Mon, 19 Sep 2022 13:58:51 +0200 Subject: [PATCH 15/16] Fixed needed changes after upgrade. Signed-off-by: Dennis Labordus --- .../builder/SubstationGraphBuilder.java | 22 ++++++--------- .../builder/VoltageLevelGraphBuilder.java | 19 ++++++------- .../model/GenericPowerTransformer.java | 10 +++---- .../SclAutoAlignmentDiagramLabelProvider.java | 28 ++++++++++++++++--- .../model/GenericPowerTransformerTest.java | 8 +++--- .../service/SclAutoAlignmentServiceTest.java | 8 +++--- 6 files changed, 54 insertions(+), 41 deletions(-) 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/model/GenericPowerTransformer.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/model/GenericPowerTransformer.java index c4daf67..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,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.w3c.dom.Element; import java.util.Collection; @@ -44,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/service/SclAutoAlignmentDiagramLabelProvider.java b/service/src/main/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentDiagramLabelProvider.java index 3f1b7d2..49c85f9 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.*; @@ -49,6 +49,26 @@ public List getNodeDecorators(Node node, Direction direction) { return new ArrayList<>(); } + @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) { String label = id; if (StringUtils.isNotBlank(label) && label.lastIndexOf("/") >= 0) { 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/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 From f4b43b1625660007a8428494e606bcdf7bec1140 Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Mon, 19 Sep 2022 14:15:28 +0200 Subject: [PATCH 16/16] Added some test for the provider. Signed-off-by: Dennis Labordus --- .../SclAutoAlignmentDiagramLabelProvider.java | 2 +- ...AutoAlignmentDiagramLabelProviderTest.java | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 service/src/test/java/org/lfenergy/compas/scl/auto/alignment/service/SclAutoAlignmentDiagramLabelProviderTest.java 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 49c85f9..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 @@ -46,7 +46,7 @@ public List getNodeLabels(Node node, Direction direction) { @Override public List getNodeDecorators(Node node, Direction direction) { - return new ArrayList<>(); + return Collections.emptyList(); } @Override 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