Skip to content

Upgrade to powsybl-dependencies v2025.0.0 #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@
</developers>

<properties>
<gridsuite-dependencies.version>38.0.0</gridsuite-dependencies.version>
<gridsuite-dependencies.version>38.1.0-SNAPSHOT</gridsuite-dependencies.version>
<db-util.version>1.0.5</db-util.version>
<mockwebserver3.version>5.0.0-alpha.14</mockwebserver3.version>
<liquibase-hibernate-package>org.gridsuite.modification.server</liquibase-hibernate-package>
<sonar.coverage.exclusions>**/migration/**/*</sonar.coverage.exclusions>
<network-modification.version>0.13.0</network-modification.version>
<!-- FIXME: powsybl-network-store modules'version is overloaded in the dependencies section.The overloads and this property below have to be removed at next powsybl-ws-dependencies.version upgrade -->
<powsybl-network-store.version>1.24.0</powsybl-network-store.version>
<network-modification.version>0.13.0-SNAPSHOT</network-modification.version>
<sonar.organization>gridsuite</sonar.organization>
<sonar.projectKey>org.gridsuite:network-modification-server</sonar.projectKey>
</properties>
Expand Down Expand Up @@ -97,25 +95,6 @@
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-client</artifactId>
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
<version>${powsybl-network-store.version}</version>
</dependency>
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-iidm-impl</artifactId>
<version>${powsybl-network-store.version}</version>
</dependency>
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-model</artifactId>
<version>${powsybl-network-store.version}</version>
</dependency>

