diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/AbstractParametrizedDynamicModelXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/AbstractParametrizedDynamicModelXmlTest.java index 4c4016698..01ed9f05e 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/AbstractParametrizedDynamicModelXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/AbstractParametrizedDynamicModelXmlTest.java @@ -7,7 +7,9 @@ */ package com.powsybl.dynawaltz.xml; +import com.powsybl.commons.report.ReportNode; import com.powsybl.commons.test.AbstractSerDeTest; +import com.powsybl.commons.test.TestUtil; import com.powsybl.dynamicsimulation.Curve; import com.powsybl.dynamicsimulation.DynamicSimulationParameters; import com.powsybl.dynawaltz.DynaWaltzContext; @@ -24,6 +26,7 @@ import javax.xml.validation.Validator; import java.io.IOException; import java.io.InputStream; +import java.io.StringWriter; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -31,17 +34,19 @@ import java.util.Objects; import static com.powsybl.commons.test.ComparisonUtils.assertTxtEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Laurent Issertial {@literal } */ -abstract class AbstractParametrizedDynamicModelXmlTest extends AbstractSerDeTest { +public abstract class AbstractParametrizedDynamicModelXmlTest extends AbstractSerDeTest { protected Network network; protected List dynamicModels = new ArrayList<>(); protected List eventModels = new ArrayList<>(); protected List curves = new ArrayList<>(); protected DynaWaltzContext context; + protected ReportNode reportNode = ReportNode.newRootReportNode().withMessageTemplate("testDyd", "Test DYD").build(); public void validate(String schemaDefinition, String expectedResourceName, Path xmlFile) throws SAXException, IOException { InputStream expected = Objects.requireNonNull(getClass().getResourceAsStream("/" + expectedResourceName)); @@ -55,9 +60,15 @@ public void validate(String schemaDefinition, String expectedResourceName, Path assertTxtEquals(expected, actual); } - void setupDynawaltzContext() { + protected void setupDynawaltzContext() { DynamicSimulationParameters parameters = DynamicSimulationParameters.load(); DynaWaltzParameters dynawoParameters = DynaWaltzParameters.load(); - context = new DynaWaltzContext(network, network.getVariantManager().getWorkingVariantId(), dynamicModels, eventModels, curves, parameters, dynawoParameters); + context = new DynaWaltzContext(network, network.getVariantManager().getWorkingVariantId(), dynamicModels, eventModels, curves, parameters, dynawoParameters, reportNode); + } + + protected void checkReport(String report) throws IOException { + StringWriter sw = new StringWriter(); + reportNode.print(sw); + assertEquals(report, TestUtil.normalizeLineSeparator(sw.toString())); } }