From e0f65e537622b3b29f0d33ca81de3f764495bf49 Mon Sep 17 00:00:00 2001 From: CARON Alice Date: Thu, 3 Apr 2025 13:21:38 +0200 Subject: [PATCH 1/7] Refacto solver report creation to mutualize code and avoid duplicate report keys Signed-off-by: CARON Alice --- .../powsybl/openloadflow/util/Reports.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/util/Reports.java b/src/main/java/com/powsybl/openloadflow/util/Reports.java index 518efc4215..de57a62006 100644 --- a/src/main/java/com/powsybl/openloadflow/util/Reports.java +++ b/src/main/java/com/powsybl/openloadflow/util/Reports.java @@ -703,11 +703,7 @@ public static ReportNode createOperatorStrategySimulation(ReportNode reportNode, } public static ReportNode createDetailedSolverReporter(ReportNode reportNode, String solverName, int networkNumCc, int networkNumSc) { - ReportNode subReportNode = reportNode.newReportNode() - .withMessageTemplate("solver", solverName + " on Network CC${networkNumCc} SC${networkNumSc}") - .withUntypedValue(NETWORK_NUM_CC, networkNumCc) - .withUntypedValue(NETWORK_NUM_SC, networkNumSc) - .add(); + ReportNode subReportNode = createSolverReport(reportNode, solverName, networkNumCc, networkNumSc); subReportNode.newReportNode() .withMessageTemplate("solverNoOuterLoops", "No outer loops have been launched") .withSeverity(TypedValue.INFO_SEVERITY) @@ -717,11 +713,7 @@ public static ReportNode createDetailedSolverReporter(ReportNode reportNode, Str public static ReportNode createDetailedSolverReporterOuterLoop(ReportNode reportNode, String solverName, int networkNumCc, int networkNumSc, int outerLoopIteration, String outerLoopType) { - ReportNode subReportNode = reportNode.newReportNode() - .withMessageTemplate("solver", solverName + " on Network CC${networkNumCc} SC${networkNumSc}") - .withUntypedValue(NETWORK_NUM_CC, networkNumCc) - .withUntypedValue(NETWORK_NUM_SC, networkNumSc) - .add(); + ReportNode subReportNode = createSolverReport(reportNode, solverName, networkNumCc, networkNumSc); subReportNode.newReportNode() .withMessageTemplate("solverOuterLoopCurrentType", "Newton-Raphson of outer loop iteration ${outerLoopIteration} of type ${outerLoopType}") .withUntypedValue("outerLoopIteration", outerLoopIteration) @@ -731,6 +723,15 @@ public static ReportNode createDetailedSolverReporterOuterLoop(ReportNode report return subReportNode; } + public static ReportNode createSolverReport(ReportNode reportNode, String solverName, int networkNumCc, int networkNumSc) { + return reportNode.newReportNode() + .withMessageTemplate("solver", "${solverName} on Network CC${networkNumCc} SC${networkNumSc}") + .withUntypedValue(NETWORK_NUM_CC, networkNumCc) + .withUntypedValue(NETWORK_NUM_SC, networkNumSc) + .withUntypedValue("solverName", solverName) + .add(); + } + public static ReportNode createNewtonRaphsonMismatchReporter(ReportNode reportNode, int iteration) { if (iteration == 0) { return reportNode.newReportNode() From 040bc56e46615fd200c75c3885a18a619dabc64b Mon Sep 17 00:00:00 2001 From: CARON Alice Date: Thu, 3 Apr 2025 13:43:30 +0200 Subject: [PATCH 2/7] Create ResourceBundle with dictionnary and prefix the keys with olf. Remove uses of deprecated withMessageTemplate method. Signed-off-by: CARON Alice --- .../sa/AbstractSecurityAnalysis.java | 5 +- .../powsybl/openloadflow/util/Reports.java | 207 +++++++++--------- ...wsyblOpenLoadFlowReportResourceBundle.java | 26 +++ .../powsybl/openloadflow/reports.properties | 87 ++++++++ .../openloadflow/reports_en_US.properties | 1 + .../openloadflow/reports_fr.properties | 1 + .../openloadflow/reports_fr_FR.properties | 1 + 7 files changed, 223 insertions(+), 105 deletions(-) create mode 100644 src/main/java/com/powsybl/openloadflow/util/report/PowsyblOpenLoadFlowReportResourceBundle.java create mode 100644 src/main/resources/com/powsybl/openloadflow/reports.properties create mode 100644 src/main/resources/com/powsybl/openloadflow/reports_en_US.properties create mode 100644 src/main/resources/com/powsybl/openloadflow/reports_fr.properties create mode 100644 src/main/resources/com/powsybl/openloadflow/reports_fr_FR.properties diff --git a/src/main/java/com/powsybl/openloadflow/sa/AbstractSecurityAnalysis.java b/src/main/java/com/powsybl/openloadflow/sa/AbstractSecurityAnalysis.java index 23c80a5e72..30d6e1dd64 100644 --- a/src/main/java/com/powsybl/openloadflow/sa/AbstractSecurityAnalysis.java +++ b/src/main/java/com/powsybl/openloadflow/sa/AbstractSecurityAnalysis.java @@ -217,10 +217,7 @@ SecurityAnalysisReport runSync(SecurityAnalysisParameters securityAnalysisParame parameters = createParameters(lfParameters, lfParametersExt, partitionTopoConfig.isBreaker(), isAreaInterchangeControl(lfParametersExt, contingencies)); - ReportNode threadRootNode = partitionNum == 0 ? saReportNode : - ReportNode.newRootReportNode() - .withMessageTemplate("threadRoot", "threadRoot") - .build(); + ReportNode threadRootNode = partitionNum == 0 ? saReportNode : Reports.createThreadRootReport(); reportNodes.set(partitionNum, threadRootNode); // create networks including all necessary switches diff --git a/src/main/java/com/powsybl/openloadflow/util/Reports.java b/src/main/java/com/powsybl/openloadflow/util/Reports.java index de57a62006..db9e6c1ebe 100644 --- a/src/main/java/com/powsybl/openloadflow/util/Reports.java +++ b/src/main/java/com/powsybl/openloadflow/util/Reports.java @@ -11,6 +11,7 @@ import com.powsybl.commons.report.TypedValue; import com.powsybl.openloadflow.OpenLoadFlowReportConstants; import com.powsybl.openloadflow.network.LfBus; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.slf4j.Logger; import java.util.List; @@ -39,8 +40,8 @@ public final class Reports { private static final String CONTINGENCY_ID = "contingencyId"; public static final String MISMATCH = "mismatch"; - public static final String LF_NETWORK_KEY = "lfNetwork"; - public static final String POST_CONTINGENCY_SIMULATION_KEY = "postContingencySimulation"; + public static final String LF_NETWORK_KEY = "olf.lfNetwork"; + public static final String POST_CONTINGENCY_SIMULATION_KEY = "olf.postContingencySimulation"; public record BusReport(String busId, double mismatch, double nominalV, double v, double phi, double p, double q) { } @@ -50,7 +51,7 @@ private Reports() { public static void reportNetworkSize(ReportNode reportNode, int busCount, int branchCount) { reportNode.newReportNode() - .withMessageTemplate("networkSize", "Network has ${busCount} buses and ${branchCount} branches") + .withMessageTemplate("olf.networkSize") .withUntypedValue("busCount", busCount) .withUntypedValue("branchCount", branchCount) .withSeverity(TypedValue.INFO_SEVERITY) @@ -59,7 +60,7 @@ public static void reportNetworkSize(ReportNode reportNode, int busCount, int br public static void reportNetworkBalance(ReportNode reportNode, double activeGeneration, double activeLoad, double reactiveGeneration, double reactiveLoad) { reportNode.newReportNode() - .withMessageTemplate("networkBalance", "Network balance: active generation=${activeGeneration} MW, active load=${activeLoad} MW, reactive generation=${reactiveGeneration} MVar, reactive load=${reactiveLoad} MVar") + .withMessageTemplate("olf.networkBalance") .withUntypedValue("activeGeneration", activeGeneration) .withUntypedValue("activeLoad", activeLoad) .withUntypedValue("reactiveGeneration", reactiveGeneration) @@ -70,7 +71,7 @@ public static void reportNetworkBalance(ReportNode reportNode, double activeGene public static void reportNotUniqueControlledBusKeepingFirstControl(ReportNode reportNode, String generatorIds, String controllerBusId, String controlledBusId, String controlledBusGenId) { reportNode.newReportNode() - .withMessageTemplate("notUniqueControlledBusKeepingFirstControl", "Generators [${generatorIds}] are connected to the same bus ${controllerBusId} but control the voltage of different buses: ${controlledBusId} (kept) and ${controlledBusGenId} (rejected)") + .withMessageTemplate("olf.notUniqueControlledBusKeepingFirstControl") .withUntypedValue(GENERATORS_ID, generatorIds) .withUntypedValue(CONTROLLER_BUS_ID, controllerBusId) .withUntypedValue(CONTROLLED_BUS_ID, controlledBusId) @@ -81,7 +82,7 @@ public static void reportNotUniqueControlledBusKeepingFirstControl(ReportNode re public static void reportNotUniqueControlledBusDisablingControl(ReportNode reportNode, String generatorIds, String controllerBusId, String controlledBusId, String controlledBusGenId) { reportNode.newReportNode() - .withMessageTemplate("notUniqueControlledBusDisablingControl", "Generators [${generatorIds}] are connected to the same bus ${controllerBusId} but control the voltage of different buses (${controlledBusId} and ${controlledBusGenId}): disabling voltage control") + .withMessageTemplate("olf.notUniqueControlledBusDisablingControl") .withUntypedValue(GENERATORS_ID, generatorIds) .withUntypedValue(CONTROLLER_BUS_ID, controllerBusId) .withUntypedValue(CONTROLLED_BUS_ID, controlledBusId) @@ -92,7 +93,7 @@ public static void reportNotUniqueControlledBusDisablingControl(ReportNode repor public static void reportNotUniqueTargetVControllerBusKeepingFirstControl(ReportNode reportNode, String generatorIds, String controllerBusId, Double keptTargetV, Double rejectedTargetV) { reportNode.newReportNode() - .withMessageTemplate("notUniqueTargetVControllerBusKeepingFirstControl", "Generators [${generatorIds}] are connected to the same bus ${controllerBusId} with different target voltages: ${keptTargetV} kV (kept) and ${rejectedTargetV} kV (rejected)") + .withMessageTemplate("olf.notUniqueTargetVControllerBusKeepingFirstControl") .withUntypedValue(GENERATORS_ID, generatorIds) .withUntypedValue(CONTROLLER_BUS_ID, controllerBusId) .withUntypedValue("keptTargetV", keptTargetV) @@ -103,7 +104,7 @@ public static void reportNotUniqueTargetVControllerBusKeepingFirstControl(Report public static void reportNotUniqueTargetVControllerBusDisablingControl(ReportNode reportNode, String generatorIds, String controllerBusId, Double targetV1, Double targetV2) { reportNode.newReportNode() - .withMessageTemplate("notUniqueTargetVControllerBusDisablingControl", "Generators [${generatorIds}] are connected to the same bus ${controllerBusId} with different target voltages (${targetV1} kV and ${targetV2} kV): disabling voltage control") + .withMessageTemplate("olf.notUniqueTargetVControllerBusDisablingControl") .withUntypedValue(GENERATORS_ID, generatorIds) .withUntypedValue(CONTROLLER_BUS_ID, controllerBusId) .withUntypedValue("targetV1", targetV1) @@ -114,7 +115,7 @@ public static void reportNotUniqueTargetVControllerBusDisablingControl(ReportNod public static void reportControllerShuntAlreadyInVoltageControl(ReportNode reportNode, String controllerShuntId, String controlledBusId) { reportNode.newReportNode() - .withMessageTemplate("controllerShuntAlreadyInVoltageControl", "Controller shunt ${controllerShuntId} is already in a shunt voltage control. The second controlled bus ${controlledBusId} is ignored") + .withMessageTemplate("olf.controllerShuntAlreadyInVoltageControl") .withUntypedValue("controllerShuntId", controllerShuntId) .withUntypedValue(CONTROLLED_BUS_ID, controlledBusId) .withSeverity(TypedValue.ERROR_SEVERITY) @@ -123,7 +124,7 @@ public static void reportControllerShuntAlreadyInVoltageControl(ReportNode repor public static void reportBusAlreadyControlledWithDifferentTargetV(ReportNode reportNode, String controllerBusId, String controlledBusId, String busesId, Double keptTargetV, Double ignoredTargetV) { reportNode.newReportNode() - .withMessageTemplate("busAlreadyControlledWithDifferentTargetV", "Bus ${controllerBusId} controls voltage of bus ${controlledBusId} which is already controlled by buses [${busesId}] with a different target voltage: ${keptTargetV} kV (kept) and ${ignoredTargetV} kV (ignored)") + .withMessageTemplate("olf.busAlreadyControlledWithDifferentTargetV") .withUntypedValue(CONTROLLER_BUS_ID, controllerBusId) .withUntypedValue(CONTROLLED_BUS_ID, controlledBusId) .withUntypedValue("busesId", busesId) @@ -135,7 +136,7 @@ public static void reportBusAlreadyControlledWithDifferentTargetV(ReportNode rep public static void reportBranchControlledAtBothSides(ReportNode reportNode, String controlledBranchId, String keptSide, String rejectedSide) { reportNode.newReportNode() - .withMessageTemplate("branchControlledAtBothSides", "Controlled branch ${controlledBranchId} is controlled at both sides. Controlled side ${keptSide} (kept) side ${rejectedSide} (rejected).") + .withMessageTemplate("olf.branchControlledAtBothSides") .withUntypedValue("controlledBranchId", controlledBranchId) .withUntypedValue("keptSide", keptSide) .withUntypedValue("rejectedSide", rejectedSide) @@ -145,14 +146,14 @@ public static void reportBranchControlledAtBothSides(ReportNode reportNode, Stri public static void reportNetworkMustHaveAtLeastOneBusGeneratorVoltageControlEnabled(ReportNode reportNode) { reportNode.newReportNode() - .withMessageTemplate("networkMustHaveAtLeastOneBusGeneratorVoltageControlEnabled", "Network must have at least one bus with generator voltage control enabled") + .withMessageTemplate("olf.networkMustHaveAtLeastOneBusGeneratorVoltageControlEnabled") .withSeverity(TypedValue.ERROR_SEVERITY) .add(); } public static void reportComponentsWithoutGenerators(ReportNode reportNode, int deadComponentsCount) { reportNode.newReportNode() - .withMessageTemplate("componentsWithoutGenerators", "No calculation will be done on ${deadComponentsCount} network(s) that have no generators") + .withMessageTemplate("olf.componentsWithoutGenerators") .withUntypedValue("deadComponentsCount", deadComponentsCount) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -160,7 +161,7 @@ public static void reportComponentsWithoutGenerators(ReportNode reportNode, int public static void reportMismatchDistributionFailure(ReportNode reportNode, double remainingMismatch) { reportNode.newReportNode() - .withMessageTemplate("mismatchDistributionFailure", "Failed to distribute slack bus active power mismatch, ${mismatch} MW remains") + .withMessageTemplate("olf.mismatchDistributionFailure") .withTypedValue(MISMATCH, remainingMismatch, OpenLoadFlowReportConstants.MISMATCH_TYPED_VALUE) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); @@ -168,7 +169,7 @@ public static void reportMismatchDistributionFailure(ReportNode reportNode, doub public static void reportMismatchDistributionSuccess(ReportNode reportNode, double slackBusActivePowerMismatch, int iterationCount) { reportNode.newReportNode() - .withMessageTemplate("mismatchDistributionSuccess", "Slack bus active power (${initialMismatch} MW) distributed in ${iterationCount} distribution iteration(s)") + .withMessageTemplate("olf.mismatchDistributionSuccess") .withTypedValue("initialMismatch", slackBusActivePowerMismatch, OpenLoadFlowReportConstants.MISMATCH_TYPED_VALUE) .withUntypedValue(ITERATION_COUNT, iterationCount) .withSeverity(TypedValue.INFO_SEVERITY) @@ -177,7 +178,7 @@ public static void reportMismatchDistributionSuccess(ReportNode reportNode, doub public static void reportAreaNoInterchangeControl(ReportNode reportNode, String area, String reason) { reportNode.newReportNode() - .withMessageTemplate("areaNoInterchangeControl", "Area ${area} will not be considered in area interchange control, reason: ${reason}") + .withMessageTemplate("olf.areaNoInterchangeControl") .withUntypedValue("area", area) .withUntypedValue("reason", reason) .withSeverity(TypedValue.WARN_SEVERITY) @@ -186,14 +187,14 @@ public static void reportAreaNoInterchangeControl(ReportNode reportNode, String public static ReportNode reportAreaInterchangeControlDistributionFailure(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate("areaInterchangeControlDistributionFailure", "Failed to distribute interchange active power mismatch") + .withMessageTemplate("olf.areaInterchangeControlDistributionFailure") .withSeverity(TypedValue.ERROR_SEVERITY) .add(); } public static void reportAreaInterchangeControlAreaMismatch(ReportNode reportNode, String area, double mismatch) { reportNode.newReportNode() - .withMessageTemplate("areaInterchangeControlAreaMismatch", "Remaining mismatch for Area ${area}: ${mismatch} MW") + .withMessageTemplate("olf.areaInterchangeControlAreaMismatch") .withUntypedValue("area", area) .withTypedValue(MISMATCH, mismatch, OpenLoadFlowReportConstants.MISMATCH_TYPED_VALUE) .withSeverity(TypedValue.ERROR_SEVERITY) @@ -202,7 +203,7 @@ public static void reportAreaInterchangeControlAreaMismatch(ReportNode reportNod public static void reportAreaInterchangeControlAreaDistributionSuccess(ReportNode reportNode, String area, double mismatch, int iterationCount) { reportNode.newReportNode() - .withMessageTemplate("areaInterchangeControlAreaDistributionSuccess", "Area ${area} interchange mismatch (${mismatch} MW) distributed in ${iterationCount} distribution iteration(s)") + .withMessageTemplate("olf.areaInterchangeControlAreaDistributionSuccess") .withUntypedValue("area", area) .withTypedValue(MISMATCH, mismatch, OpenLoadFlowReportConstants.MISMATCH_TYPED_VALUE) .withUntypedValue(ITERATION_COUNT, iterationCount) @@ -212,7 +213,7 @@ public static void reportAreaInterchangeControlAreaDistributionSuccess(ReportNod public static ReportNode reportPvToPqBuses(ReportNode reportNode, int pvToPqBusCount, int remainingPvBusCount) { return reportNode.newReportNode() - .withMessageTemplate("pvToPqBuses", "${pvToPqBusCount} buses switched PV -> PQ (${remainingPvBusCount} buses remain PV)") + .withMessageTemplate("olf.pvToPqBuses") .withUntypedValue("pvToPqBusCount", pvToPqBusCount) .withUntypedValue("remainingPvBusCount", remainingPvBusCount) .withSeverity(TypedValue.INFO_SEVERITY) @@ -226,9 +227,8 @@ public static void reportPvToPqMaxQ(ReportNode reportNode, boolean log, Logger logger) { ReportNode newNode = reportNode.newReportNode() - .withMessageTemplate("pvToPqMaxQ", - "Switch bus '${busId}' PV -> PQ, q=${busQ} > maxQ=${maxQ}") - .withUntypedValue("busId", controllerBus.getId()) + .withMessageTemplate("olf.pvToPqMaxQ") + .withUntypedValue(BUS_ID, controllerBus.getId()) .withTypedValue("busQ", busQ * PerUnit.SB, TypedValue.REACTIVE_POWER) .withTypedValue("maxQ", maxQ * PerUnit.SB, TypedValue.REACTIVE_POWER) .withSeverity(TypedValue.TRACE_SEVERITY) @@ -245,9 +245,8 @@ public static void reportPvToPqMinQ(ReportNode reportNode, boolean log, Logger logger) { ReportNode newNode = reportNode.newReportNode() - .withMessageTemplate("PvToPqMinQ", - "Switch bus '${busId}' PV -> PQ, q=${busQ} < minQ=${minQ}") - .withUntypedValue("busId", controllerBus.getId()) + .withMessageTemplate("olf.PvToPqMinQ") + .withUntypedValue(BUS_ID, controllerBus.getId()) .withTypedValue("busQ", busQ * PerUnit.SB, TypedValue.REACTIVE_POWER) .withTypedValue("minQ", minQ * PerUnit.SB, TypedValue.REACTIVE_POWER) .withSeverity(TypedValue.TRACE_SEVERITY) @@ -264,9 +263,8 @@ public static void reportPvToPqMinRealisticV(ReportNode reportNode, boolean log, Logger logger) { ReportNode newNode = reportNode.newReportNode() - .withMessageTemplate("PvToPqMinRealisticV", - "Switch bus '${busId}' PV -> PQ, q set to ${targetQ} = targetQ - because V < ${minRealisticV}kV when remote voltage target is maintained") - .withUntypedValue("busId", controllerBus.getId()) + .withMessageTemplate("olf.PvToPqMinRealisticV") + .withUntypedValue(BUS_ID, controllerBus.getId()) .withTypedValue("targetQ", targetQ * PerUnit.SB, TypedValue.REACTIVE_POWER) .withTypedValue("minRealisticV", minRealisticV * controllerBus.getNominalV(), TypedValue.VOLTAGE) .withSeverity(TypedValue.TRACE_SEVERITY) @@ -283,8 +281,7 @@ public static void reportPvToPqMaxRealisticV(ReportNode reportNode, boolean log, Logger logger) { ReportNode newNode = reportNode.newReportNode() - .withMessageTemplate("PvToPqMaxRealisticV", - "Switch bus '${busId}' PV -> PQ, q set to ${targetQ} = targetQ - because V > ${maxRealisticV}kV when remote voltage target is maintained") + .withMessageTemplate("olf.PvToPqMaxRealisticV") .withUntypedValue("busId", controllerBus.getId()) .withTypedValue("targetQ", targetQ * PerUnit.SB, TypedValue.REACTIVE_POWER) .withTypedValue("maxRealisticV", maxRealisticV * controllerBus.getNominalV(), TypedValue.VOLTAGE) @@ -297,7 +294,7 @@ public static void reportPvToPqMaxRealisticV(ReportNode reportNode, public static ReportNode reportPqToPvBuses(ReportNode reportNode, int pqToPvBusCount, int blockedPqBusCount) { return reportNode.newReportNode() - .withMessageTemplate("PqToPvBuses", "${pqToPvBusCount} buses switched PQ -> PV (${blockedPqBusCount} buses blocked PQ due to the max number of switches)") + .withMessageTemplate("olf.PqToPvBuses") .withUntypedValue("pqToPvBusCount", pqToPvBusCount) .withUntypedValue("blockedPqBusCount", blockedPqBusCount) .withSeverity(TypedValue.INFO_SEVERITY) @@ -306,8 +303,8 @@ public static ReportNode reportPqToPvBuses(ReportNode reportNode, int pqToPvBusC public static ReportNode reportPvPqSwitchLimit(LfBus controllerBus, int limit, boolean log, Logger logger) { ReportNode result = ReportNode.newRootReportNode() - .withMessageTemplate("pvPqSwitchLimit", - "Bus '${busId}' blocked PQ as it has reached its max number of PQ -> PV switch (${limit})") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("olf.pvPqSwitchLimit") .withUntypedValue("busId", controllerBus.getId()) .withUntypedValue("limit", limit) .withSeverity(TypedValue.TRACE_SEVERITY) @@ -320,8 +317,8 @@ public static ReportNode reportPvPqSwitchLimit(LfBus controllerBus, int limit, b public static ReportNode reportPqToPvBusMaxLimit(LfBus controllerBus, LfBus controlledBus, double targetV, boolean log, Logger logger) { ReportNode result = ReportNode.newRootReportNode() - .withMessageTemplate("pqToPvBusMaxLimit", - "Switch bus '${busId}' PQ -> PV, q=maxQ and v=${busV}kV > targetV=${targetV}kV") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("olf.pqToPvBusMaxLimit") .withUntypedValue("busId", controllerBus.getId()) // busV and targetV need a higher precision than usual Voltage rounding to understand // the difference. Their unit is not given to avoid a too high formatting based on Unit @@ -337,8 +334,8 @@ public static ReportNode reportPqToPvBusMaxLimit(LfBus controllerBus, LfBus cont public static ReportNode reportPqToPvBusMinLimit(LfBus controllerBus, LfBus controlledBus, double targetV, boolean log, Logger logger) { ReportNode result = ReportNode.newRootReportNode() - .withMessageTemplate("pqToPvBusMinLimit", - "Switch bus '${busId}' PQ -> PV, q=minQ and v=${busV}kV < targetV=${targetV}kV") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("olf.pqToPvBusMinLimit") .withUntypedValue("busId", controllerBus.getId()) // busV and targetV need a higher precision than usual Voltage rounding to understand // the difference. Their unit is not given to avoid a too high formatting based on Unit @@ -354,7 +351,7 @@ public static ReportNode reportPqToPvBusMinLimit(LfBus controllerBus, LfBus cont public static void reportBusForcedToBePv(ReportNode reportNode, String busId) { reportNode.newReportNode() - .withMessageTemplate("busForcedToBePv", "All PV buses should switch PQ, strongest one will stay PV: ${busId}") + .withMessageTemplate("olf.busForcedToBePv") .withUntypedValue(BUS_ID, busId) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -362,7 +359,7 @@ public static void reportBusForcedToBePv(ReportNode reportNode, String busId) { public static void reportBusesWithUpdatedQLimits(ReportNode reportNode, int numBusesWithUpdatedQLimits) { reportNode.newReportNode() - .withMessageTemplate("busWithUpdatedQLimits", "${numBusesWithUpdatedQLimits} buses blocked at a reactive limit have been adjusted because the reactive limit changed") + .withMessageTemplate("olf.busWithUpdatedQLimits") .withUntypedValue("numBusesWithUpdatedQLimits", numBusesWithUpdatedQLimits) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -370,7 +367,7 @@ public static void reportBusesWithUpdatedQLimits(ReportNode reportNode, int numB public static ReportNode reportReactiveControllerBusesToPqBuses(ReportNode reportNode, int remoteReactivePowerControllerBusToPqCount) { return reportNode.newReportNode() - .withMessageTemplate("reactiveControllerBusesToPqBuses", "${remoteReactivePowerControllerBusToPqCount} bus(es) with remote reactive power controller switched PQ") + .withMessageTemplate("olf.reactiveControllerBusesToPqBuses") .withUntypedValue("remoteReactivePowerControllerBusToPqCount", remoteReactivePowerControllerBusToPqCount) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -382,8 +379,8 @@ public static ReportNode reportReactiveControllerBusesToPqMaxQ(LfBus controllerB boolean log, Logger logger) { ReportNode result = ReportNode.newRootReportNode() - .withMessageTemplate("reactiveControllerBusesToPqMaxQ", - "Remote reactive power controller bus '${busId}' -> PQ, q=${busQ} > maxQ=${maxQ}") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("olf.reactiveControllerBusesToPqMaxQ") .withUntypedValue("busId", controllerBus.getId()) .withTypedValue("busQ", busQ * PerUnit.SB, TypedValue.REACTIVE_POWER) .withTypedValue("maxQ", maxQ * PerUnit.SB, TypedValue.REACTIVE_POWER) @@ -401,8 +398,8 @@ public static ReportNode reportReactiveControllerBusesToPqMinQ(LfBus controllerB boolean log, Logger logger) { ReportNode result = ReportNode.newRootReportNode() - .withMessageTemplate("reactiveControllerBusesToPqMinQ", - "Remote reactive power controller bus '${busId}' -> PQ, q=${busQ} < minQ=${minQ}") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("olf.reactiveControllerBusesToPqMinQ") .withUntypedValue("busId", controllerBus.getId()) .withTypedValue("busQ", busQ * PerUnit.SB, TypedValue.REACTIVE_POWER) .withTypedValue("minQ", minQ * PerUnit.SB, TypedValue.REACTIVE_POWER) @@ -416,7 +413,7 @@ public static ReportNode reportReactiveControllerBusesToPqMinQ(LfBus controllerB public static void reportStandByAutomatonActivation(ReportNode reportNode, String busId, double newTargetV) { reportNode.newReportNode() - .withMessageTemplate("standByAutomatonActivation", "Activation of voltage control of static var compensator with stand by automaton: bus ${busId} switched PQ -> PV with targetV ${newTargetV}") + .withMessageTemplate("olf.standByAutomatonActivation") .withUntypedValue(BUS_ID, busId) .withUntypedValue("newTargetV", newTargetV) .withSeverity(TypedValue.INFO_SEVERITY) @@ -425,7 +422,7 @@ public static void reportStandByAutomatonActivation(ReportNode reportNode, Strin public static void reportCurrentLimiterPstsChangedTaps(ReportNode reportNode, int numOfCurrentLimiterPstsThatChangedTap) { reportNode.newReportNode() - .withMessageTemplate("currentLimiterPstsChangedTaps", "${numOfCurrentLimiterPstsThatChangedTap} current limiter PST(s) changed taps") + .withMessageTemplate("olf.currentLimiterPstsChangedTaps") .withUntypedValue("numOfCurrentLimiterPstsThatChangedTap", numOfCurrentLimiterPstsThatChangedTap) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -433,7 +430,7 @@ public static void reportCurrentLimiterPstsChangedTaps(ReportNode reportNode, in public static void reportActivePowerControlPstsChangedTaps(ReportNode reportNode, int numOfActivePowerControlPstsThatChangedTap) { reportNode.newReportNode() - .withMessageTemplate("activePowerControlPstsChangedTaps", "${numOfActivePowerControlPstsThatChangedTap} active power control PST(s) changed taps") + .withMessageTemplate("olf.activePowerControlPstsChangedTaps") .withUntypedValue("numOfActivePowerControlPstsThatChangedTap", numOfActivePowerControlPstsThatChangedTap) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -441,7 +438,7 @@ public static void reportActivePowerControlPstsChangedTaps(ReportNode reportNode public static void reportTransformerControlAlreadyExistsWithDifferentTargetV(ReportNode reportNode, String firstControllerId, String newControllerId, String controlledBusId, double vcTargetValue, double targetValue) { reportNode.newReportNode() - .withMessageTemplate("transformerControlAlreadyExistsWithDifferentTargetV", "Transformers ${firstControllerId} and ${newControllerId} control voltage at bus ${controlledBusId} with different target voltages: ${vcTargetValue}kV (kept) and ${targetValue}kV (rejected)") + .withMessageTemplate("olf.transformerControlAlreadyExistsWithDifferentTargetV") .withUntypedValue(CONTROLLED_BUS_ID, controlledBusId) .withUntypedValue("firstControllerId", firstControllerId) .withUntypedValue("newControllerId", newControllerId) @@ -453,7 +450,7 @@ public static void reportTransformerControlAlreadyExistsWithDifferentTargetV(Rep public static void reportTransformerControlAlreadyExistsUpdateDeadband(ReportNode reportNode, String firstControllerId, String newControllerId, String controlledBusId, double newTargetDeadband, Double oldTargetDeadband) { reportNode.newReportNode() - .withMessageTemplate("transformerControlAlreadyExistsUpdateDeadband", "Transformers ${firstControllerId} and ${newControllerId} control voltage at bus ${controlledBusId} with different deadbands, thinnest will be kept: ${newTargetDeadband}kV (kept) and ${oldTargetDeadband}kV (rejected)") + .withMessageTemplate("olf.transformerControlAlreadyExistsUpdateDeadband") .withUntypedValue(CONTROLLED_BUS_ID, controlledBusId) .withUntypedValue("firstControllerId", firstControllerId) .withUntypedValue("newControllerId", newControllerId) @@ -465,7 +462,7 @@ public static void reportTransformerControlAlreadyExistsUpdateDeadband(ReportNod public static void reportTransformerControlBusesOutsideDeadband(ReportNode reportNode, int numTransformerControlBusesOutsideDeadband) { reportNode.newReportNode() - .withMessageTemplate("transformerControlBusesOutsideDeadband", "${numTransformerControlBusesOutsideDeadband} voltage-controlled buses are outside of their target deadbands") + .withMessageTemplate("olf.transformerControlBusesOutsideDeadband") .withUntypedValue("numTransformerControlBusesOutsideDeadband", numTransformerControlBusesOutsideDeadband) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -473,7 +470,7 @@ public static void reportTransformerControlBusesOutsideDeadband(ReportNode repor public static void reportTransformerControlBranchesOutsideDeadband(ReportNode reportNode, int numTransformerControlBranchesOutsideDeadband) { reportNode.newReportNode() - .withMessageTemplate("transformerControlBranchesOutsideDeadband", "${numTransformerControlBranchesOutsideDeadband} reactive power-controlled branches are outside of their target deadbands") + .withMessageTemplate("olf.transformerControlBranchesOutsideDeadband") .withUntypedValue("numTransformerControlBranchesOutsideDeadband", numTransformerControlBranchesOutsideDeadband) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -481,7 +478,7 @@ public static void reportTransformerControlBranchesOutsideDeadband(ReportNode re public static void reportTransformerControlChangedTaps(ReportNode reportNode, int numTransformerControlAdjusted) { reportNode.newReportNode() - .withMessageTemplate("transformerControlChangedTaps", "${numTransformerControlAdjusted} transformers changed tap position") + .withMessageTemplate("olf.transformerControlChangedTaps") .withUntypedValue("numTransformerControlAdjusted", numTransformerControlAdjusted) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -489,7 +486,7 @@ public static void reportTransformerControlChangedTaps(ReportNode reportNode, in public static void reportTransformerControlTapLimit(ReportNode reportNode, int numTransformerControlTapLimit) { reportNode.newReportNode() - .withMessageTemplate("transformerControlTapLimit", "${numTransformerControlTapLimit} transformers reached their tap maximum position") + .withMessageTemplate("olf.transformerControlTapLimit") .withUntypedValue("numTransformerControlTapLimit", numTransformerControlTapLimit) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -497,7 +494,7 @@ public static void reportTransformerControlTapLimit(ReportNode reportNode, int n public static void reportShuntVoltageControlChangedSection(ReportNode reportNode, int numShuntVoltageControlAdjusted) { reportNode.newReportNode() - .withMessageTemplate("shuntVoltageControlChangedSection", "${numShuntVoltageControlAdjusted} shunts changed section") + .withMessageTemplate("olf.shuntVoltageControlChangedSection") .withUntypedValue("numShuntVoltageControlAdjusted", numShuntVoltageControlAdjusted) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -505,7 +502,7 @@ public static void reportShuntVoltageControlChangedSection(ReportNode reportNode public static void reportUnsuccessfulOuterLoop(ReportNode reportNode, String outerLoopStatus) { reportNode.newReportNode() - .withMessageTemplate("outerLoopStatus", "Outer loop unsuccessful with status: ${outerLoopStatus}") + .withMessageTemplate("olf.outerLoopStatus") .withUntypedValue("outerLoopStatus", outerLoopStatus) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); @@ -513,7 +510,7 @@ public static void reportUnsuccessfulOuterLoop(ReportNode reportNode, String out public static void reportMaxOuterLoopIterations(ReportNode reportNode, int iterationCount, boolean withLog, Logger logger) { ReportNode added = reportNode.newReportNode() - .withMessageTemplate("maxOuterLoopIterations", "Maximum number of outerloop iterations reached: ${outerLoopIterationCount}") + .withMessageTemplate("olf.maxOuterLoopIterations") .withUntypedValue("outerLoopIterationCount", iterationCount) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); @@ -524,7 +521,7 @@ public static void reportMaxOuterLoopIterations(ReportNode reportNode, int itera public static void reportDcLfSolverFailure(ReportNode reportNode, String errorMessage) { reportNode.newReportNode() - .withMessageTemplate("dcLfFailure", "Failed to solve linear system for DC load flow: ${errorMessage}") + .withMessageTemplate("olf.dcLfFailure") .withUntypedValue("errorMessage", errorMessage) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); @@ -532,7 +529,7 @@ public static void reportDcLfSolverFailure(ReportNode reportNode, String errorMe public static void reportDcLfComplete(ReportNode reportNode, boolean succeeded, String outerloopStatus) { reportNode.newReportNode() - .withMessageTemplate("dcLfComplete", "DC load flow completed (solverSuccess=${succeeded}, outerloopStatus=${outerloopStatus})") + .withMessageTemplate("olf.dcLfComplete") .withUntypedValue("succeeded", succeeded) .withUntypedValue("outerloopStatus", outerloopStatus) .withSeverity(TypedValue.INFO_SEVERITY) @@ -541,7 +538,7 @@ public static void reportDcLfComplete(ReportNode reportNode, boolean succeeded, public static void reportGeneratorsDiscardedFromVoltageControlBecauseNotStarted(ReportNode reportNode, int impactedGeneratorCount) { reportNode.newReportNode() - .withMessageTemplate("generatorsDiscardedFromVoltageControlBecauseNotStarted", "${impactedGeneratorCount} generators were discarded from voltage control because not started") + .withMessageTemplate("olf.generatorsDiscardedFromVoltageControlBecauseNotStarted") .withUntypedValue(IMPACTED_GENERATOR_COUNT, impactedGeneratorCount) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -549,7 +546,7 @@ public static void reportGeneratorsDiscardedFromVoltageControlBecauseNotStarted( public static void reportGeneratorsDiscardedFromVoltageControlBecauseReactiveRangeIsTooSmall(ReportNode reportNode, int impactedGeneratorCount) { reportNode.newReportNode() - .withMessageTemplate("generatorsDiscardedFromVoltageControlBecauseReactiveRangeIsTooSmall", "${impactedGeneratorCount} generators have been discarded from voltage control because of a too small reactive range") + .withMessageTemplate("olf.generatorsDiscardedFromVoltageControlBecauseReactiveRangeIsTooSmall") .withUntypedValue(IMPACTED_GENERATOR_COUNT, impactedGeneratorCount) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -557,7 +554,7 @@ public static void reportGeneratorsDiscardedFromVoltageControlBecauseReactiveRan public static void reportGeneratorsDiscardedFromVoltageControlBecauseTargetPIsOutsideActiveLimits(ReportNode reportNode, int impactedGeneratorCount) { reportNode.newReportNode() - .withMessageTemplate("generatorsDiscardedFromVoltageControlBecauseTargetPIsOutsideActiveLimits", "${impactedGeneratorCount} generators have been discarded from voltage control because targetP is outside active power limits") + .withMessageTemplate("olf.generatorsDiscardedFromVoltageControlBecauseTargetPIsOutsideActiveLimits") .withUntypedValue(IMPACTED_GENERATOR_COUNT, impactedGeneratorCount) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -565,7 +562,7 @@ public static void reportGeneratorsDiscardedFromVoltageControlBecauseTargetPIsOu public static void reportGeneratorsDiscardedFromVoltageControlBecauseTargetVIsImplausible(ReportNode reportNode, int impactedGeneratorCount) { reportNode.newReportNode() - .withMessageTemplate("generatorsDiscardedFromVoltageControlBecauseTargetVIsImplausible", "${impactedGeneratorCount} generators have been discarded from voltage control because targetV is implausible") + .withMessageTemplate("olf.generatorsDiscardedFromVoltageControlBecauseTargetVIsImplausible") .withUntypedValue(IMPACTED_GENERATOR_COUNT, impactedGeneratorCount) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -573,7 +570,7 @@ public static void reportGeneratorsDiscardedFromVoltageControlBecauseTargetVIsIm public static void reportGeneratorsDiscardedFromVoltageControlBecauseInconsistentControlledBus(ReportNode reportNode, int impactedGeneratorCount) { reportNode.newReportNode() - .withMessageTemplate("generatorsDiscardedFromVoltageControlBecauseInconsistentControlledBus", "${impactedGeneratorCount} generators have been discarded from voltage control because connected to the same bus but controlling the voltage of different buses") + .withMessageTemplate("olf.generatorsDiscardedFromVoltageControlBecauseInconsistentControlledBus") .withUntypedValue(IMPACTED_GENERATOR_COUNT, impactedGeneratorCount) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -581,7 +578,7 @@ public static void reportGeneratorsDiscardedFromVoltageControlBecauseInconsisten public static void reportGeneratorsDiscardedFromVoltageControlBecauseInconsistentTargetVoltages(ReportNode reportNode, int impactedGeneratorCount) { reportNode.newReportNode() - .withMessageTemplate("generatorsDiscardedFromVoltageControlBecauseInconsistentTargetVoltages", "${impactedGeneratorCount} generators have been discarded from voltage control because connected to the same bus but having different target voltages") + .withMessageTemplate("olf.generatorsDiscardedFromVoltageControlBecauseInconsistentTargetVoltages") .withUntypedValue(IMPACTED_GENERATOR_COUNT, impactedGeneratorCount) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -589,7 +586,7 @@ public static void reportGeneratorsDiscardedFromVoltageControlBecauseInconsisten public static void reportTransformersDiscardedFromVoltageControlBecauseTargetVIsInconsistent(ReportNode reportNode, int impactedTransformerCount) { reportNode.newReportNode() - .withMessageTemplate("transformersDiscardedFromVoltageControlBecauseTargetVIsInconsistent", "${impactedTransformerCount} transformers have been discarded from voltage control because targetV is inconsistent") + .withMessageTemplate("olf.transformersDiscardedFromVoltageControlBecauseTargetVIsInconsistent") .withUntypedValue(IMPACTED_TRANSFORMER_COUNT, impactedTransformerCount) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -597,7 +594,7 @@ public static void reportTransformersDiscardedFromVoltageControlBecauseTargetVIs public static void reportShuntsDiscardedFromVoltageControlBecauseTargetVIsInconsistent(ReportNode reportNode, int impactedShuntCount) { reportNode.newReportNode() - .withMessageTemplate("shuntsDiscardedFromVoltageControlBecauseTargetVIsInconsistent", "${impactedShuntCount} shunt compensators have been discarded from voltage control because targetV is inconsistent") + .withMessageTemplate("olf.shuntsDiscardedFromVoltageControlBecauseTargetVIsInconsistent") .withUntypedValue(IMPACTED_SHUNT_COUNT, impactedShuntCount) .withSeverity(TypedValue.WARN_SEVERITY) .add(); @@ -607,7 +604,7 @@ public static void reportAcLfComplete(ReportNode reportNode, boolean success, St TypedValue severity = success ? TypedValue.INFO_SEVERITY : TypedValue.ERROR_SEVERITY; String successText = success ? "successfully" : "with error"; reportNode.newReportNode() - .withMessageTemplate("acLfComplete", "AC load flow completed ${successText} (solverStatus=${solverStatus}, outerloopStatus=${outerloopStatus})") + .withMessageTemplate("olf.acLfComplete") .withUntypedValue("successText", successText) .withUntypedValue("solverStatus", solverStatus) .withUntypedValue("outerloopStatus", outerloopStatus) @@ -616,14 +613,15 @@ public static void reportAcLfComplete(ReportNode reportNode, boolean success, St } public static ReportNode createLoadFlowReporter(ReportNode reportNode, String networkId) { - return reportNode.newReportNode().withMessageTemplate("loadFlow", "Load flow on network '${networkId}'") + return reportNode.newReportNode().withMessageTemplate("olf.loadFlow") .withUntypedValue(NETWORK_ID, networkId) .add(); } public static ReportNode createRootLfNetworkReportNode(int networkNumCc, int networkNumSc) { return ReportNode.newRootReportNode() - .withMessageTemplate(LF_NETWORK_KEY, "Network CC${networkNumCc} SC${networkNumSc}") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate(LF_NETWORK_KEY) .withUntypedValue(NETWORK_NUM_CC, networkNumCc) .withUntypedValue(NETWORK_NUM_SC, networkNumSc) .build(); @@ -636,68 +634,68 @@ public static ReportNode includeLfNetworkReportNode(ReportNode reportNode, Repor public static ReportNode createNetworkInfoReporter(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate("networkInfo", "Network info") + .withMessageTemplate("olf.networkInfo") .add(); } public static ReportNode createOuterLoopReporter(ReportNode reportNode, String outerLoopType) { return reportNode.newReportNode() - .withMessageTemplate("OuterLoop", "Outer loop ${outerLoopType}") + .withMessageTemplate("olf.OuterLoop") .withUntypedValue("outerLoopType", outerLoopType) .add(); } public static ReportNode createOuterLoopIterationReporter(ReportNode reportNode, int outerLoopIteration) { return reportNode.newReportNode() - .withMessageTemplate("OuterLoopIteration", "Outer loop iteration ${outerLoopIteration}") + .withMessageTemplate("olf.OuterLoopIteration") .withUntypedValue("outerLoopIteration", outerLoopIteration) .add(); } public static ReportNode createSensitivityAnalysis(ReportNode reportNode, String networkId) { return reportNode.newReportNode() - .withMessageTemplate("sensitivityAnalysis", "Sensitivity analysis on network '${networkId}'") + .withMessageTemplate("olf.sensitivityAnalysis") .withUntypedValue(NETWORK_ID, networkId) .add(); } public static ReportNode createAcSecurityAnalysis(ReportNode reportNode, String networkId) { return reportNode.newReportNode() - .withMessageTemplate("acSecurityAnalysis", "AC security analysis on network '${networkId}'") + .withMessageTemplate("olf.acSecurityAnalysis") .withUntypedValue(NETWORK_ID, networkId) .add(); } public static ReportNode createDcSecurityAnalysis(ReportNode reportNode, String networkId) { return reportNode.newReportNode() - .withMessageTemplate("dcSecurityAnalysis", "DC security analysis on network '${networkId}'") + .withMessageTemplate("olf.dcSecurityAnalysis") .withUntypedValue(NETWORK_ID, networkId) .add(); } public static ReportNode createWoodburyDcSecurityAnalysis(ReportNode reportNode, String networkId) { return reportNode.newReportNode() - .withMessageTemplate("woodburyDcSecurityAnalysis", "Woodbury DC security analysis on network '${networkId}'") + .withMessageTemplate("olf.woodburyDcSecurityAnalysis") .withUntypedValue(NETWORK_ID, networkId) .add(); } public static ReportNode createPreContingencySimulation(ReportNode reportNode) { return reportNode.newReportNode() - .withMessageTemplate("preContingencySimulation", "Pre-contingency simulation") + .withMessageTemplate("olf.preContingencySimulation") .add(); } public static ReportNode createPostContingencySimulation(ReportNode reportNode, String contingencyId) { return reportNode.newReportNode() - .withMessageTemplate(POST_CONTINGENCY_SIMULATION_KEY, "Post-contingency simulation '${contingencyId}'") - .withUntypedValue("contingencyId", contingencyId) + .withMessageTemplate(POST_CONTINGENCY_SIMULATION_KEY) + .withUntypedValue(CONTINGENCY_ID, contingencyId) .add(); } public static ReportNode createOperatorStrategySimulation(ReportNode reportNode, String operatorStrategyId) { return reportNode.newReportNode() - .withMessageTemplate("operatorStrategySimulation", "Operator strategy simulation '${operatorStrategyId}'") + .withMessageTemplate("olf.operatorStrategySimulation") .withUntypedValue("operatorStrategyId", operatorStrategyId) .add(); } @@ -705,7 +703,7 @@ public static ReportNode createOperatorStrategySimulation(ReportNode reportNode, public static ReportNode createDetailedSolverReporter(ReportNode reportNode, String solverName, int networkNumCc, int networkNumSc) { ReportNode subReportNode = createSolverReport(reportNode, solverName, networkNumCc, networkNumSc); subReportNode.newReportNode() - .withMessageTemplate("solverNoOuterLoops", "No outer loops have been launched") + .withMessageTemplate("olf.solverNoOuterLoops") .withSeverity(TypedValue.INFO_SEVERITY) .add(); return subReportNode; @@ -715,7 +713,7 @@ public static ReportNode createDetailedSolverReporterOuterLoop(ReportNode report int outerLoopIteration, String outerLoopType) { ReportNode subReportNode = createSolverReport(reportNode, solverName, networkNumCc, networkNumSc); subReportNode.newReportNode() - .withMessageTemplate("solverOuterLoopCurrentType", "Newton-Raphson of outer loop iteration ${outerLoopIteration} of type ${outerLoopType}") + .withMessageTemplate("olf.solverOuterLoopCurrentType") .withUntypedValue("outerLoopIteration", outerLoopIteration) .withUntypedValue("outerLoopType", outerLoopType) .withSeverity(TypedValue.INFO_SEVERITY) @@ -725,7 +723,7 @@ public static ReportNode createDetailedSolverReporterOuterLoop(ReportNode report public static ReportNode createSolverReport(ReportNode reportNode, String solverName, int networkNumCc, int networkNumSc) { return reportNode.newReportNode() - .withMessageTemplate("solver", "${solverName} on Network CC${networkNumCc} SC${networkNumSc}") + .withMessageTemplate("olf.solver") .withUntypedValue(NETWORK_NUM_CC, networkNumCc) .withUntypedValue(NETWORK_NUM_SC, networkNumSc) .withUntypedValue("solverName", solverName) @@ -735,11 +733,11 @@ public static ReportNode createSolverReport(ReportNode reportNode, String solver public static ReportNode createNewtonRaphsonMismatchReporter(ReportNode reportNode, int iteration) { if (iteration == 0) { return reportNode.newReportNode() - .withMessageTemplate("mismatchInitial", "Initial mismatch"). + .withMessageTemplate("olf.mismatchInitial"). add(); } else { return reportNode.newReportNode() - .withMessageTemplate("mismatchIteration", "Iteration ${iteration} mismatch") + .withMessageTemplate("olf.mismatchIteration") .withUntypedValue(ITERATION, iteration) .add(); } @@ -747,7 +745,7 @@ public static ReportNode createNewtonRaphsonMismatchReporter(ReportNode reportNo public static void reportNewtonRaphsonError(ReportNode reportNode, String error) { reportNode.newReportNode() - .withMessageTemplate("NRError", "Newton Raphson error: ${error}") + .withMessageTemplate("olf.NRError") .withUntypedValue("error", error) .withSeverity(TypedValue.ERROR_SEVERITY) .add(); @@ -755,7 +753,7 @@ public static void reportNewtonRaphsonError(ReportNode reportNode, String error) public static void reportNewtonRaphsonNorm(ReportNode reportNode, double norm) { reportNode.newReportNode() - .withMessageTemplate("NRNorm", "Newton-Raphson norm |f(x)|=${norm}") + .withMessageTemplate("olf.NRNorm") .withUntypedValue("norm", norm) .withSeverity(TypedValue.TRACE_SEVERITY) .add(); @@ -780,28 +778,28 @@ public static void reportNewtonRaphsonLargestMismatches(ReportNode reportNode, S } ReportNode subReportNode = reportNode.newReportNode() - .withMessageTemplate("NRMismatch", "Largest ${equationType} mismatch: ${mismatch} ${mismatchUnit}") + .withMessageTemplate("olf.NRMismatch") .withUntypedValue("equationType", acEquationType) .withTypedValue(MISMATCH, mismatchUnitConverter * busReport.mismatch(), OpenLoadFlowReportConstants.MISMATCH_TYPED_VALUE) .withUntypedValue("mismatchUnit", mismatchUnit) .add(); subReportNode.newReportNode() - .withMessageTemplate("NRMismatchBusInfo", "Bus Id: ${busId} (nominalVoltage=${busNominalV}kV)") + .withMessageTemplate("olf.NRMismatchBusInfo") .withUntypedValue(BUS_ID, busReport.busId()) .withUntypedValue("busNominalV", busReport.nominalV()) .withSeverity(TypedValue.TRACE_SEVERITY) .add(); subReportNode.newReportNode() - .withMessageTemplate("NRMismatchBusV", "Bus V: ${busV} pu, ${busPhi} rad") + .withMessageTemplate("olf.NRMismatchBusV") .withUntypedValue("busV", busReport.v()) .withUntypedValue("busPhi", busReport.phi()) .withSeverity(TypedValue.TRACE_SEVERITY) .add(); subReportNode.newReportNode() - .withMessageTemplate("NRMismatchBusInjection", "Bus injection: ${busP} MW, ${busQ} MVar") + .withMessageTemplate("olf.NRMismatchBusInjection") .withUntypedValue("busP", busReport.p()) .withUntypedValue("busQ", busReport.q()) .withSeverity(TypedValue.TRACE_SEVERITY) @@ -810,7 +808,7 @@ public static void reportNewtonRaphsonLargestMismatches(ReportNode reportNode, S public static void reportLineSearchStateVectorScaling(ReportNode reportNode, double stepSize) { reportNode.newReportNode() - .withMessageTemplate("lineSearchStateVectorScaling", "Step size: ${stepSize} (line search)") + .withMessageTemplate("olf.lineSearchStateVectorScaling") .withUntypedValue("stepSize", stepSize) .withSeverity(TypedValue.INFO_SEVERITY) .add(); @@ -818,7 +816,7 @@ public static void reportLineSearchStateVectorScaling(ReportNode reportNode, dou public static void reportMaxVoltageChangeStateVectorScaling(ReportNode reportNode, double stepSize, int vCutCount, int phiCutCount) { reportNode.newReportNode() - .withMessageTemplate("maxVoltageChangeStateVectorScaling", "Step size: ${stepSize} (max voltage change: ${vCutCount} Vmagnitude and ${phiCutCount} Vangle changes outside configured thresholds)") + .withMessageTemplate("olf.maxVoltageChangeStateVectorScaling") .withUntypedValue("stepSize", stepSize) .withUntypedValue("vCutCount", vCutCount) .withUntypedValue("phiCutCount", phiCutCount) @@ -828,7 +826,7 @@ public static void reportMaxVoltageChangeStateVectorScaling(ReportNode reportNod public static void reportNewtonRaphsonBusesOutOfRealisticVoltageRange(ReportNode reportNode, Map busesOutOfRealisticVoltageRange, double minRealisticVoltage, double maxRealisticVoltage) { ReportNode voltageOutOfRangeReport = reportNode.newReportNode() - .withMessageTemplate("newtonRaphsonBusesOutOfRealisticVoltageRange", "${busCountOutOfRealisticVoltageRange} buses have a voltage magnitude out of the configured realistic range [${minRealisticVoltage}, ${maxRealisticVoltage}] p.u.") + .withMessageTemplate("olf.newtonRaphsonBusesOutOfRealisticVoltageRange") .withUntypedValue("busCountOutOfRealisticVoltageRange", busesOutOfRealisticVoltageRange.size()) .withUntypedValue("minRealisticVoltage", minRealisticVoltage) .withUntypedValue("maxRealisticVoltage", maxRealisticVoltage) @@ -836,7 +834,7 @@ public static void reportNewtonRaphsonBusesOutOfRealisticVoltageRange(ReportNode .add(); busesOutOfRealisticVoltageRange.forEach((id, voltage) -> voltageOutOfRangeReport.newReportNode() - .withMessageTemplate("newtonRaphsonBusesOutOfRealisticVoltageRangeDetails", "Bus ${busId} has an unrealistic voltage magnitude: ${voltage} p.u.") + .withMessageTemplate("olf.newtonRaphsonBusesOutOfRealisticVoltageRangeDetails") .withUntypedValue(BUS_ID, id) .withUntypedValue("voltage", voltage) .withSeverity(TypedValue.TRACE_SEVERITY) @@ -845,12 +843,12 @@ public static void reportNewtonRaphsonBusesOutOfRealisticVoltageRange(ReportNode public static void reportAngleReferenceBusAndSlackBuses(ReportNode reportNode, String referenceBus, List slackBuses) { reportNode.newReportNode() - .withMessageTemplate("angleReferenceBusSelection", "Angle reference bus: ${referenceBus}") + .withMessageTemplate("olf.angleReferenceBusSelection") .withUntypedValue("referenceBus", referenceBus) .withSeverity(TypedValue.INFO_SEVERITY) .add(); slackBuses.forEach(slackBus -> reportNode.newReportNode() - .withMessageTemplate("slackBusSelection", "Slack bus: ${slackBus}") + .withMessageTemplate("olf.slackBusSelection") .withUntypedValue("slackBus", slackBus) .withSeverity(TypedValue.INFO_SEVERITY) .add()); @@ -858,14 +856,14 @@ public static void reportAngleReferenceBusAndSlackBuses(ReportNode reportNode, S public static void reportAcEmulationDisabledInWoodburyDcSecurityAnalysis(ReportNode reportNode) { reportNode.newReportNode() - .withMessageTemplate("acEmulationDisabledInWoodburyDcSecurityAnalysis", "AC emulation of HVDC lines is disabled with Woodbury DC Security Analysis. HVDC active power setpoint will be used instead.") + .withMessageTemplate("olf.acEmulationDisabledInWoodburyDcSecurityAnalysis") .withSeverity(TypedValue.WARN_SEVERITY) .add(); } public static void reportContingencyActivePowerLossDistribution(ReportNode reportNode, double mismatch, double remaining) { reportNode.newReportNode() - .withMessageTemplate("contingencyActivePowerLossDistribution", "Contingency caused the loss of ${mismatch} MW injection: ${distributed} MW distributed, ${remaining} MW remaining.") + .withMessageTemplate("olf.contingencyActivePowerLossDistribution") .withUntypedValue(MISMATCH, mismatch) .withUntypedValue("distributed", mismatch - remaining) .withUntypedValue("remaining", remaining) @@ -875,9 +873,16 @@ public static void reportContingencyActivePowerLossDistribution(ReportNode repor public static void reportActionApplicationFailure(String actionId, String contingencyId, ReportNode node) { node.newReportNode() - .withMessageTemplate("LfActionUtils", "Action '${actionId}': may not have been applied successfully on contingency '${contingencyId}'") + .withMessageTemplate("olf.LfActionUtils") .withUntypedValue(ACTION_ID, actionId) .withUntypedValue(CONTINGENCY_ID, contingencyId) .add(); } + + public static ReportNode createThreadRootReport() { + return ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("olf.threadRoot") + .build(); + } } diff --git a/src/main/java/com/powsybl/openloadflow/util/report/PowsyblOpenLoadFlowReportResourceBundle.java b/src/main/java/com/powsybl/openloadflow/util/report/PowsyblOpenLoadFlowReportResourceBundle.java new file mode 100644 index 0000000000..00d2f25c58 --- /dev/null +++ b/src/main/java/com/powsybl/openloadflow/util/report/PowsyblOpenLoadFlowReportResourceBundle.java @@ -0,0 +1,26 @@ +package com.powsybl.openloadflow.util.report; + +/** + * 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 + */ + +import com.google.auto.service.AutoService; +import com.powsybl.commons.report.ReportResourceBundle; + +/** + * @author Alice Caron {@literal } + */ + +@AutoService(ReportResourceBundle.class) +public final class PowsyblOpenLoadFlowReportResourceBundle implements ReportResourceBundle { + + public static final String BASE_NAME = "com.powsybl.openloadflow.reports"; + + public String getBaseName() { + return BASE_NAME; + } +} diff --git a/src/main/resources/com/powsybl/openloadflow/reports.properties b/src/main/resources/com/powsybl/openloadflow/reports.properties new file mode 100644 index 0000000000..b01e759f59 --- /dev/null +++ b/src/main/resources/com/powsybl/openloadflow/reports.properties @@ -0,0 +1,87 @@ +olf.acEmulationDisabledInWoodburyDcSecurityAnalysis = AC emulation of HVDC lines is disabled with Woodbury DC Security Analysis. HVDC active power setpoint will be used instead. +olf.acLfComplete = AC load flow completed ${successText} (solverStatus=${solverStatus}, outerloopStatus=${outerloopStatus}) +olf.acSecurityAnalysis = AC security analysis on network '${networkId}' +olf.activePowerControlPstsChangedTaps = ${numOfActivePowerControlPstsThatChangedTap} active power control PST(s) changed taps +olf.angleReferenceBusSelection = Angle reference bus: ${referenceBus} +olf.areaInterchangeControlAreaDistributionSuccess = Area ${area} interchange mismatch (${mismatch} MW) distributed in ${iterationCount} distribution iteration(s) +olf.areaInterchangeControlAreaMismatch = Remaining mismatch for Area ${area}: ${mismatch} MW +olf.areaInterchangeControlDistributionFailure = Failed to distribute interchange active power mismatch +olf.areaNoInterchangeControl = Area ${area} will not be considered in area interchange control, reason: ${reason} +olf.branchControlledAtBothSides = Controlled branch ${controlledBranchId} is controlled at both sides. Controlled side ${keptSide} (kept) side ${rejectedSide} (rejected). +olf.busAlreadyControlledWithDifferentTargetV = Bus ${controllerBusId} controls voltage of bus ${controlledBusId} which is already controlled by buses [${busesId}] with a different target voltage: ${keptTargetV} kV (kept) and ${ignoredTargetV} kV (ignored) +olf.busForcedToBePv = All PV buses should switch PQ, strongest one will stay PV: ${busId} +olf.busWithUpdatedQLimits = ${numBusesWithUpdatedQLimits} buses blocked at a reactive limit have been adjusted because the reactive limit changed +olf.componentsWithoutGenerators = No calculation will be done on ${deadComponentsCount} network(s) that have no generators +olf.contingencyActivePowerLossDistribution = Contingency caused the loss of ${mismatch} MW injection: ${distributed} MW distributed, ${remaining} MW remaining. +olf.controllerShuntAlreadyInVoltageControl = Controller shunt ${controllerShuntId} is already in a shunt voltage control. The second controlled bus ${controlledBusId} is ignored +olf.currentLimiterPstsChangedTaps = ${numOfCurrentLimiterPstsThatChangedTap} current limiter PST(s) changed taps +olf.dcLfComplete = DC load flow completed (solverSuccess=${succeeded}, outerloopStatus=${outerloopStatus}) +olf.dcLfFailure = Failed to solve linear system for DC load flow: ${errorMessage} +olf.dcSecurityAnalysis = DC security analysis on network '${networkId}' +olf.generatorsDiscardedFromVoltageControlBecauseInconsistentControlledBus = ${impactedGeneratorCount} generators have been discarded from voltage control because connected to the same bus but controlling the voltage of different buses +olf.generatorsDiscardedFromVoltageControlBecauseInconsistentTargetVoltages = ${impactedGeneratorCount} generators have been discarded from voltage control because connected to the same bus but having different target voltages +olf.generatorsDiscardedFromVoltageControlBecauseNotStarted = ${impactedGeneratorCount} generators were discarded from voltage control because not started +olf.generatorsDiscardedFromVoltageControlBecauseReactiveRangeIsTooSmall = ${impactedGeneratorCount} generators have been discarded from voltage control because of a too small reactive range +olf.generatorsDiscardedFromVoltageControlBecauseTargetPIsOutsideActiveLimits = ${impactedGeneratorCount} generators have been discarded from voltage control because targetP is outside active power limits +olf.generatorsDiscardedFromVoltageControlBecauseTargetVIsImplausible = ${impactedGeneratorCount} generators have been discarded from voltage control because targetV is implausible +olf.LfActionUtils = Action '${actionId}': may not have been applied successfully on contingency '${contingencyId}' +olf.lineSearchStateVectorScaling = Step size: ${stepSize} (line search) +olf.loadFlow = Load flow on network '${networkId}' +olf.maxOuterLoopIterations = Maximum number of outerloop iterations reached: ${outerLoopIterationCount} +olf.maxVoltageChangeStateVectorScaling = Step size: ${stepSize} (max voltage change: ${vCutCount} Vmagnitude and ${phiCutCount} Vangle changes outside configured thresholds) +olf.mismatchDistributionFailure = Failed to distribute slack bus active power mismatch, ${mismatch} MW remains +olf.mismatchDistributionSuccess = Slack bus active power (${initialMismatch} MW) distributed in ${iterationCount} distribution iteration(s) +olf.mismatchInitial = Initial mismatch +olf.mismatchIteration = Iteration ${iteration} mismatch +olf.networkBalance = Network balance: active generation=${activeGeneration} MW, active load=${activeLoad} MW, reactive generation=${reactiveGeneration} MVar, reactive load=${reactiveLoad} MVar +olf.lfNetwork = Network CC${networkNumCc} SC${networkNumSc} +olf.networkInfo = Network info +olf.networkMustHaveAtLeastOneBusGeneratorVoltageControlEnabled = Network must have at least one bus with generator voltage control enabled +olf.networkSize = Network has ${busCount} buses and ${branchCount} branches +olf.newtonRaphsonBusesOutOfRealisticVoltageRange = ${busCountOutOfRealisticVoltageRange} buses have a voltage magnitude out of the configured realistic range [${minRealisticVoltage}, ${maxRealisticVoltage}] p.u. +olf.newtonRaphsonBusesOutOfRealisticVoltageRangeDetails = Bus ${busId} has an unrealistic voltage magnitude: ${voltage} p.u. +olf.notUniqueControlledBusDisablingControl = Generators [${generatorIds}] are connected to the same bus ${controllerBusId} but control the voltage of different buses (${controlledBusId} and ${controlledBusGenId}): disabling voltage control +olf.notUniqueControlledBusKeepingFirstControl = Generators [${generatorIds}] are connected to the same bus ${controllerBusId} but control the voltage of different buses: ${controlledBusId} (kept) and ${controlledBusGenId} (rejected) +olf.notUniqueTargetVControllerBusDisablingControl = Generators [${generatorIds}] are connected to the same bus ${controllerBusId} with different target voltages (${targetV1} kV and ${targetV2} kV): disabling voltage control +olf.notUniqueTargetVControllerBusKeepingFirstControl = Generators [${generatorIds}] are connected to the same bus ${controllerBusId} with different target voltages: ${keptTargetV} kV (kept) and ${rejectedTargetV} kV (rejected) +olf.NRError = Newton Raphson error: ${error} +olf.NRMismatch = Largest ${equationType} mismatch: ${mismatch} ${mismatchUnit} +olf.NRMismatchBusInfo = Bus Id: ${busId} (nominalVoltage=${busNominalV}kV) +olf.NRMismatchBusInjection = Bus injection: ${busP} MW, ${busQ} MVar +olf.NRMismatchBusV = Bus V: ${busV} pu, ${busPhi} rad +olf.NRNorm = Newton-Raphson norm |f(x)|=${norm} +olf.operatorStrategySimulation = Operator strategy simulation '${operatorStrategyId}' +olf.OuterLoop = Outer loop ${outerLoopType} +olf.OuterLoopIteration = Outer loop iteration ${outerLoopIteration} +olf.outerLoopStatus = Outer loop unsuccessful with status: ${outerLoopStatus} +olf.postContingencySimulation = Post-contingency simulation '${contingencyId}' +olf.PqToPvBuses = ${pqToPvBusCount} buses switched PQ -> PV (${blockedPqBusCount} buses blocked PQ due to the max number of switches) +olf.pqToPvBusMaxLimit = Switch bus '${busId}' PQ -> PV, q=maxQ and v=${busV}kV > targetV=${targetV}kV +olf.pqToPvBusMinLimit = Switch bus '${busId}' PQ -> PV, q=minQ and v=${busV}kV < targetV=${targetV}kV +olf.preContingencySimulation = Pre-contingency simulation +olf.pvPqSwitchLimit = Bus '${busId}' blocked PQ as it has reached its max number of PQ -> PV switch (${limit}) +olf.pvToPqBuses = ${pvToPqBusCount} buses switched PV -> PQ (${remainingPvBusCount} buses remain PV) +olf.pvToPqMaxQ = Switch bus '${busId}' PV -> PQ, q=${busQ} > maxQ=${maxQ} +olf.PvToPqMaxRealisticV = Switch bus '${busId}' PV -> PQ, q set to ${targetQ} = targetQ - because V > ${maxRealisticV}kV when remote voltage target is maintained +olf.PvToPqMinQ = Switch bus '${busId}' PV -> PQ, q=${busQ} < minQ=${minQ} +olf.PvToPqMinRealisticV = Switch bus '${busId}' PV -> PQ, q set to ${targetQ} = targetQ - because V < ${minRealisticV}kV when remote voltage target is maintained +olf.reactiveControllerBusesToPqBuses = ${remoteReactivePowerControllerBusToPqCount} bus(es) with remote reactive power controller switched PQ +olf.reactiveControllerBusesToPqMaxQ = Remote reactive power controller bus '${busId}' -> PQ, q=${busQ} > maxQ=${maxQ} +olf.reactiveControllerBusesToPqMinQ = Remote reactive power controller bus '${busId}' -> PQ, q=${busQ} < minQ=${minQ} +olf.sensitivityAnalysis = Sensitivity analysis on network '${networkId}' +olf.shuntsDiscardedFromVoltageControlBecauseTargetVIsInconsistent = ${impactedShuntCount} shunt compensators have been discarded from voltage control because targetV is inconsistent +olf.shuntVoltageControlChangedSection = ${numShuntVoltageControlAdjusted} shunts changed section +olf.slackBusSelection = Slack bus: ${slackBus} +olf.solver = ${solverName} on Network CC${networkNumCc} SC${networkNumSc} +olf.solverNoOuterLoops = No outer loops have been launched +olf.solverOuterLoopCurrentType = Newton-Raphson of outer loop iteration ${outerLoopIteration} of type ${outerLoopType} +olf.standByAutomatonActivation = Activation of voltage control of static var compensator with stand by automaton: bus ${busId} switched PQ -> PV with targetV ${newTargetV} +olf.threadRoot = threadRoot +olf.transformerControlAlreadyExistsUpdateDeadband = Transformers ${firstControllerId} and ${newControllerId} control voltage at bus ${controlledBusId} with different deadbands, thinnest will be kept: ${newTargetDeadband}kV (kept) and ${oldTargetDeadband}kV (rejected) +olf.transformerControlAlreadyExistsWithDifferentTargetV = Transformers ${firstControllerId} and ${newControllerId} control voltage at bus ${controlledBusId} with different target voltages: ${vcTargetValue}kV (kept) and ${targetValue}kV (rejected) +olf.transformerControlBranchesOutsideDeadband = ${numTransformerControlBranchesOutsideDeadband} reactive power-controlled branches are outside of their target deadbands +olf.transformerControlBusesOutsideDeadband = ${numTransformerControlBusesOutsideDeadband} voltage-controlled buses are outside of their target deadbands +olf.transformerControlChangedTaps = ${numTransformerControlAdjusted} transformers changed tap position +olf.transformerControlTapLimit = ${numTransformerControlTapLimit} transformers reached their tap maximum position +olf.transformersDiscardedFromVoltageControlBecauseTargetVIsInconsistent = ${impactedTransformerCount} transformers have been discarded from voltage control because targetV is inconsistent +olf.woodburyDcSecurityAnalysis = Woodbury DC security analysis on network '${networkId}' diff --git a/src/main/resources/com/powsybl/openloadflow/reports_en_US.properties b/src/main/resources/com/powsybl/openloadflow/reports_en_US.properties new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/src/main/resources/com/powsybl/openloadflow/reports_en_US.properties @@ -0,0 +1 @@ + diff --git a/src/main/resources/com/powsybl/openloadflow/reports_fr.properties b/src/main/resources/com/powsybl/openloadflow/reports_fr.properties new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/src/main/resources/com/powsybl/openloadflow/reports_fr.properties @@ -0,0 +1 @@ + diff --git a/src/main/resources/com/powsybl/openloadflow/reports_fr_FR.properties b/src/main/resources/com/powsybl/openloadflow/reports_fr_FR.properties new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/src/main/resources/com/powsybl/openloadflow/reports_fr_FR.properties @@ -0,0 +1 @@ + From 09c1c6e21c7fd1fda7697ba5db6fcff33d75c358 Mon Sep 17 00:00:00 2001 From: CARON Alice Date: Thu, 3 Apr 2025 14:05:34 +0200 Subject: [PATCH 3/7] Fix tests loading the olf ResourceBundle in needed rootreport nodes Signed-off-by: CARON Alice --- .../ac/AcLoadFlowEurostagTutorialExample1Test.java | 8 ++++++-- .../openloadflow/ac/AcLoadFlowReportTest.java | 12 ++++++++++++ .../powsybl/openloadflow/ac/AcLoadFlowShuntTest.java | 2 ++ ...cLoadFlowTransformerReactivePowerControlTest.java | 7 ++++++- .../ac/GeneratorRemoteControlPQSwitchTest.java | 5 ++++- .../openloadflow/ac/GeneratorRemoteControlTest.java | 2 ++ .../openloadflow/ac/SecondaryVoltageControlTest.java | 11 +++++++++-- .../com/powsybl/openloadflow/ac/SwitchPqPvTest.java | 6 +++++- .../com/powsybl/openloadflow/dc/DcLoadFlowTest.java | 6 +++++- .../openloadflow/sa/OpenSecurityAnalysisTest.java | 4 ++++ .../sa/OpenSecurityAnalysisWithActionsTest.java | 9 ++++++++- .../sensi/AcSensitivityAnalysisReportTest.java | 3 +++ 12 files changed, 66 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowEurostagTutorialExample1Test.java b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowEurostagTutorialExample1Test.java index f61080d1ab..fb8d4863d5 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowEurostagTutorialExample1Test.java +++ b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowEurostagTutorialExample1Test.java @@ -23,6 +23,7 @@ import com.powsybl.openloadflow.network.EurostagFactory; import com.powsybl.openloadflow.network.SlackBusSelectionMode; import com.powsybl.openloadflow.util.LoadFlowAssert; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -280,6 +281,7 @@ void noGeneratorPvTest() { network.getGenerator("GEN").setVoltageRegulatorOn(false); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("unitTest", "") .build(); LoadFlowResult result = loadFlowRunner.run(network, VariantManagerConstants.INITIAL_VARIANT_ID, LocalComputationManager.getDefault(), parameters, reportNode); @@ -292,9 +294,9 @@ void noGeneratorPvTest() { ReportNode lfReportNode = reportNode.getChildren().get(0); assertEquals(1, lfReportNode.getChildren().size()); ReportNode networkReportNode = lfReportNode.getChildren().get(0); - assertEquals("lfNetwork", networkReportNode.getMessageKey()); + assertEquals("olf.lfNetwork", networkReportNode.getMessageKey()); ReportNode networkInfoReportNode = networkReportNode.getChildren().get(0); - assertEquals("networkInfo", networkInfoReportNode.getMessageKey()); + assertEquals("olf.networkInfo", networkInfoReportNode.getMessageKey()); assertEquals(1, networkInfoReportNode.getChildren().size()); assertEquals("Network must have at least one bus with generator voltage control enabled", networkInfoReportNode.getChildren().get(0).getMessage()); @@ -460,6 +462,7 @@ void testGeneratorsConnectedToSameBusNotControllingSameBus() throws IOException .setRegulatingTerminal(network.getLoad("LOAD").getTerminal()) .add(); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); loadFlowRunner.run(network, VariantManagerConstants.INITIAL_VARIANT_ID, LocalComputationManager.getDefault(), parameters, reportNode); @@ -471,6 +474,7 @@ void testGeneratorsConnectedToSameBusNotControllingSameBus() throws IOException @Test void maxOuterLoopIterationTest() throws IOException { ReportNode report = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("test", "test") .build(); gen.setTargetP(1000); diff --git a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowReportTest.java b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowReportTest.java index 2c6e8ede5d..a168603029 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowReportTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowReportTest.java @@ -25,6 +25,7 @@ import com.powsybl.openloadflow.graph.NaiveGraphConnectivityFactory; import com.powsybl.openloadflow.network.*; import com.powsybl.openloadflow.util.LoadFlowAssert; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -42,6 +43,7 @@ class AcLoadFlowReportTest { void testEsgTutoDetailedNrLogsLf() throws IOException { Network network = EurostagFactory.fix(EurostagTutorialExample1Factory.create()); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testEsgTutoReport", "Test ESG tutorial report") .build(); var lfParameters = new LoadFlowParameters() @@ -65,6 +67,7 @@ void testEsgTutoDetailedNrLogsLf() throws IOException { void testShuntVoltageControlOuterLoopReport() throws IOException { Network network = ShuntNetworkFactory.createWithTwoShuntCompensators(); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); var lfParameters = new LoadFlowParameters() @@ -94,6 +97,7 @@ void testTransformerReactivePowerControlOuterLoopReport() throws IOException { .setRegulationMode(RatioTapChanger.RegulationMode.REACTIVE_POWER) .setRegulationValue(-0.55); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); var lfParameters = new LoadFlowParameters(); @@ -127,6 +131,7 @@ void testMultipleComponents() throws IOException { // test in AC ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); LoadFlowResult result = runner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), lfParameters, reportNode); @@ -143,6 +148,7 @@ void testMultipleComponents() throws IOException { // test in DC lfParameters.setDc(true); reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); result = runner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), lfParameters, reportNode); @@ -163,6 +169,7 @@ void generatorVoltageControlDiscarded() throws IOException { network.getGenerator("g2").setTargetV(10); // not plausible targetV, will be discarded and reported ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); var lfParameters = new LoadFlowParameters(); @@ -189,6 +196,7 @@ void transformerVoltageControlDiscarded() throws IOException { .setRegulationMode(RatioTapChanger.RegulationMode.VOLTAGE) .setTargetV(100); // not plausible, will be discarded and reported ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); var lfParameters = new LoadFlowParameters(); @@ -207,6 +215,7 @@ void shuntVoltageControlDiscarded() throws IOException { Network network = ShuntNetworkFactory.createWithTwoShuntCompensators(); network.getShuntCompensator("SHUNT2").setVoltageRegulatorOn(true).setTargetV(600); // not plausible targetV, will be discarded and reported ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); var lfParameters = new LoadFlowParameters() @@ -225,6 +234,7 @@ void testTransformerControlAlreadyExistsWithDifferentTargetV() throws IOExceptio Network network = VoltageControlNetworkFactory.createWithTransformerSharedRemoteControl(); network.getTwoWindingsTransformer("T2wT2").getRatioTapChanger().setTargetV(34.5).setTargetDeadband(3.0); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); var lfParameters = new LoadFlowParameters(); @@ -244,6 +254,7 @@ void testTransformerControlAlreadyExistsWithDifferentTargetV() throws IOExceptio void areaInterchangeControl() throws IOException { Network network = MultiAreaNetworkFactory.createTwoAreasWithXNode(); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); var lfParameters = new LoadFlowParameters(); @@ -262,6 +273,7 @@ void areaInterchangeControl() throws IOException { void busesOutOfRealisticVoltageRangeTest() throws IOException { Network network = EurostagTutorialExample1Factory.create(); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); var lfParameters = new LoadFlowParameters(); diff --git a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowShuntTest.java b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowShuntTest.java index 8c45557b25..37bc4c4fb0 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowShuntTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowShuntTest.java @@ -18,6 +18,7 @@ import com.powsybl.openloadflow.OpenLoadFlowProvider; import com.powsybl.openloadflow.network.*; import com.powsybl.openloadflow.util.LoadFlowAssert; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -355,6 +356,7 @@ void testUnsupportedSharedVoltageControl() throws IOException { parameters.setShuntCompensatorVoltageControlOn(true); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); LoadFlowResult result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); diff --git a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowTransformerReactivePowerControlTest.java b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowTransformerReactivePowerControlTest.java index 6131485efd..9a6c849b84 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowTransformerReactivePowerControlTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowTransformerReactivePowerControlTest.java @@ -22,6 +22,7 @@ import com.powsybl.openloadflow.OpenLoadFlowProvider; import com.powsybl.openloadflow.ac.outerloop.ReactiveLimitsOuterLoop; import com.powsybl.openloadflow.network.*; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -130,7 +131,10 @@ void testGeneratorRemoteReactivePowerControlOutsideReactiveLimits() throws IOExc parametersExt.setGeneratorReactivePowerRemoteControl(true) .setTransformerReactivePowerControl(true); - ReportNode report = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + ReportNode report = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("test", "test") + .build(); result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, report); assertTrue(result.isFullyConverged()); @@ -203,6 +207,7 @@ void testGeneratorRemoteReactivePowerControlBelowReactiveLimits() throws IOExcep parametersExt.setGeneratorReactivePowerRemoteControl(true); ReportNode report = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("test", "test") .build(); diff --git a/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlPQSwitchTest.java b/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlPQSwitchTest.java index 590aaea481..f9c25a8751 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlPQSwitchTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlPQSwitchTest.java @@ -28,6 +28,7 @@ import com.powsybl.openloadflow.ac.outerloop.ReactiveLimitsOuterLoop; import com.powsybl.openloadflow.network.SlackBusSelectionMode; import com.powsybl.openloadflow.util.LoadFlowAssert; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; @@ -166,7 +167,9 @@ void setUp() { // Activate trace logs to ensure ReactiveLimitsLoop trace logs are run at least once per build LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); loggerContext.getLogger(ReactiveLimitsOuterLoop.class).setLevel(Level.TRACE); - reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("test", "test").build(); } @AfterEach diff --git a/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlTest.java b/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlTest.java index 94687673f4..a8665a37c5 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlTest.java @@ -24,6 +24,7 @@ import com.powsybl.openloadflow.network.*; import com.powsybl.openloadflow.network.impl.LfNetworkLoaderImpl; import com.powsybl.openloadflow.util.LoadFlowAssert; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -504,6 +505,7 @@ void testSharedGeneratorRemoteReactivePowerControl() throws IOException { parametersExt.setGeneratorReactivePowerRemoteControl(true); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testReport", "Test Report") .build(); LoadFlowResult result2 = loadFlowRunner.run(network, VariantManagerConstants.INITIAL_VARIANT_ID, LocalComputationManager.getDefault(), parameters, reportNode); diff --git a/src/test/java/com/powsybl/openloadflow/ac/SecondaryVoltageControlTest.java b/src/test/java/com/powsybl/openloadflow/ac/SecondaryVoltageControlTest.java index 37078d80ca..08450d9168 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/SecondaryVoltageControlTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/SecondaryVoltageControlTest.java @@ -25,6 +25,7 @@ import com.powsybl.openloadflow.network.LfNetworkParameters; import com.powsybl.openloadflow.network.LfSecondaryVoltageControl; import com.powsybl.openloadflow.network.impl.LfNetworkLoaderImpl; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -191,7 +192,10 @@ void testUnblockGeneratorFromLimit() throws IOException { parametersExt.setSecondaryVoltageControl(true); - ReportNode node = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + ReportNode node = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("test", "test") + .build(); // try to put g6 and g8 at qmax to see if they are correctly unblock from qmin var result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, node); @@ -269,7 +273,10 @@ void testCannotUnblockGeneratorFromLimit() throws IOException { parametersExt.setSecondaryVoltageControl(true); parametersExt.setReactiveLimitsMaxPqPvSwitch(0); // Will block PQ->PV move - ReportNode node = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + ReportNode node = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("test", "test") + .build(); // try to put g6 and g8 at qmax to see if they are correctly unblock from qmin var result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, node); diff --git a/src/test/java/com/powsybl/openloadflow/ac/SwitchPqPvTest.java b/src/test/java/com/powsybl/openloadflow/ac/SwitchPqPvTest.java index b519a8674b..5e9dbf3607 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/SwitchPqPvTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/SwitchPqPvTest.java @@ -20,6 +20,7 @@ import com.powsybl.openloadflow.network.AbstractLoadFlowNetworkFactory; import com.powsybl.openloadflow.network.SlackBusSelectionMode; import com.powsybl.openloadflow.util.LoadFlowAssert; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -205,7 +206,10 @@ void testMultipleSwitch() throws IOException { .setMaxQ(700) .add(); g2.setTargetV(22); - ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("test", "test") + .build(); LoadFlowResult result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); assertTrue(result.isFullyConverged()); // bus 1 and 3 switch PQ at first outer loop, then at next outer loop bus 3 go back PV diff --git a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java index 2b7c9774ee..ffdfdca84c 100644 --- a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java +++ b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java @@ -25,6 +25,7 @@ import com.powsybl.openloadflow.network.impl.Networks; import com.powsybl.openloadflow.util.LoadFlowAssert; import com.powsybl.openloadflow.util.PerUnit; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -495,7 +496,10 @@ void outerLoopMaxTotalIterationTest() throws IOException { parametersExt.setAreaInterchangePMaxMismatch(1) .setMaxOuterLoopIterations(1); - ReportNode reportNodeWithLimit1 = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + ReportNode reportNodeWithLimit1 = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("test", "test") + .build(); var result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNodeWithLimit1); assertFalse(result.isFullyConverged()); diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java index 8326c356a7..6f4c128964 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java @@ -44,6 +44,7 @@ import com.powsybl.openloadflow.network.impl.OlfThreeWindingsTransformerResult; import com.powsybl.openloadflow.sa.extensions.ContingencyLoadFlowParameters; import com.powsybl.openloadflow.util.LoadFlowAssert; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import com.powsybl.security.*; import com.powsybl.security.condition.TrueCondition; import com.powsybl.security.limitreduction.LimitReduction; @@ -1779,6 +1780,7 @@ void reportTest() throws IOException { List contingencies = createAllBranchesContingencies(network); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("TestSecurityAnalysis", "Test security analysis report") .build(); @@ -3726,6 +3728,7 @@ void multiComponentSaTest(int threadCount) throws IOException { ); ReportNode testReport = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("TEST", "TEST Report Node") .build(); @@ -3830,6 +3833,7 @@ void multiComponentSaTestContingencyBothComponentsAndOperatorStrategy(int thread .toList(); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("TEST", "Test Report Node") .build(); diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java index aa7b3ceaf6..0c0a7c670a 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java @@ -24,6 +24,7 @@ import com.powsybl.openloadflow.network.*; import com.powsybl.openloadflow.sa.extensions.ContingencyLoadFlowParameters; import com.powsybl.openloadflow.util.LoadFlowAssert; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import com.powsybl.security.*; import com.powsybl.security.condition.AllViolationCondition; import com.powsybl.security.condition.AnyViolationCondition; @@ -93,6 +94,7 @@ void testSecurityAnalysisReport() throws IOException { saParameters.setLoadFlowParameters(lfParameters); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testSaReport", "Test report of security analysis") .build(); runSecurityAnalysis(network, contingencies, Collections.emptyList(), @@ -138,6 +140,7 @@ void testSecurityAnalysisWithOperatorStrategy() throws IOException { securityAnalysisParameters.setLoadFlowParameters(parameters); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testSaReport", "Test report of security analysis with operator strategies") .build(); SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters, @@ -371,7 +374,10 @@ void testMetrixTutorial() throws IOException { assertEquals(639.268, getOperatorStrategyResult(result, "strategy3").getNetworkResult().getBranchResult("S_SO_2").getI1(), LoadFlowAssert.DELTA_I); assertEquals(639.268, getOperatorStrategyResult(result, "strategy4").getNetworkResult().getBranchResult("S_SO_2").getI1(), LoadFlowAssert.DELTA_I); - ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withMessageTemplate("test", "test") + .build(); loadFlowRunner.run(network, parameters); assertEquals(346.296, network.getLine("S_SO_2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); @@ -1718,6 +1724,7 @@ void testOperatorStrategyNoMoreBusVoltageControlled() throws IOException { ContingencyContext.specificContingency("NHV1_NHV2_2"), new TrueCondition(), List.of("open NGEN_NHV1"))); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testSaReport", "Test report of security analysis") .build(); SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, Collections.emptyList(), new SecurityAnalysisParameters(), operatorStrategies, actions, reportNode); diff --git a/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisReportTest.java b/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisReportTest.java index f82141cd09..badaae0fb2 100644 --- a/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisReportTest.java +++ b/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisReportTest.java @@ -15,6 +15,7 @@ import com.powsybl.loadflow.LoadFlowParameters; import com.powsybl.openloadflow.OpenLoadFlowParameters; import com.powsybl.openloadflow.network.EurostagFactory; +import com.powsybl.openloadflow.util.report.PowsyblOpenLoadFlowReportResourceBundle; import com.powsybl.sensitivity.SensitivityAnalysisParameters; import com.powsybl.sensitivity.SensitivityFactor; import org.junit.jupiter.api.Test; @@ -36,6 +37,7 @@ class AcSensitivityAnalysisReportTest extends AbstractSensitivityAnalysisTest { void testEsgTuto() throws IOException { Network network = EurostagFactory.fix(EurostagTutorialExample1Factory.create()); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testEsgTutoReport", "Test ESG tutorial report") .build(); runAcLf(network, reportNode); @@ -54,6 +56,7 @@ void testEsgTuto() throws IOException { void testEsgTutoDetailedNrLogsSensi() throws IOException { Network network = EurostagFactory.fix(EurostagTutorialExample1Factory.create()); ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("testEsgTutoReport", "Test ESG tutorial report") .build(); From aedcaa30fe1af64ae955f1d1c7c4c8e513b79aa2 Mon Sep 17 00:00:00 2001 From: CARON Alice Date: Thu, 3 Apr 2025 14:13:14 +0200 Subject: [PATCH 4/7] Create test resource bundle and remove usages of deprecated withMessageTemplate method in tests report nodes Signed-off-by: CARON Alice --- ...cLoadFlowEurostagTutorialExample1Test.java | 11 ++--- .../openloadflow/ac/AcLoadFlowReportTest.java | 45 ++++++++++--------- .../openloadflow/ac/AcLoadFlowShuntTest.java | 5 ++- ...owTransformerReactivePowerControlTest.java | 9 ++-- .../ac/DistributedSlackOnGenerationTest.java | 2 +- .../ac/DistributedSlackOnLoadTest.java | 6 +-- .../GeneratorRemoteControlPQSwitchTest.java | 5 ++- .../ac/GeneratorRemoteControlTest.java | 5 ++- ...neratorTargetVoltageInconsistencyTest.java | 11 +++-- .../ac/SecondaryVoltageControlTest.java | 9 ++-- .../openloadflow/ac/SwitchPqPvTest.java | 5 ++- .../openloadflow/dc/DcLoadFlowTest.java | 11 ++--- .../sa/OpenSecurityAnalysisTest.java | 17 +++---- .../OpenSecurityAnalysisWithActionsTest.java | 19 ++++---- .../AcSensitivityAnalysisReportTest.java | 9 ++-- src/test/resources/i18n/reports.properties | 9 ++++ .../resources/i18n/reports_en_US.properties | 1 + src/test/resources/saMtReport.txt | 2 +- 18 files changed, 103 insertions(+), 78 deletions(-) create mode 100644 src/test/resources/i18n/reports.properties create mode 100644 src/test/resources/i18n/reports_en_US.properties diff --git a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowEurostagTutorialExample1Test.java b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowEurostagTutorialExample1Test.java index fb8d4863d5..cceee5a9b9 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowEurostagTutorialExample1Test.java +++ b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowEurostagTutorialExample1Test.java @@ -9,6 +9,7 @@ package com.powsybl.openloadflow.ac; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.SlackTerminal; @@ -282,7 +283,7 @@ void noGeneratorPvTest() { ReportNode reportNode = ReportNode.newRootReportNode() .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("unitTest", "") + .withMessageTemplate("unitTest") .build(); LoadFlowResult result = loadFlowRunner.run(network, VariantManagerConstants.INITIAL_VARIANT_ID, LocalComputationManager.getDefault(), parameters, reportNode); assertFalse(result.isFullyConverged()); @@ -462,8 +463,8 @@ void testGeneratorsConnectedToSameBusNotControllingSameBus() throws IOException .setRegulatingTerminal(network.getLoad("LOAD").getTerminal()) .add(); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); loadFlowRunner.run(network, VariantManagerConstants.INITIAL_VARIANT_ID, LocalComputationManager.getDefault(), parameters, reportNode); assertVoltageEquals(24.5, network.getBusBreakerView().getBus("NGEN")); @@ -474,8 +475,8 @@ void testGeneratorsConnectedToSameBusNotControllingSameBus() throws IOException @Test void maxOuterLoopIterationTest() throws IOException { ReportNode report = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("test", "test") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("test") .build(); gen.setTargetP(1000); parameters.setDistributedSlack(true); diff --git a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowReportTest.java b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowReportTest.java index a168603029..74373bbe1c 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowReportTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowReportTest.java @@ -8,6 +8,7 @@ package com.powsybl.openloadflow.ac; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.RatioTapChanger; @@ -43,8 +44,8 @@ class AcLoadFlowReportTest { void testEsgTutoDetailedNrLogsLf() throws IOException { Network network = EurostagFactory.fix(EurostagTutorialExample1Factory.create()); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testEsgTutoReport", "Test ESG tutorial report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testEsgTutoReport") .build(); var lfParameters = new LoadFlowParameters() .setTransformerVoltageControlOn(true); @@ -67,8 +68,8 @@ void testEsgTutoDetailedNrLogsLf() throws IOException { void testShuntVoltageControlOuterLoopReport() throws IOException { Network network = ShuntNetworkFactory.createWithTwoShuntCompensators(); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); var lfParameters = new LoadFlowParameters() .setShuntCompensatorVoltageControlOn(true); @@ -97,8 +98,8 @@ void testTransformerReactivePowerControlOuterLoopReport() throws IOException { .setRegulationMode(RatioTapChanger.RegulationMode.REACTIVE_POWER) .setRegulationValue(-0.55); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); var lfParameters = new LoadFlowParameters(); var olfParameters = OpenLoadFlowParameters.create(lfParameters); @@ -131,8 +132,8 @@ void testMultipleComponents() throws IOException { // test in AC ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); LoadFlowResult result = runner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), lfParameters, reportNode); @@ -148,8 +149,8 @@ void testMultipleComponents() throws IOException { // test in DC lfParameters.setDc(true); reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); result = runner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), lfParameters, reportNode); @@ -169,8 +170,8 @@ void generatorVoltageControlDiscarded() throws IOException { network.getGenerator("g2").setTargetV(10); // not plausible targetV, will be discarded and reported ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); var lfParameters = new LoadFlowParameters(); lfParameters.setTransformerVoltageControlOn(true); @@ -196,8 +197,8 @@ void transformerVoltageControlDiscarded() throws IOException { .setRegulationMode(RatioTapChanger.RegulationMode.VOLTAGE) .setTargetV(100); // not plausible, will be discarded and reported ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); var lfParameters = new LoadFlowParameters(); lfParameters.setTransformerVoltageControlOn(true); @@ -215,8 +216,8 @@ void shuntVoltageControlDiscarded() throws IOException { Network network = ShuntNetworkFactory.createWithTwoShuntCompensators(); network.getShuntCompensator("SHUNT2").setVoltageRegulatorOn(true).setTargetV(600); // not plausible targetV, will be discarded and reported ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); var lfParameters = new LoadFlowParameters() .setShuntCompensatorVoltageControlOn(true); @@ -234,8 +235,8 @@ void testTransformerControlAlreadyExistsWithDifferentTargetV() throws IOExceptio Network network = VoltageControlNetworkFactory.createWithTransformerSharedRemoteControl(); network.getTwoWindingsTransformer("T2wT2").getRatioTapChanger().setTargetV(34.5).setTargetDeadband(3.0); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); var lfParameters = new LoadFlowParameters(); lfParameters.setTransformerVoltageControlOn(true); @@ -254,8 +255,8 @@ void testTransformerControlAlreadyExistsWithDifferentTargetV() throws IOExceptio void areaInterchangeControl() throws IOException { Network network = MultiAreaNetworkFactory.createTwoAreasWithXNode(); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); var lfParameters = new LoadFlowParameters(); OpenLoadFlowParameters.create(lfParameters) @@ -273,8 +274,8 @@ void areaInterchangeControl() throws IOException { void busesOutOfRealisticVoltageRangeTest() throws IOException { Network network = EurostagTutorialExample1Factory.create(); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); var lfParameters = new LoadFlowParameters(); OpenLoadFlowParameters.create(lfParameters) diff --git a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowShuntTest.java b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowShuntTest.java index 37bc4c4fb0..d1d159d7c9 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowShuntTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowShuntTest.java @@ -8,6 +8,7 @@ package com.powsybl.openloadflow.ac; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.*; import com.powsybl.loadflow.LoadFlow; @@ -356,8 +357,8 @@ void testUnsupportedSharedVoltageControl() throws IOException { parameters.setShuntCompensatorVoltageControlOn(true); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); LoadFlowResult result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); assertTrue(result.isFullyConverged()); diff --git a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowTransformerReactivePowerControlTest.java b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowTransformerReactivePowerControlTest.java index 9a6c849b84..b116a2c69e 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowTransformerReactivePowerControlTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowTransformerReactivePowerControlTest.java @@ -11,6 +11,7 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.RemoteReactivePowerControlAdder; @@ -132,8 +133,8 @@ void testGeneratorRemoteReactivePowerControlOutsideReactiveLimits() throws IOExc .setTransformerReactivePowerControl(true); ReportNode report = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("test", "test") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("test") .build(); result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, report); @@ -207,8 +208,8 @@ void testGeneratorRemoteReactivePowerControlBelowReactiveLimits() throws IOExcep parametersExt.setGeneratorReactivePowerRemoteControl(true); ReportNode report = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("test", "test") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("test") .build(); LoadFlowResult result = loadFlowRunner.run(myNetwork, myNetwork.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), diff --git a/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnGenerationTest.java b/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnGenerationTest.java index a0926767bc..cdc4f7da7a 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnGenerationTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnGenerationTest.java @@ -74,7 +74,7 @@ void setUp() { parametersExt = OpenLoadFlowParameters.create(parameters) .setSlackBusSelectionMode(SlackBusSelectionMode.MOST_MESHED) .setSlackDistributionFailureBehavior(OpenLoadFlowParameters.SlackDistributionFailureBehavior.THROW); - reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + reportNode = ReportNode.newRootReportNode().withMessageTemplate("test").build(); } @Test diff --git a/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnLoadTest.java b/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnLoadTest.java index 41b2f80eee..fbd6ecb699 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnLoadTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnLoadTest.java @@ -189,7 +189,7 @@ void testNetworkWithoutConformingLoad() { .setBalanceType(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD); parametersExt .setSlackDistributionFailureBehavior(OpenLoadFlowParameters.SlackDistributionFailureBehavior.LEAVE_ON_SLACK_BUS); - ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("test").build(); LoadFlowResult result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); LoadFlowResult.ComponentResult componentResult = result.getComponentResults().get(0); assertTrue(result.isFullyConverged()); @@ -199,7 +199,7 @@ void testNetworkWithoutConformingLoad() { parametersExt .setSlackDistributionFailureBehavior(OpenLoadFlowParameters.SlackDistributionFailureBehavior.FAIL); - reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + reportNode = ReportNode.newRootReportNode().withMessageTemplate("test").build(); result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); componentResult = result.getComponentResults().get(0); assertFalse(result.isFullyConverged()); @@ -215,7 +215,7 @@ void testNetworkWithoutConformingLoad() { .setSlackDistributionFailureBehavior(OpenLoadFlowParameters.SlackDistributionFailureBehavior.DISTRIBUTE_ON_REFERENCE_GENERATOR) .setReferenceBusSelectionMode(ReferenceBusSelectionMode.GENERATOR_REFERENCE_PRIORITY); ReferencePriority.set(network.getGenerator("g1"), 1); - reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + reportNode = ReportNode.newRootReportNode().withMessageTemplate("test").build(); result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); componentResult = result.getComponentResults().get(0); assertTrue(result.isFullyConverged()); diff --git a/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlPQSwitchTest.java b/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlPQSwitchTest.java index f9c25a8751..75c1002bce 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlPQSwitchTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlPQSwitchTest.java @@ -10,6 +10,7 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.Bus; import com.powsybl.iidm.network.Generator; @@ -168,8 +169,8 @@ void setUp() { LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); loggerContext.getLogger(ReactiveLimitsOuterLoop.class).setLevel(Level.TRACE); reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("test", "test").build(); + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("test").build(); } @AfterEach diff --git a/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlTest.java b/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlTest.java index a8665a37c5..c2a035b951 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/GeneratorRemoteControlTest.java @@ -8,6 +8,7 @@ package com.powsybl.openloadflow.ac; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.CoordinatedReactiveControlAdder; @@ -505,8 +506,8 @@ void testSharedGeneratorRemoteReactivePowerControl() throws IOException { parametersExt.setGeneratorReactivePowerRemoteControl(true); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); LoadFlowResult result2 = loadFlowRunner.run(network, VariantManagerConstants.INITIAL_VARIANT_ID, LocalComputationManager.getDefault(), parameters, reportNode); assertTrue(result2.isFullyConverged()); diff --git a/src/test/java/com/powsybl/openloadflow/ac/GeneratorTargetVoltageInconsistencyTest.java b/src/test/java/com/powsybl/openloadflow/ac/GeneratorTargetVoltageInconsistencyTest.java index bf4a24c946..49db2a8729 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/GeneratorTargetVoltageInconsistencyTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/GeneratorTargetVoltageInconsistencyTest.java @@ -8,6 +8,7 @@ package com.powsybl.openloadflow.ac; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.iidm.network.*; import com.powsybl.openloadflow.network.*; import com.powsybl.openloadflow.network.impl.Networks; @@ -99,7 +100,8 @@ void localTest() throws IOException { LfNetworkParameters lfNetworkParameters = new LfNetworkParameters() .setSlackBusSelector(new FirstSlackBusSelector()); ReportNode reportNode = ReportNode.newRootReportNode() - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); List lfNetworks = Networks.load(network, lfNetworkParameters, reportNode); assertEquals(1, lfNetworks.size()); @@ -123,7 +125,7 @@ void localTestWithDisabling() { .setDisableInconsistentVoltageControls(true); ReportNode reportNode = ReportNode.newRootReportNode() - .withMessageTemplate("testReport", "Test Report") + .withMessageTemplate("testReport") .build(); List lfNetworks = Networks.load(network, lfNetworkParameters, reportNode); @@ -324,7 +326,8 @@ void remoteAndLocalTest() throws IOException { assertEquals(412, network.getGenerator("g1").getTargetV()); assertEquals(413, g2.getTargetV()); ReportNode reportNode = ReportNode.newRootReportNode() - .withMessageTemplate("testReport", "Test Report") + .withResourceBundles(PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") .build(); List networkList = Networks.load(network, parameters, reportNode); LfNetwork mainNetwork = networkList.get(0); @@ -345,7 +348,7 @@ void remoteAndLocalTestWithDisabling() { .setDisableInconsistentVoltageControls(true); ReportNode reportNode = ReportNode.newRootReportNode() - .withMessageTemplate("testReport", "Test Report") + .withMessageTemplate("testReport") .build(); List networkList = Networks.load(network, parameters, reportNode); LfNetwork lfNetwork = networkList.get(0); diff --git a/src/test/java/com/powsybl/openloadflow/ac/SecondaryVoltageControlTest.java b/src/test/java/com/powsybl/openloadflow/ac/SecondaryVoltageControlTest.java index 08450d9168..a19723144a 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/SecondaryVoltageControlTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/SecondaryVoltageControlTest.java @@ -9,6 +9,7 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.ieeecdf.converter.IeeeCdfNetworkFactory; import com.powsybl.iidm.network.*; @@ -193,8 +194,8 @@ void testUnblockGeneratorFromLimit() throws IOException { parametersExt.setSecondaryVoltageControl(true); ReportNode node = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("test", "test") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("test") .build(); // try to put g6 and g8 at qmax to see if they are correctly unblock from qmin @@ -274,8 +275,8 @@ void testCannotUnblockGeneratorFromLimit() throws IOException { parametersExt.setReactiveLimitsMaxPqPvSwitch(0); // Will block PQ->PV move ReportNode node = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("test", "test") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("test") .build(); // try to put g6 and g8 at qmax to see if they are correctly unblock from qmin diff --git a/src/test/java/com/powsybl/openloadflow/ac/SwitchPqPvTest.java b/src/test/java/com/powsybl/openloadflow/ac/SwitchPqPvTest.java index 5e9dbf3607..f54e4c5c2e 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/SwitchPqPvTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/SwitchPqPvTest.java @@ -8,6 +8,7 @@ package com.powsybl.openloadflow.ac; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.VoltagePerReactivePowerControlAdder; @@ -207,8 +208,8 @@ void testMultipleSwitch() throws IOException { .add(); g2.setTargetV(22); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("test", "test") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("test") .build(); LoadFlowResult result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); assertTrue(result.isFullyConverged()); diff --git a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java index ffdfdca84c..d92cd835aa 100644 --- a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java +++ b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java @@ -8,6 +8,7 @@ package com.powsybl.openloadflow.dc; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.ieeecdf.converter.IeeeCdfNetworkFactory; import com.powsybl.iidm.network.*; @@ -497,8 +498,8 @@ void outerLoopMaxTotalIterationTest() throws IOException { .setMaxOuterLoopIterations(1); ReportNode reportNodeWithLimit1 = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("test", "test") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("test") .build(); var result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNodeWithLimit1); @@ -564,7 +565,7 @@ void testDcSlackDistributionFailureBehavior() { Generator referenceGenerator = network.getGenerator("B1-G"); parametersExt.setSlackDistributionFailureBehavior(OpenLoadFlowParameters.SlackDistributionFailureBehavior.LEAVE_ON_SLACK_BUS); - ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("test").build(); var result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); assertTrue(result.isFullyConverged()); assertEquals(1, result.getComponentResults().size()); @@ -574,7 +575,7 @@ void testDcSlackDistributionFailureBehavior() { assertReportContains("Failed to distribute slack bus active power mismatch, [-+]?321\\.\\d* MW remains", reportNode); parametersExt.setSlackDistributionFailureBehavior(OpenLoadFlowParameters.SlackDistributionFailureBehavior.FAIL); - reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + reportNode = ReportNode.newRootReportNode().withMessageTemplate("test").build(); result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); assertFalse(result.isFullyConverged()); assertEquals(1, result.getComponentResults().size()); @@ -590,7 +591,7 @@ void testDcSlackDistributionFailureBehavior() { parametersExt.setSlackDistributionFailureBehavior(OpenLoadFlowParameters.SlackDistributionFailureBehavior.DISTRIBUTE_ON_REFERENCE_GENERATOR); parametersExt.setReferenceBusSelectionMode(ReferenceBusSelectionMode.GENERATOR_REFERENCE_PRIORITY); - reportNode = ReportNode.newRootReportNode().withMessageTemplate("test", "test").build(); + reportNode = ReportNode.newRootReportNode().withMessageTemplate("test").build(); result = loadFlowRunner.run(network, network.getVariantManager().getWorkingVariantId(), LocalComputationManager.getDefault(), parameters, reportNode); assertEquals(0, result.getComponentResults().get(0).getSlackBusResults().get(0).getActivePowerMismatch(), 0.01); assertEquals(321.9, result.getComponentResults().get(0).getDistributedActivePower(), 0.01); diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java index 6f4c128964..c2d989f9af 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java @@ -13,6 +13,7 @@ import com.powsybl.action.TerminalsConnectionAction; import com.powsybl.commons.PowsyblException; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.commons.test.TestUtil; import com.powsybl.contingency.*; import com.powsybl.ieeecdf.converter.IeeeCdfNetworkFactory; @@ -1780,8 +1781,8 @@ void reportTest() throws IOException { List contingencies = createAllBranchesContingencies(network); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("TestSecurityAnalysis", "Test security analysis report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("TestSecurityAnalysis") .build(); LoadFlowParameters loadFlowParameters = new LoadFlowParameters(); @@ -3541,14 +3542,14 @@ void testMultiThreads() throws IOException { .toList(); ReportNode reportNodeOneThread = ReportNode.newRootReportNode() - .withMessageTemplate("MT_SA_TEST", "MT SA Report Node") + .withMessageTemplate("MT_SA_TEST") .build(); SecurityAnalysisResult resultOneThread = runSecurityAnalysis(network, contingencies, Collections.emptyList(), securityAnalysisParameters, reportNodeOneThread); securityAnalysisParametersExt.setThreadCount(2); ReportNode reportNodeTwoThreads = ReportNode.newRootReportNode() - .withMessageTemplate("MT_SA_TEST", "MT SA Report Node") + .withMessageTemplate("MT_SA_TEST") .build(); SecurityAnalysisResult resultTwoThreads = runSecurityAnalysis(network, contingencies, Collections.emptyList(), securityAnalysisParameters, reportNodeOneThread); @@ -3728,8 +3729,8 @@ void multiComponentSaTest(int threadCount) throws IOException { ); ReportNode testReport = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("TEST", "TEST Report Node") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("TEST") .build(); SecurityAnalysisResult results = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters, testReport); @@ -3833,8 +3834,8 @@ void multiComponentSaTestContingencyBothComponentsAndOperatorStrategy(int thread .toList(); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("TEST", "Test Report Node") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("TEST") .build(); SecurityAnalysisResult results = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters, operatorStrategies, actions, reportNode); diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java index 0c0a7c670a..c703786216 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java @@ -9,6 +9,7 @@ import com.powsybl.action.*; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.contingency.*; import com.powsybl.iidm.network.*; @@ -94,8 +95,8 @@ void testSecurityAnalysisReport() throws IOException { saParameters.setLoadFlowParameters(lfParameters); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testSaReport", "Test report of security analysis") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testSaReport") .build(); runSecurityAnalysis(network, contingencies, Collections.emptyList(), saParameters, Collections.emptyList(), Collections.emptyList(), reportNode); @@ -140,8 +141,8 @@ void testSecurityAnalysisWithOperatorStrategy() throws IOException { securityAnalysisParameters.setLoadFlowParameters(parameters); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testSaReport", "Test report of security analysis with operator strategies") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testSaReportWithOperatorStrategies") .build(); SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters, operatorStrategies, actions, reportNode); @@ -375,8 +376,8 @@ void testMetrixTutorial() throws IOException { assertEquals(639.268, getOperatorStrategyResult(result, "strategy4").getNetworkResult().getBranchResult("S_SO_2").getI1(), LoadFlowAssert.DELTA_I); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("test", "test") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("test") .build(); loadFlowRunner.run(network, parameters); assertEquals(346.296, network.getLine("S_SO_2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); @@ -1724,8 +1725,8 @@ void testOperatorStrategyNoMoreBusVoltageControlled() throws IOException { ContingencyContext.specificContingency("NHV1_NHV2_2"), new TrueCondition(), List.of("open NGEN_NHV1"))); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testSaReport", "Test report of security analysis") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testSaReport") .build(); SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, Collections.emptyList(), new SecurityAnalysisParameters(), operatorStrategies, actions, reportNode); @@ -1775,7 +1776,7 @@ void testAreaInterchangeTargetAction() { new OperatorStrategy("strategy1", ContingencyContext.specificContingency(lineContingency.getId()), new TrueCondition(), List.of(actionArea1.getId(), actionArea2.getId())), new OperatorStrategy("strategy2", ContingencyContext.specificContingency(lineContingency.getId()), new TrueCondition(), List.of(actionArea3.getId()))); ReportNode reportNode = ReportNode.newRootReportNode() - .withMessageTemplate("testSaReport", "Test report of security analysis") + .withMessageTemplate("testSaReport") .build(); double areaInterchangePMaxMismatch = 1e-3; diff --git a/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisReportTest.java b/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisReportTest.java index badaae0fb2..4d95a6abdc 100644 --- a/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisReportTest.java +++ b/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisReportTest.java @@ -8,6 +8,7 @@ package com.powsybl.openloadflow.sensi; import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.VariantManagerConstants; @@ -37,8 +38,8 @@ class AcSensitivityAnalysisReportTest extends AbstractSensitivityAnalysisTest { void testEsgTuto() throws IOException { Network network = EurostagFactory.fix(EurostagTutorialExample1Factory.create()); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testEsgTutoReport", "Test ESG tutorial report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testEsgTutoReport") .build(); runAcLf(network, reportNode); @@ -56,8 +57,8 @@ void testEsgTuto() throws IOException { void testEsgTutoDetailedNrLogsSensi() throws IOException { Network network = EurostagFactory.fix(EurostagTutorialExample1Factory.create()); ReportNode reportNode = ReportNode.newRootReportNode() - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) - .withMessageTemplate("testEsgTutoReport", "Test ESG tutorial report") + .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME, PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testEsgTutoReport") .build(); SensitivityAnalysisParameters sensiParameters = createParameters(false, "VLLOAD_0"); diff --git a/src/test/resources/i18n/reports.properties b/src/test/resources/i18n/reports.properties new file mode 100644 index 0000000000..e0f166ceea --- /dev/null +++ b/src/test/resources/i18n/reports.properties @@ -0,0 +1,9 @@ +MT_SA_TEST = MT SA Report Node +test = test +TEST = TEST Report Node +testEsgTutoReport = Test ESG tutorial report +testReport = Test Report +testSaReport = Test report of security analysis +testSaReportWithOperatorStrategies = Test report of security analysis with operator strategies +TestSecurityAnalysis = Test security analysis report +unitTest = diff --git a/src/test/resources/i18n/reports_en_US.properties b/src/test/resources/i18n/reports_en_US.properties new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/src/test/resources/i18n/reports_en_US.properties @@ -0,0 +1 @@ + diff --git a/src/test/resources/saMtReport.txt b/src/test/resources/saMtReport.txt index 40abf6eb80..b7a3e9fc9a 100644 --- a/src/test/resources/saMtReport.txt +++ b/src/test/resources/saMtReport.txt @@ -1,4 +1,4 @@ -+ Test Report Node ++ TEST Report Node + AC security analysis on network 'test' + Network CC0 SC0 + Network info From 204da59df4273f965493f46d983cc0f7d150dfa4 Mon Sep 17 00:00:00 2001 From: CARON Alice Date: Fri, 11 Apr 2025 10:51:59 +0200 Subject: [PATCH 5/7] Add explicit locale on root report node creation to keep coherence between included/added root reports Signed-off-by: CARON Alice --- .../ac/outerloop/ReactiveLimitsOuterLoop.java | 14 ++++++--- .../network/impl/LfNetworkLoaderImpl.java | 2 +- .../sa/AbstractSecurityAnalysis.java | 2 +- .../powsybl/openloadflow/util/Reports.java | 31 ++++++++++++------- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/ac/outerloop/ReactiveLimitsOuterLoop.java b/src/main/java/com/powsybl/openloadflow/ac/outerloop/ReactiveLimitsOuterLoop.java index f3b7e5f74e..07fb06c47d 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/outerloop/ReactiveLimitsOuterLoop.java +++ b/src/main/java/com/powsybl/openloadflow/ac/outerloop/ReactiveLimitsOuterLoop.java @@ -187,7 +187,7 @@ private static boolean switchPqPv(List pqToPvBuses, ContextData conte int pvPqSwitchCount = contextData.getPvPqSwitchCount(controllerBus.getId()); if (pvPqSwitchCount >= maxPqPvSwitch) { - pqPvNodes.add(Reports.reportPvPqSwitchLimit(controllerBus, pvPqSwitchCount, log, LOGGER)); + pqPvNodes.add(Reports.reportPvPqSwitchLimit(reportNode, controllerBus, pvPqSwitchCount, log, LOGGER)); } else { controllerBus.setGeneratorVoltageControlEnabled(true); controllerBus.setGenerationTargetQ(0); @@ -195,13 +195,17 @@ private static boolean switchPqPv(List pqToPvBuses, ContextData conte pqPvSwitchCount++; if (pqToPvBus.limitType.isMaxLimit()) { - pqPvNodes.add(Reports.reportPqToPvBusMaxLimit(controllerBus, + pqPvNodes.add(Reports.reportPqToPvBusMaxLimit( + reportNode, + controllerBus, controllerBus.getGeneratorVoltageControl().map(VoltageControl::getControlledBus).orElseThrow(), getBusTargetV(controllerBus), log, LOGGER)); } else { - pqPvNodes.add(Reports.reportPqToPvBusMinLimit(controllerBus, + pqPvNodes.add(Reports.reportPqToPvBusMinLimit( + reportNode, + controllerBus, controllerBus.getGeneratorVoltageControl().map(VoltageControl::getControlledBus).orElseThrow(), getBusTargetV(controllerBus), log, @@ -341,10 +345,10 @@ private boolean switchReactiveControllerBusPq(List reactiv switch (bus.limitType) { case MAX_Q: - switchedNodes.add(Reports.reportReactiveControllerBusesToPqMaxQ(controllerBus, bus.q, bus.qLimit, log, LOGGER)); + switchedNodes.add(Reports.reportReactiveControllerBusesToPqMaxQ(reportNode, controllerBus, bus.q, bus.qLimit, log, LOGGER)); break; case MIN_Q: - switchedNodes.add(Reports.reportReactiveControllerBusesToPqMinQ(controllerBus, bus.q, bus.qLimit, log, LOGGER)); + switchedNodes.add(Reports.reportReactiveControllerBusesToPqMinQ(reportNode, controllerBus, bus.q, bus.qLimit, log, LOGGER)); break; case MIN_REALISTIC_V, MAX_REALISTIC_V: // Note: never happens for now. Robust mode applies only to remote voltage control generators diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java b/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java index 132eae9858..16e25a3434 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java @@ -1306,7 +1306,7 @@ public List load(Network network, LfTopoConfig topoConfig, LfNetworkP int numSc = networkKey.getRight(); List lfBuses = e.getValue(); return create(numCc, numSc, network, lfBuses, switchesByCc.get(networkKey), topoConfig, - parameters, Reports.createRootLfNetworkReportNode(numCc, numSc)); + parameters, Reports.createRootLfNetworkReportNode(reportNode, numCc, numSc)); }) .collect(Collectors.toList()); diff --git a/src/main/java/com/powsybl/openloadflow/sa/AbstractSecurityAnalysis.java b/src/main/java/com/powsybl/openloadflow/sa/AbstractSecurityAnalysis.java index 30d6e1dd64..1c0a6a8a0b 100644 --- a/src/main/java/com/powsybl/openloadflow/sa/AbstractSecurityAnalysis.java +++ b/src/main/java/com/powsybl/openloadflow/sa/AbstractSecurityAnalysis.java @@ -217,7 +217,7 @@ SecurityAnalysisReport runSync(SecurityAnalysisParameters securityAnalysisParame parameters = createParameters(lfParameters, lfParametersExt, partitionTopoConfig.isBreaker(), isAreaInterchangeControl(lfParametersExt, contingencies)); - ReportNode threadRootNode = partitionNum == 0 ? saReportNode : Reports.createThreadRootReport(); + ReportNode threadRootNode = partitionNum == 0 ? saReportNode : Reports.createThreadRootReport(saReportNode); reportNodes.set(partitionNum, threadRootNode); // create networks including all necessary switches diff --git a/src/main/java/com/powsybl/openloadflow/util/Reports.java b/src/main/java/com/powsybl/openloadflow/util/Reports.java index db9e6c1ebe..e4dd7aac4a 100644 --- a/src/main/java/com/powsybl/openloadflow/util/Reports.java +++ b/src/main/java/com/powsybl/openloadflow/util/Reports.java @@ -301,8 +301,9 @@ public static ReportNode reportPqToPvBuses(ReportNode reportNode, int pqToPvBusC .add(); } - public static ReportNode reportPvPqSwitchLimit(LfBus controllerBus, int limit, boolean log, Logger logger) { + public static ReportNode reportPvPqSwitchLimit(ReportNode firstRootReportNode, LfBus controllerBus, int limit, boolean log, Logger logger) { ReportNode result = ReportNode.newRootReportNode() + .withLocale(firstRootReportNode.getTreeContext().getLocale()) .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("olf.pvPqSwitchLimit") .withUntypedValue("busId", controllerBus.getId()) @@ -315,8 +316,9 @@ public static ReportNode reportPvPqSwitchLimit(LfBus controllerBus, int limit, b return result; } - public static ReportNode reportPqToPvBusMaxLimit(LfBus controllerBus, LfBus controlledBus, double targetV, boolean log, Logger logger) { + public static ReportNode reportPqToPvBusMaxLimit(ReportNode firstRootReportNode, LfBus controllerBus, LfBus controlledBus, double targetV, boolean log, Logger logger) { ReportNode result = ReportNode.newRootReportNode() + .withLocale(firstRootReportNode.getTreeContext().getLocale()) .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("olf.pqToPvBusMaxLimit") .withUntypedValue("busId", controllerBus.getId()) @@ -332,8 +334,9 @@ public static ReportNode reportPqToPvBusMaxLimit(LfBus controllerBus, LfBus cont return result; } - public static ReportNode reportPqToPvBusMinLimit(LfBus controllerBus, LfBus controlledBus, double targetV, boolean log, Logger logger) { + public static ReportNode reportPqToPvBusMinLimit(ReportNode firstRootReportNode, LfBus controllerBus, LfBus controlledBus, double targetV, boolean log, Logger logger) { ReportNode result = ReportNode.newRootReportNode() + .withLocale(firstRootReportNode.getTreeContext().getLocale()) .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("olf.pqToPvBusMinLimit") .withUntypedValue("busId", controllerBus.getId()) @@ -373,12 +376,14 @@ public static ReportNode reportReactiveControllerBusesToPqBuses(ReportNode repor .add(); } - public static ReportNode reportReactiveControllerBusesToPqMaxQ(LfBus controllerBus, + public static ReportNode reportReactiveControllerBusesToPqMaxQ(ReportNode firstRootReportNode, + LfBus controllerBus, double busQ, double maxQ, boolean log, Logger logger) { ReportNode result = ReportNode.newRootReportNode() + .withLocale(firstRootReportNode.getTreeContext().getLocale()) .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("olf.reactiveControllerBusesToPqMaxQ") .withUntypedValue("busId", controllerBus.getId()) @@ -392,12 +397,14 @@ public static ReportNode reportReactiveControllerBusesToPqMaxQ(LfBus controllerB return result; } - public static ReportNode reportReactiveControllerBusesToPqMinQ(LfBus controllerBus, - double busQ, - double minQ, - boolean log, - Logger logger) { + public static ReportNode reportReactiveControllerBusesToPqMinQ(ReportNode firstRootReportNode, + LfBus controllerBus, + double busQ, + double minQ, + boolean log, + Logger logger) { ReportNode result = ReportNode.newRootReportNode() + .withLocale(firstRootReportNode.getTreeContext().getLocale()) .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("olf.reactiveControllerBusesToPqMinQ") .withUntypedValue("busId", controllerBus.getId()) @@ -618,8 +625,9 @@ public static ReportNode createLoadFlowReporter(ReportNode reportNode, String ne .add(); } - public static ReportNode createRootLfNetworkReportNode(int networkNumCc, int networkNumSc) { + public static ReportNode createRootLfNetworkReportNode(ReportNode firstRootReportNode, int networkNumCc, int networkNumSc) { return ReportNode.newRootReportNode() + .withLocale(firstRootReportNode.getTreeContext().getLocale()) .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate(LF_NETWORK_KEY) .withUntypedValue(NETWORK_NUM_CC, networkNumCc) @@ -879,8 +887,9 @@ public static void reportActionApplicationFailure(String actionId, String contin .add(); } - public static ReportNode createThreadRootReport() { + public static ReportNode createThreadRootReport(ReportNode firstRootReport) { return ReportNode.newRootReportNode() + .withLocale(firstRootReport.getTreeContext().getLocale()) .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) .withMessageTemplate("olf.threadRoot") .build(); From 39a19c268df4c59f5ba967e08a0b40548a993f13 Mon Sep 17 00:00:00 2001 From: CARON Alice Date: Fri, 11 Apr 2025 15:04:43 +0200 Subject: [PATCH 6/7] Extend resource bundle loaded in root report node to all the ones in the classpath Signed-off-by: CARON Alice --- src/main/java/com/powsybl/openloadflow/util/Reports.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/util/Reports.java b/src/main/java/com/powsybl/openloadflow/util/Reports.java index e4dd7aac4a..36fa3aad20 100644 --- a/src/main/java/com/powsybl/openloadflow/util/Reports.java +++ b/src/main/java/com/powsybl/openloadflow/util/Reports.java @@ -628,7 +628,7 @@ public static ReportNode createLoadFlowReporter(ReportNode reportNode, String ne public static ReportNode createRootLfNetworkReportNode(ReportNode firstRootReportNode, int networkNumCc, int networkNumSc) { return ReportNode.newRootReportNode() .withLocale(firstRootReportNode.getTreeContext().getLocale()) - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withAllResourceBundlesFromClasspath() .withMessageTemplate(LF_NETWORK_KEY) .withUntypedValue(NETWORK_NUM_CC, networkNumCc) .withUntypedValue(NETWORK_NUM_SC, networkNumSc) @@ -890,7 +890,7 @@ public static void reportActionApplicationFailure(String actionId, String contin public static ReportNode createThreadRootReport(ReportNode firstRootReport) { return ReportNode.newRootReportNode() .withLocale(firstRootReport.getTreeContext().getLocale()) - .withResourceBundles(PowsyblOpenLoadFlowReportResourceBundle.BASE_NAME) + .withAllResourceBundlesFromClasspath() .withMessageTemplate("olf.threadRoot") .build(); } From 2a65ce5f830b716e6eece658495defa570ad64be Mon Sep 17 00:00:00 2001 From: CARON Alice Date: Fri, 11 Apr 2025 15:12:51 +0200 Subject: [PATCH 7/7] Remove unused ResourceBundle reports files, keep reports_en.properties to fallback on en locale for tests Signed-off-by: CARON Alice --- .../openloadflow/reports_fr.properties | 1 - .../openloadflow/reports_fr_FR.properties | 1 - .../openloadflow/util/ReportsTest.java | 40 +++++++++++++++++++ .../resources/i18n/reports_en.properties} | 0 .../resources/i18n/reports_en_US.properties | 1 - src/test/resources/i18n/reports_fr.properties | 1 + 6 files changed, 41 insertions(+), 3 deletions(-) delete mode 100644 src/main/resources/com/powsybl/openloadflow/reports_fr.properties delete mode 100644 src/main/resources/com/powsybl/openloadflow/reports_fr_FR.properties create mode 100644 src/test/java/com/powsybl/openloadflow/util/ReportsTest.java rename src/{main/resources/com/powsybl/openloadflow/reports_en_US.properties => test/resources/i18n/reports_en.properties} (100%) delete mode 100644 src/test/resources/i18n/reports_en_US.properties create mode 100644 src/test/resources/i18n/reports_fr.properties diff --git a/src/main/resources/com/powsybl/openloadflow/reports_fr.properties b/src/main/resources/com/powsybl/openloadflow/reports_fr.properties deleted file mode 100644 index 8b13789179..0000000000 --- a/src/main/resources/com/powsybl/openloadflow/reports_fr.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/com/powsybl/openloadflow/reports_fr_FR.properties b/src/main/resources/com/powsybl/openloadflow/reports_fr_FR.properties deleted file mode 100644 index 8b13789179..0000000000 --- a/src/main/resources/com/powsybl/openloadflow/reports_fr_FR.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/test/java/com/powsybl/openloadflow/util/ReportsTest.java b/src/test/java/com/powsybl/openloadflow/util/ReportsTest.java new file mode 100644 index 0000000000..8670d6cae9 --- /dev/null +++ b/src/test/java/com/powsybl/openloadflow/util/ReportsTest.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2024, 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 com.powsybl.openloadflow.util; + +import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.test.PowsyblCoreTestReportResourceBundle; +import org.junit.jupiter.api.Test; +import java.util.Locale; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * @author Alice Caron {@literal } + */ +class ReportsTest { + + @Test + void useReportWithFranceLocaleTest() { + ReportNode reportNode = ReportNode.newRootReportNode() + .withLocale(Locale.FRANCE) + .withResourceBundles(PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") + .build(); + assertEquals("Rapport de test en français", reportNode.getMessage()); + } + + @Test + void useReportWithJVMLocaleTest() { + ReportNode reportNode = ReportNode.newRootReportNode() + .withLocale(Locale.ENGLISH) + .withResourceBundles(PowsyblCoreTestReportResourceBundle.TEST_BASE_NAME) + .withMessageTemplate("testReport") + .build(); + assertEquals("Test Report", reportNode.getMessage()); + } +} diff --git a/src/main/resources/com/powsybl/openloadflow/reports_en_US.properties b/src/test/resources/i18n/reports_en.properties similarity index 100% rename from src/main/resources/com/powsybl/openloadflow/reports_en_US.properties rename to src/test/resources/i18n/reports_en.properties diff --git a/src/test/resources/i18n/reports_en_US.properties b/src/test/resources/i18n/reports_en_US.properties deleted file mode 100644 index 8b13789179..0000000000 --- a/src/test/resources/i18n/reports_en_US.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/test/resources/i18n/reports_fr.properties b/src/test/resources/i18n/reports_fr.properties new file mode 100644 index 0000000000..fc14283a7f --- /dev/null +++ b/src/test/resources/i18n/reports_fr.properties @@ -0,0 +1 @@ +testReport = Rapport de test en fran�ais