<!-- imports -->
<dependency>
<groupId>org.gridsuite</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ private ApplicationStatus apply(ModificationApplicationGroup modificationGroupIn
ReportNode reportNode;
if (modificationGroupInfos.reportInfos().getNodeUuid() != null) {
UUID reporterId = modificationGroupInfos.reportInfos().getNodeUuid();
reportNode = ReportNode.newRootReportNode().withMessageTemplate(reporterId.toString(), reporterId.toString()).build();
reportNode = ReportNode.newRootReportNode()
.withAllResourceBundlesFromClasspath()
.withMessageTemplate("network.modification.server.nodeUuid")
.withUntypedValue("nodeUuid", reporterId.toString()).build();
} else {
reportNode = ReportNode.NO_OP;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* 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/.
* SPDX-License-Identifier: MPL-2.0
*/
package org.gridsuite.modification.server.report;

import com.google.auto.service.AutoService;
import com.powsybl.commons.report.ReportResourceBundle;

/**
* @author Charly Boutier {@literal <charly.boutier at rte-france.com>}
*/
@AutoService(ReportResourceBundle.class)
public final class NetworkModificationServerReportResourceBundle implements ReportResourceBundle {

public static final String BASE_NAME = "org.gridsuite.modification.server.reports";

public String getBaseName() {
return BASE_NAME;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
network.modification.server.nodeUuid = ${nodeUuid}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,10 @@ void testTombstonedEquipmentInfos() throws Exception {
mvcResult = mockMvc.perform(post(NETWORK_MODIFICATION_URI).content(equipmentDeletionInfosJson).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andReturn();
assertApplicationStatusOK(mvcResult);
expectedImpacts = createMultipleDeletionImpacts(
expectedImpacts = new ArrayList<>();
// Two winding transformer trf2 (in s1) is regulating on v3load (in s2), resetting regulation on delete of v3load adds a modification impact on the substation s1
expectedImpacts.add(createModificationImpactType(IdentifiableType.SUBSTATION, "s1", Set.of("s1")));
expectedImpacts.addAll(createMultipleDeletionImpacts(
List.of(
Pair.of(IdentifiableType.SUBSTATION, "s2"), Pair.of(IdentifiableType.VOLTAGE_LEVEL, "v3"),
Pair.of(IdentifiableType.BUSBAR_SECTION, "3A"), Pair.of(IdentifiableType.LOAD, "v3load"),
Expand All @@ -1339,7 +1342,7 @@ void testTombstonedEquipmentInfos() throws Exception {
Pair.of(IdentifiableType.SWITCH, "v3bl3"), Pair.of(IdentifiableType.SWITCH, "v3dl3")
),
Set.of("s2")
);
));
expectedImpacts.addAll(createMultipleDeletionImpacts(
List.of(
Pair.of(IdentifiableType.SWITCH, "v1bl3"), Pair.of(IdentifiableType.SWITCH, "v1dl3"),
Expand Down Expand Up @@ -1382,7 +1385,7 @@ private void testBranchDeletionImpacts(String resultAsString,
TestImpactUtils.testBranchDeletionImpacts(mapper, resultAsString, branchType, branchId, breakerId1, disconnectorId1, substationId1, breakerId2, disconnectorId2, substationId2);

// line and switches have been removed from network
assertNull(network.getLine(branchId));
assertNull(network.getBranch(branchId));
assertNull(network.getSwitch(breakerId1));
assertNull(network.getSwitch(disconnectorId1));
assertNull(network.getSwitch(breakerId2));
Expand Down Expand Up @@ -1427,7 +1430,7 @@ private void test3WTDeletionImpacts(String resultAsString, String w3tId,

private void testMultipleDeletionImpacts(String networkModificationResultAsString, List<AbstractBaseImpact> expectedImpacts) throws Exception {
for (AbstractBaseImpact impact : expectedImpacts) {
if (impact instanceof SimpleElementImpact simpleImpact) {
if (impact instanceof SimpleElementImpact simpleImpact && simpleImpact.isDeletion()) {
// Equipment has been removed from network
assertNull(network.getIdentifiable(simpleImpact.getElementId()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,23 @@ public static void testBranchImpacts(ObjectMapper mapper, SimpleImpactType type,
private static List<AbstractBaseImpact> createBranchImpacts(SimpleImpactType type, IdentifiableType branchType, String branchId,
String breakerId1, String disconnectorId1, String substationId1,
String breakerId2, String disconnectorId2, String substationId2) {
if (type == SimpleImpactType.DELETION) {
return List.of(
if (type != SimpleImpactType.DELETION) {
return createSubstationImpacts(Set.copyOf(List.of(substationId1, substationId2)));
}

List<AbstractBaseImpact> expectedImpacts = new ArrayList<>();
// For two windings transformers, resetting regulation on delete adds a modification impact on the substation
if (branchType == IdentifiableType.TWO_WINDINGS_TRANSFORMER) {
expectedImpacts.add(createModificationImpactType(IdentifiableType.SUBSTATION, substationId1, Set.of(substationId1)));
}
expectedImpacts.addAll(List.of(
createElementImpact(SimpleImpactType.DELETION, branchType, branchId, Set.copyOf(List.of(substationId1, substationId2))),
createElementImpact(SimpleImpactType.DELETION, IdentifiableType.SWITCH, breakerId1, Set.of(substationId1)),
createElementImpact(SimpleImpactType.DELETION, IdentifiableType.SWITCH, disconnectorId1, Set.of(substationId1)),
createElementImpact(SimpleImpactType.DELETION, IdentifiableType.SWITCH, breakerId2, Set.of(substationId2)),
createElementImpact(SimpleImpactType.DELETION, IdentifiableType.SWITCH, disconnectorId2, Set.of(substationId2))
);
}
return createSubstationImpacts(Set.copyOf(List.of(substationId1, substationId2)));
));
return expectedImpacts;
}

public static void test3WTDeletionImpacts(ObjectMapper mapper, String resultAsString, String w3tId,
Expand All @@ -184,6 +191,8 @@ private static List<AbstractBaseImpact> create3wtDeletionImpacts(String w3tId,
String breakerId3, String disconnectorId3,
String substationId) {
return List.of(
// For three windings transformers, resetting regulation on delete adds a modification impact on the substation
createModificationImpactType(IdentifiableType.SUBSTATION, substationId, Set.of(substationId)),
createDeletionImpactType(IdentifiableType.SWITCH, breakerId1, Set.of(substationId)),
createDeletionImpactType(IdentifiableType.SWITCH, disconnectorId1, Set.of(substationId)),
createDeletionImpactType(IdentifiableType.SWITCH, breakerId2, Set.of(substationId)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ void testCheckModificationConflict() {
when(shuntCompensator.getModelType()).thenReturn(ShuntCompensatorModelType.LINEAR);
when(shuntCompensator.getId()).thenReturn("id");
ReportNode reportNode = ReportNode.newRootReportNode()
.withMessageTemplate("test", "test")
.withResourceBundles("i18n.reports")
.withMessageTemplate("test")
.build();

tabularModification.checkShuntCompensatorModification(network, shuntModification, reportNode);
Expand Down Expand Up @@ -159,7 +160,8 @@ void testCheckModificationNonLinear() {
when(shuntCompensator.getId()).thenReturn("id");

ReportNode reportNode = ReportNode.newRootReportNode()
.withMessageTemplate("test", "test")
.withResourceBundles("i18n.reports")
.withMessageTemplate("test")
.build();
tabularModification.checkShuntCompensatorModification(network, shuntModification, reportNode);

Expand Down Expand Up @@ -187,7 +189,8 @@ void testCheckModificationOK() {
when(shuntCompensator.getModelType()).thenReturn(ShuntCompensatorModelType.LINEAR);
when(shuntCompensator.getId()).thenReturn("id");
ReportNode reportNode = ReportNode.newRootReportNode()
.withMessageTemplate("test", "test")
.withResourceBundles("i18n.reports")
.withMessageTemplate("test")
.build();

tabularModification.checkShuntCompensatorModification(network, shuntModification, reportNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,16 @@ void computeHigherSeverity(List<ReportNode> reports, ApplicationStatus expectedS
assertEquals(6, reports.size(), "We need exactly 6 reports to run the test");

ReportNode rootReportNode = ReportNode.newRootReportNode()
.withMessageTemplate("rep1", "")
.withResourceBundles("i18n.reports")
.withMessageTemplate("rep1")
.build();

ReportNode subReportNode1 = rootReportNode.newReportNode().withMessageTemplate("subrep1", "").add();
ReportNode subReportNode2 = rootReportNode.newReportNode().withMessageTemplate("subrep2", "").add();
ReportNode subReportNode3 = rootReportNode.newReportNode().withMessageTemplate("rep2", "").add();
ReportNode subReportNode1 = rootReportNode.newReportNode().withMessageTemplate("subrep1").add();
ReportNode subReportNode2 = rootReportNode.newReportNode().withMessageTemplate("subrep2").add();
ReportNode subReportNode3 = rootReportNode.newReportNode().withMessageTemplate("rep2").add();

ReportNode subSubReportNode1 = subReportNode3.newReportNode().withMessageTemplate("subsubrep1", "").add();
ReportNode subSubReportNode2 = subReportNode3.newReportNode().withMessageTemplate("subsubrep2", "").add();
ReportNode subSubReportNode1 = subReportNode3.newReportNode().withMessageTemplate("subsubrep1").add();
ReportNode subSubReportNode2 = subReportNode3.newReportNode().withMessageTemplate("subsubrep2").add();

addSubReport(rootReportNode, reports.get(0));
addSubReport(subReportNode1, reports.get(1));
Expand All @@ -129,7 +130,9 @@ void computeHigherSeverity(List<ReportNode> reports, ApplicationStatus expectedS
}

private static void addSubReport(ReportNode parent, ReportNode child) {
ReportNodeAdder adder = parent.newReportNode().withMessageTemplate(child.getMessageKey(), child.getMessageTemplate());
ReportNodeAdder adder = parent.newReportNode()
.withMessageTemplate("message")
.withUntypedValue("message", child.getMessageTemplate());
TypedValue severity = child.getValue(ReportConstants.SEVERITY_KEY).orElse(null);
if (severity != null) {
adder.withSeverity(severity);
Expand All @@ -140,10 +143,11 @@ private static void addSubReport(ReportNode parent, ReportNode child) {
@Test
void shouldThrowExceptionOnBadSeverity() {
ReportNode rootReportNode = ReportNode.newRootReportNode()
.withMessageTemplate("rep1", "")
.withResourceBundles("i18n.reports")
.withMessageTemplate("rep1")
.build();
rootReportNode.newReportNode()
.withMessageTemplate("badSeverity", "Bad severity message")
.withMessageTemplate("badSeverity")
.withUntypedValue("reportSeverity", "bad severity")
.add();

Expand Down Expand Up @@ -228,22 +232,26 @@ private static Stream<Arguments> provideArgumentsForComputeHigherSeverity() {
}

private static ReportNode infoReport = ReportNode.newRootReportNode()
.withMessageTemplate("info", "Info severity message")
.withResourceBundles("i18n.reports")
.withMessageTemplate("info")
.withSeverity(TypedValue.INFO_SEVERITY)
.build();

private static ReportNode warningReport = ReportNode.newRootReportNode()
.withMessageTemplate("warning", "Warning severity message")
.withResourceBundles("i18n.reports")
.withMessageTemplate("warning")
.withSeverity(TypedValue.WARN_SEVERITY)
.build();

private static ReportNode errorReport = ReportNode.newRootReportNode()
.withMessageTemplate("error", "Error severity message")
.withResourceBundles("i18n.reports")
.withMessageTemplate("error")
.withSeverity(TypedValue.ERROR_SEVERITY)
.build();

private static ReportNode notSeverityReport = ReportNode.newRootReportNode()
.withMessageTemplate("notSeverity", "Not a severity message")
.withResourceBundles("i18n.reports")
.withMessageTemplate("notSeverity")
.withUntypedValue("rand", "random value")
.build();
}
14 changes: 14 additions & 0 deletions src/test/resources/i18n/reports.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
badSeverity = Bad severity message
error = Error severity message
info = Info severity message
message = ${message}
notSeverity = Not a severity message
rep1 = rep1
rep2 = rep2
subrep1 = subrep1
subrep2 = subrep2
subsubrep1 = subsubrep1
subsubrep2 = subsubrep2
test = test
testSubReporterId1 = ${testSubReporterId1}
warning = Warning severity message
6 changes: 3 additions & 3 deletions src/test/resources/reports_voltage_init_modification_ok.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"version": "2.1",
"version": "3.0",
"dictionaries": {
"default": {
"2WindingsTransformerModification": "2 windings transformer with id=${id} modified :",
"2WindingsTransformersModifications": "2 windings transformers",
"99999999-9999-9999-9999-999999999999": "99999999-9999-9999-9999-999999999999",
"network.modification.server.nodeUuid": "${nodeUuid}",
"GeneratorsModifications": "Generators",
"ShuntCompensatorsModifications": "Shunt compensators",
"StaticVarCompensatorsModifications": "Static var compensators",
Expand All @@ -24,7 +24,7 @@
}
},
"reportRoot": {
"messageKey": "99999999-9999-9999-9999-999999999999",
"messageKey": "network.modification.server.nodeUuid",
"children": [
{
"messageKey": "VOLTAGE_INIT_MODIFICATION",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"version": "2.1",
"version": "3.0",
"dictionaries": {
"default": {
"2WindingsTransformerNotFound": "2 windings transformer with id=${id} not found",
"2WindingsTransformersModifications": "2 windings transformers",
"3WindingsTransformerNotFound": "3 windings transformer with id=${id} not found",
"3WindingsTransformersModifications": "3 windings transformers",
"99999999-9999-9999-9999-999999999999": "99999999-9999-9999-9999-999999999999",
"network.modification.server.nodeUuid": "${nodeUuid}",
"GeneratorsModifications": "Generators",
"ShuntCompensatorsModifications": "Shunt compensators",
"StaticVarCompensatorsModifications": "Static var compensators",
Expand All @@ -21,7 +21,7 @@
}
},
"reportRoot": {
"messageKey": "99999999-9999-9999-9999-999999999999",
"messageKey": "network.modification.server.nodeUuid",
"children": [
{
"messageKey": "VOLTAGE_INIT_MODIFICATION",
Expand Down
Loading