diff --git a/balances-adjustment/pom.xml b/balances-adjustment/pom.xml index 90b4b96d..956b57fc 100644 --- a/balances-adjustment/pom.xml +++ b/balances-adjustment/pom.xml @@ -36,6 +36,10 @@ com.powsybl powsybl-commons + + com.powsybl + powsybl-entsoe-commons + com.powsybl powsybl-iidm-extensions diff --git a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImpl.java b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImpl.java index 0d65d0b7..e8eb7a2c 100644 --- a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImpl.java +++ b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImpl.java @@ -90,11 +90,11 @@ public CompletableFuture run(Network network, String w context.setIterationReportNode(iterationReportNode); // Step 1: Perform the scaling - ReportNode scalingReportNode = iterationReportNode.newReportNode().withMessageTemplate("scaling", "Scaling").add(); + ReportNode scalingReportNode = Reports.createScalingReporter(iterationReportNode); context.getBalanceOffsets().forEach((area, offset) -> { Scalable scalable = area.getScalable(); double done = scalable.scale(network, offset, parameters.getScalingParameters()); - Reports.reportScaling(scalingReportNode, area.getName(), offset, done); + Reports.reportAreaScaling(scalingReportNode, area.getName(), offset, done); LOGGER.info("Iteration={}, Scaling for area {}: offset={}, done={}", context.getIterationNum(), area.getName(), offset, done); }); @@ -108,15 +108,12 @@ public CompletableFuture run(Network network, String w } } else { // Report that LoadFlow was skipped - iterationReportNode.newReportNode() - .withMessageTemplate("skipLoadFlow", "Load flow computation skipped") - .withSeverity(TypedValue.INFO_SEVERITY) - .add(); + Reports.createSkipLoadFlowReport(iterationReportNode); LOGGER.info("Iteration={}, LoadFlow computation skipped as per configuration", context.getIterationNum()); } // Step 3: Compute balance and mismatch for each area - ReportNode mismatchReportNode = iterationReportNode.newReportNode().withMessageTemplate("mismatch", "Mismatch").add(); + ReportNode mismatchReportNode = Reports.createMismatchReporter(iterationReportNode); for (BalanceComputationArea area : areas) { NetworkArea na = context.getNetworkArea(area); double target = area.getTargetNetPosition(); @@ -139,7 +136,7 @@ public CompletableFuture run(Network network, String w } } while (context.getIterationNum() < parameters.getMaxNumberIterations() && result.getStatus() != BalanceComputationResult.Status.SUCCESS); - ReportNode statusReportNode = reportNode.newReportNode().withMessageTemplate("status", "Status").add(); + ReportNode statusReportNode = Reports.createStatusReporter(reportNode); if (result.getStatus() == BalanceComputationResult.Status.SUCCESS) { List networkAreasName = areas.stream() .map(BalanceComputationArea::getName).collect(Collectors.toList()); @@ -193,7 +190,7 @@ protected boolean isLoadFlowResultOk(BalanceComputationRunningContext context, f return false; } final var cr = list.get(0); - ReportNode lfStatusReportNode = context.getIterationReportNode().newReportNode().withMessageTemplate("loadFlowStatus", "Checking load flow status").add(); + ReportNode lfStatusReportNode = Reports.createLoadFlowStatusReporter(context.getIterationReportNode()); final var severity = cr.getStatus() == LoadFlowResult.ComponentResult.Status.CONVERGED ? TypedValue.INFO_SEVERITY : TypedValue.ERROR_SEVERITY; Reports.reportLfStatus(lfStatusReportNode, cr.getConnectedComponentNum(), cr.getSynchronousComponentNum(), cr.getStatus().name(), severity); return cr.getStatus() == LoadFlowResult.ComponentResult.Status.CONVERGED; diff --git a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/util/Reports.java b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/util/Reports.java index aacd1a0b..653b27a9 100644 --- a/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/util/Reports.java +++ b/balances-adjustment/src/main/java/com/powsybl/balances_adjustment/util/Reports.java @@ -23,9 +23,9 @@ public final class Reports { private Reports() { } - public static void reportScaling(ReportNode reportNode, String areaName, double offset, double done) { - reportNode.newReportNode().withMessageTemplate("areaScaling", - "Scaling for area ${areaName}: offset=${offset}, done=${done}") + public static void reportAreaScaling(ReportNode reportNode, String areaName, double offset, double done) { + reportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.areaScaling") .withUntypedValue(AREA_NAME, areaName) .withUntypedValue("offset", offset) .withUntypedValue("done", done) @@ -34,8 +34,8 @@ public static void reportScaling(ReportNode reportNode, String areaName, double } public static void reportLfStatus(ReportNode reportNode, int networkNumCc, int networkNumSc, String status, TypedValue severity) { - reportNode.newReportNode().withMessageTemplate("lfStatus", - "Network CC${networkNumCc} SC${networkNumSc} Load flow complete with status '${status}'") + reportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.lfStatus") .withUntypedValue("networkNumCc", networkNumCc) .withUntypedValue("networkNumSc", networkNumSc) .withUntypedValue("status", status) @@ -44,8 +44,8 @@ public static void reportLfStatus(ReportNode reportNode, int networkNumCc, int n } public static void reportAreaMismatch(ReportNode reportNode, String areaName, double mismatch, double target, double balance) { - reportNode.newReportNode().withMessageTemplate("areaMismatch", - "Mismatch for area ${areaName}: ${mismatch} (target=${target}, balance=${balance})") + reportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.areaMismatch") .withUntypedValue(AREA_NAME, areaName) .withUntypedValue("mismatch", mismatch) .withUntypedValue("target", target) @@ -55,8 +55,8 @@ public static void reportAreaMismatch(ReportNode reportNode, String areaName, do } public static void reportBalancedAreas(ReportNode reportNode, List networkAreasName, int iterationCount) { - reportNode.newReportNode().withMessageTemplate("balancedAreas", - "Areas ${networkAreasName} are balanced after ${iterationCount} iterations") + reportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.balancedAreas") .withUntypedValue("networkAreasName", networkAreasName.toString()) .withUntypedValue("iterationCount", iterationCount) .withSeverity(TypedValue.INFO_SEVERITY) @@ -64,8 +64,8 @@ public static void reportBalancedAreas(ReportNode reportNode, List netwo } public static void reportUnbalancedAreas(ReportNode reportNode, int iteration, BigDecimal totalMismatch) { - reportNode.newReportNode().withMessageTemplate("unbalancedAreas", - "Areas are unbalanced after ${iteration} iterations, total mismatch is ${totalMismatch}") + reportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.unbalancedAreas") .withUntypedValue(ITERATION, iteration) .withUntypedValue("totalMismatch", totalMismatch.toString()) .withSeverity(TypedValue.ERROR_SEVERITY) @@ -73,8 +73,40 @@ public static void reportUnbalancedAreas(ReportNode reportNode, int iteration, B } public static ReportNode createBalanceComputationIterationReporter(ReportNode reportNode, int iteration) { - return reportNode.newReportNode().withMessageTemplate("balanceComputation", "Balance Computation iteration '${iteration}'") + return reportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.balanceComputation") .withUntypedValue(ITERATION, iteration) .add(); } + + public static ReportNode createStatusReporter(ReportNode reportNode) { + return reportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.status") + .add(); + } + + public static ReportNode createMismatchReporter(ReportNode iterationReportNode) { + return iterationReportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.mismatch") + .add(); + } + + public static ReportNode createScalingReporter(ReportNode iterationReportNode) { + return iterationReportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.scaling") + .add(); + } + + public static ReportNode createLoadFlowStatusReporter(ReportNode reportNode) { + return reportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.loadFlowStatus") + .add(); + } + + public static void createSkipLoadFlowReport(ReportNode reportNode) { + reportNode.newReportNode() + .withMessageTemplate("entsoe.balances_adjustment.skipLoadflow") + .withSeverity(TypedValue.INFO_SEVERITY) + .add(); + } } diff --git a/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationSimpleDcTest.java b/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationSimpleDcTest.java index d7208768..e6af6818 100644 --- a/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationSimpleDcTest.java +++ b/balances-adjustment/src/test/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationSimpleDcTest.java @@ -11,6 +11,7 @@ import com.powsybl.commons.report.ReportNode; import com.powsybl.computation.ComputationManager; import com.powsybl.computation.local.LocalComputationManager; +import com.powsybl.entsoe.commons.PowsyblEntsoeReportResourceBundle; import com.powsybl.iidm.modification.scalable.Scalable; import com.powsybl.iidm.network.*; import com.powsybl.loadflow.*; @@ -48,6 +49,7 @@ class BalanceComputationSimpleDcTest { private Branch branchFrBe2; private String initialState = "InitialState"; private String initialVariantNew = "InitialVariantNew"; + private static final String TEST_BASE_NAME = "i18n.reports"; @BeforeEach void setUp() { @@ -238,7 +240,7 @@ void testSkipLoadFlowWithReportNode() throws IOException { BalanceComputation balanceComputation = balanceComputationFactory.create(areas, loadFlowRunner, computationManager); - ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("testSkipLoadFlow", "Test skip load flow").build(); + ReportNode reportNode = ReportNode.newRootReportNode().withResourceBundles(TEST_BASE_NAME, PowsyblEntsoeReportResourceBundle.BASE_NAME).withMessageTemplate("testSkipLoadFlow").build(); BalanceComputationResult result = balanceComputation.run(simpleNetwork, simpleNetwork.getVariantManager().getWorkingVariantId(), parameters, reportNode).join(); // Check that the report contains information about skipping load flow @@ -338,7 +340,10 @@ void testBalancedNetworkAfter1ScalingReport() throws IOException { BalanceComputation balanceComputation = balanceComputationFactory.create(areas, loadFlowRunner, computationManager); - ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("testBalancedNetworkReport", "Test balanced network report").build(); + ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(TEST_BASE_NAME, PowsyblEntsoeReportResourceBundle.BASE_NAME) + .withMessageTemplate("testBalancedNetworkReport") + .build(); balanceComputation.run(simpleNetwork, simpleNetwork.getVariantManager().getWorkingVariantId(), parameters, reportNode).join(); BalanceComputationAssert.assertReportEquals("/balancedNetworkReport.txt", reportNode); } @@ -351,7 +356,10 @@ void testUnBalancedNetworkReport() throws IOException { BalanceComputation balanceComputation = balanceComputationFactory.create(areas, loadFlowRunner, computationManager); - ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("testUnbalancedNetworkReport", "Test unbalanced network report").build(); + ReportNode reportNode = ReportNode.newRootReportNode() + .withResourceBundles(TEST_BASE_NAME, PowsyblEntsoeReportResourceBundle.BASE_NAME) + .withMessageTemplate("testUnbalancedNetworkReport") + .build(); balanceComputation.run(simpleNetwork, simpleNetwork.getVariantManager().getWorkingVariantId(), parameters, reportNode).join(); BalanceComputationAssert.assertReportEquals("/unbalancedNetworkReport.txt", reportNode); } diff --git a/balances-adjustment/src/test/resources/i18n/reports.properties b/balances-adjustment/src/test/resources/i18n/reports.properties new file mode 100644 index 00000000..528d39df --- /dev/null +++ b/balances-adjustment/src/test/resources/i18n/reports.properties @@ -0,0 +1,3 @@ +testBalancedNetworkReport = Test balanced network report +testUnbalancedNetworkReport = Test unbalanced network report +testSkipLoadFlow = Test skip load flow diff --git a/commons/src/main/java/com/powsybl/entsoe/commons/PowsyblEntsoeReportResourceBundle.java b/commons/src/main/java/com/powsybl/entsoe/commons/PowsyblEntsoeReportResourceBundle.java new file mode 100644 index 00000000..2078654e --- /dev/null +++ b/commons/src/main/java/com/powsybl/entsoe/commons/PowsyblEntsoeReportResourceBundle.java @@ -0,0 +1,26 @@ +package com.powsybl.entsoe.commons; + +/** + * 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 PowsyblEntsoeReportResourceBundle implements ReportResourceBundle { + + public static final String BASE_NAME = "com.powsybl.entsoe.commons.reports"; + + public String getBaseName() { + return BASE_NAME; + } +} diff --git a/commons/src/main/resources/com/powsybl/entsoe/commons/reports.properties b/commons/src/main/resources/com/powsybl/entsoe/commons/reports.properties new file mode 100644 index 00000000..5a8de356 --- /dev/null +++ b/commons/src/main/resources/com/powsybl/entsoe/commons/reports.properties @@ -0,0 +1,14 @@ +entsoe.balances_adjustment.areaMismatch = Mismatch for area ${areaName}: ${mismatch} (target=${target}, balance=${balance}) +entsoe.balances_adjustment.areaScaling = Scaling for area ${areaName}: offset=${offset}, done=${done} +entsoe.balances_adjustment.balanceComputation = Balance Computation iteration '${iteration}' +entsoe.balances_adjustment.balancedAreas = Areas ${networkAreasName} are balanced after ${iterationCount} iterations +entsoe.balances_adjustment.lfStatus = Network CC${networkNumCc} SC${networkNumSc} Load flow complete with status '${status}' +entsoe.balances_adjustment.loadFlowStatus = Checking load flow status +entsoe.balances_adjustment.mismatch = Mismatch +entsoe.balances_adjustment.scaling = Scaling +entsoe.balances_adjustment.skipLoadflow = Load flow computation skipped +entsoe.balances_adjustment.status = Status +entsoe.balances_adjustment.unbalancedAreas = Areas are unbalanced after ${iteration} iterations, total mismatch is ${totalMismatch} +entsoe.glsk.connectedToAnIsland = GLSK node is connected to an island +entsoe.glsk.nodeNotFound = GLSK node is not found in CGM +entsoe.glsk.noRunningGeneratorOrLoad = GLSK node is present but has no running Generator or Load diff --git a/glsk/glsk-commons/src/main/java/com/powsybl/glsk/commons/GlskReports.java b/glsk/glsk-commons/src/main/java/com/powsybl/glsk/commons/GlskReports.java new file mode 100644 index 00000000..885e5641 --- /dev/null +++ b/glsk/glsk-commons/src/main/java/com/powsybl/glsk/commons/GlskReports.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2025, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * SPDX-License-Identifier: MPL-2.0 + */ +package com.powsybl.glsk.commons; + +import com.powsybl.commons.report.ReportNode; + +import static com.powsybl.commons.report.TypedValue.WARN_SEVERITY; + +/** + * @author Olivier Perrin {@literal } + */ +public final class GlskReports { + + public static final String NODE_ID_KEY = "NodeId"; + public static final String TYPE_KEY = "Type"; + public static final String TSO_KEY = "TSO"; + + private GlskReports() { + } + + public static void reportNodeNotFound(String nodeId, String type, String tso, ReportNode reportNode) { + reportNode.newReportNode() + .withMessageTemplate("entsoe.glsk.nodeNotFound") + .withTypedValue(NODE_ID_KEY, nodeId, "") + .withTypedValue(TYPE_KEY, type, "") + .withTypedValue(TSO_KEY, tso, "") + .withSeverity(WARN_SEVERITY) + .add(); + } + + public static void reportNoRunningGeneratorOrLoad(String nodeId, String type, String tso, ReportNode reportNode) { + reportNode.newReportNode() + .withMessageTemplate("entsoe.glsk.noRunningGeneratorOrLoad") + .withTypedValue(NODE_ID_KEY, nodeId, "") + .withTypedValue(TYPE_KEY, type, "") + .withTypedValue(TSO_KEY, tso, "") + .withSeverity(WARN_SEVERITY) + .add(); + } + + public static void reportConnectedToAnIsland(String nodeId, String type, String tso, ReportNode reportNode) { + reportNode.newReportNode() + .withMessageTemplate("entsoe.glsk.connectedToAnIsland") + .withTypedValue(NODE_ID_KEY, nodeId, "") + .withTypedValue(TYPE_KEY, type, "") + .withTypedValue(TSO_KEY, tso, "") + .withSeverity(WARN_SEVERITY) + .add(); + } +} diff --git a/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityCheck.java b/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityCheck.java index eb05e271..6379f830 100644 --- a/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityCheck.java +++ b/glsk/glsk-quality-check-ucte/src/main/java/com/powsybl/glsk/ucte/quality_check/GlskQualityCheck.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.stream.Collectors; -import static com.powsybl.commons.report.TypedValue.WARN_SEVERITY; +import static com.powsybl.glsk.commons.GlskReports.*; /** * @author Marc Erkol {@literal } @@ -30,12 +30,6 @@ class GlskQualityCheck { private static final String LOAD = "A05"; - public static final String NODE_ID_KEY = "NodeId"; - - public static final String TYPE_KEY = "Type"; - - public static final String TSO_KEY = "TSO"; - public static void gskQualityCheck(GlskQualityCheckInput input, ReportNode reportNode) { new GlskQualityCheck().generateReport(input, reportNode); } @@ -110,31 +104,15 @@ private void createMissingLoad(Network network, VoltageLevel voltageLevel, Strin private void checkResource(GlskRegisteredResource registeredResource, Injection injection, String type, Network network, String tso, ReportNode reportNode) { if (injection == null) { - if (network.getBusBreakerView().getBus(registeredResource.getmRID()) == null) { - reportNode.newReportNode().withMessageTemplate("1", "GLSK node is not found in CGM") - .withTypedValue(NODE_ID_KEY, registeredResource.getmRID(), "") - .withTypedValue(TYPE_KEY, type, "") - .withTypedValue(TSO_KEY, tso, "") - .withSeverity(WARN_SEVERITY) - .add(); + reportNodeNotFound(registeredResource.getmRID(), type, tso, reportNode); } else { - reportNode.newReportNode().withMessageTemplate("2", "GLSK node is present but has no running Generator or Load") - .withTypedValue(NODE_ID_KEY, registeredResource.getmRID(), "") - .withTypedValue(TYPE_KEY, type, "") - .withTypedValue(TSO_KEY, tso, "") - .withSeverity(WARN_SEVERITY) - .add(); + reportNoRunningGeneratorOrLoad(registeredResource.getmRID(), type, tso, reportNode); } } else { if (!injection.getTerminal().isConnected() || !injection.getTerminal().getBusBreakerView().getBus().isInMainSynchronousComponent()) { - reportNode.newReportNode().withMessageTemplate("3", "GLSK node is connected to an island") - .withTypedValue(NODE_ID_KEY, registeredResource.getmRID(), "") - .withTypedValue(TYPE_KEY, type, "") - .withTypedValue(TSO_KEY, tso, "") - .withSeverity(WARN_SEVERITY) - .add(); + reportConnectedToAnIsland(registeredResource.getmRID(), type, tso, reportNode); } } } diff --git a/glsk/glsk-quality-check-ucte/src/test/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessorTest.java b/glsk/glsk-quality-check-ucte/src/test/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessorTest.java index 4dbbfa13..71f09474 100644 --- a/glsk/glsk-quality-check-ucte/src/test/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessorTest.java +++ b/glsk/glsk-quality-check-ucte/src/test/java/com/powsybl/glsk/ucte/quality_check/GlskQualityProcessorTest.java @@ -7,6 +7,7 @@ package com.powsybl.glsk.ucte.quality_check; import com.powsybl.commons.report.ReportNode; +import com.powsybl.entsoe.commons.PowsyblEntsoeReportResourceBundle; import com.powsybl.glsk.ucte.UcteGlskDocument; import com.powsybl.iidm.network.Network; import org.junit.jupiter.api.Test; @@ -14,6 +15,8 @@ import java.io.InputStream; import java.time.Instant; +import static com.powsybl.glsk.commons.GlskReports.NODE_ID_KEY; +import static com.powsybl.glsk.commons.GlskReports.TSO_KEY; import static org.junit.jupiter.api.Assertions.*; /** @@ -23,6 +26,7 @@ class GlskQualityProcessorTest { private static final String COUNTRYTEST = "/20170322_1844_SN3_FR2_GLSK_test.xml"; private static final String FIRST_ERROR = "/20170322_1844_SN3_FR2_GLSK_error_1.xml"; + private static final String TEST_BASE_NAME = "i18n.reports"; private InputStream getResourceAsInputStream(String resource) { return getClass().getResourceAsStream(resource); @@ -32,9 +36,8 @@ private InputStream getResourceAsInputStream(String resource) { void qualityCheckWithCorrectValue() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(COUNTRYTEST)); Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm")); - ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); + ReportNode reportNode = ReportNode.newRootReportNode().withResourceBundles(TEST_BASE_NAME, PowsyblEntsoeReportResourceBundle.BASE_NAME).withMessageTemplate("defaultTask").build(); GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reportNode); - assertTrue(reportNode.getChildren().isEmpty()); } @@ -42,61 +45,59 @@ void qualityCheckWithCorrectValue() { void qualityCheckWithError1() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(FIRST_ERROR)); Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm")); - ReportNode reporter = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); + ReportNode reporter = ReportNode.newRootReportNode().withResourceBundles(TEST_BASE_NAME, PowsyblEntsoeReportResourceBundle.BASE_NAME).withMessageTemplate("defaultTask").build(); GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reporter); assertEquals(1, reporter.getChildren().size()); ReportNode r = reporter.getChildren().stream().findFirst().get(); assertEquals("GLSK node is not found in CGM", r.getMessage()); - assertEquals("FFR2AA2 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).get().toString()); - assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).get().toString()); + assertEquals("FFR2AA2 ", r.getValue(NODE_ID_KEY).get().toString()); + assertEquals("10YFR-RTE------C", r.getValue(TSO_KEY).get().toString()); //Get unique TSO count in logs - assertEquals(1, reporter.getChildren().stream().filter(rep -> rep.getValue(GlskQualityCheck.TSO_KEY).get().toString().equals("10YFR-RTE------C")).count()); + assertEquals(1, reporter.getChildren().stream().filter(rep -> rep.getValue(TSO_KEY).get().toString().equals("10YFR-RTE------C")).count()); //Get log count for RTE - assertEquals(1, reporter.getChildren().stream().map(rep -> rep.getValue(GlskQualityCheck.TSO_KEY).get().toString()).distinct().count()); - + assertEquals(1, reporter.getChildren().stream().map(rep -> rep.getValue(TSO_KEY).get().toString()).distinct().count()); } @Test void qualityCheckWithError2() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(COUNTRYTEST)); Network network = Network.read("testCase_error_2.xiidm", getClass().getResourceAsStream("/testCase_error_2.xiidm")); - ReportNode reporter = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); + ReportNode reporter = ReportNode.newRootReportNode().withResourceBundles(TEST_BASE_NAME, PowsyblEntsoeReportResourceBundle.BASE_NAME).withMessageTemplate("defaultTask").build(); GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reporter); - assertEquals(1, reporter.getChildren().size()); ReportNode r = reporter.getChildren().stream().findFirst().get(); assertEquals("GLSK node is present but has no running Generator or Load", r.getMessage()); - assertEquals("FFR2AA1 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).get().toString()); - assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).get().toString()); + assertEquals("FFR2AA1 ", r.getValue(NODE_ID_KEY).get().toString()); + assertEquals("10YFR-RTE------C", r.getValue(TSO_KEY).get().toString()); } @Test void qualityCheckWithError3() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(COUNTRYTEST)); Network network = Network.read("testCase_error_3.xiidm", getClass().getResourceAsStream("/testCase_error_3.xiidm")); - ReportNode reporter = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); + ReportNode reporter = ReportNode.newRootReportNode().withResourceBundles(TEST_BASE_NAME, PowsyblEntsoeReportResourceBundle.BASE_NAME).withMessageTemplate("defaultTask").build(); GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reporter); assertEquals(1, reporter.getChildren().size()); ReportNode r = reporter.getChildren().stream().findFirst().get(); assertEquals("GLSK node is connected to an island", r.getMessage()); - assertEquals("FFR2AA1 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).get().toString()); - assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).get().toString()); + assertEquals("FFR2AA1 ", r.getValue(NODE_ID_KEY).get().toString()); + assertEquals("10YFR-RTE------C", r.getValue(TSO_KEY).get().toString()); } @Test void qualityCheckLoadNotConnected() { UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getResourceAsInputStream(COUNTRYTEST)); Network network = Network.read("testCase_error_load_not_connected.xiidm", getClass().getResourceAsStream("/testCase_error_load_not_connected.xiidm")); - ReportNode reporter = ReportNode.newRootReportNode().withMessageTemplate("defaultTask", "defaultName").build(); + ReportNode reporter = ReportNode.newRootReportNode().withResourceBundles(TEST_BASE_NAME, PowsyblEntsoeReportResourceBundle.BASE_NAME).withMessageTemplate("defaultTask").build(); GlskQualityProcessor.process(ucteGlskDocument, network, Instant.parse("2016-07-28T23:30:00Z"), reporter); assertEquals(1, reporter.getChildren().size()); ReportNode r = reporter.getChildren().stream().findFirst().get(); assertEquals("GLSK node is connected to an island", r.getMessage()); - assertEquals("FFR2AA1 ", r.getValue(GlskQualityCheck.NODE_ID_KEY).get().toString()); - assertEquals("10YFR-RTE------C", r.getValue(GlskQualityCheck.TSO_KEY).get().toString()); + assertEquals("FFR2AA1 ", r.getValue(NODE_ID_KEY).get().toString()); + assertEquals("10YFR-RTE------C", r.getValue(TSO_KEY).get().toString()); } } diff --git a/glsk/glsk-quality-check-ucte/src/test/resources/i18n/reports.properties b/glsk/glsk-quality-check-ucte/src/test/resources/i18n/reports.properties new file mode 100644 index 00000000..049f9707 --- /dev/null +++ b/glsk/glsk-quality-check-ucte/src/test/resources/i18n/reports.properties @@ -0,0 +1 @@ +defaultTask = defaultName diff --git a/glsk/pom.xml b/glsk/pom.xml index 05a32fb2..b1797757 100644 --- a/glsk/pom.xml +++ b/glsk/pom.xml @@ -24,4 +24,11 @@ glsk-document-cse glsk-quality-check-ucte + + + + com.powsybl + powsybl-entsoe-commons + + \ No newline at end of file