Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add access to AbstractParametrizedDynamicModelXmlTest #375

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()));
}
}
Loading