Skip to content

Commit

Permalink
Add access to AbstractParametrizedDynamicModelXmlTest (#375)
Browse files Browse the repository at this point in the history
Signed-off-by: lisrte <[email protected]>
  • Loading branch information
Lisrte authored Jul 17, 2024
1 parent 5328e95 commit 7df9e1b
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,24 +26,27 @@
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;
import java.util.List;
import java.util.Objects;

import static com.powsybl.commons.test.ComparisonUtils.assertTxtEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
abstract class AbstractParametrizedDynamicModelXmlTest extends AbstractSerDeTest {
public abstract class AbstractParametrizedDynamicModelXmlTest extends AbstractSerDeTest {

protected Network network;
protected List<BlackBoxModel> dynamicModels = new ArrayList<>();
protected List<BlackBoxModel> eventModels = new ArrayList<>();
protected List<Curve> 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));
Expand All @@ -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()));
}
}

0 comments on commit 7df9e1b

Please sign in to comment.