Skip to content

Commit

Permalink
Fix copyrights & UT
Browse files Browse the repository at this point in the history
Signed-off-by: lisrte <laurent.issertial@rte-france.com>
  • Loading branch information
Lisrte authored and flo-dup committed May 5, 2023
1 parent 0cfc3cf commit 43a6a9a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) 2023, 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.dynawaltz.models.automatons.phaseshifters;

import com.powsybl.dynawaltz.models.VarConnection;
Expand All @@ -7,6 +14,9 @@
import java.util.Arrays;
import java.util.List;

/**
* @author Laurent Issertial <laurent.issertial at rte-france.com>
*/
public class PhaseShifterIAutomaton extends AbstractPhaseShifterAutomaton {

public PhaseShifterIAutomaton(String dynamicModelId, TwoWindingsTransformer transformer, String parameterSetId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) 2023, 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.dynawaltz.models.automatons.phaseshifters;

import com.powsybl.dynawaltz.models.VarConnection;
Expand All @@ -7,6 +14,9 @@
import java.util.Arrays;
import java.util.List;

/**
* @author Laurent Issertial <laurent.issertial at rte-france.com>
*/
public class PhaseShifterPAutomaton extends AbstractPhaseShifterAutomaton {

public PhaseShifterPAutomaton(String dynamicModelId, TwoWindingsTransformer transformer, String parameterSetId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
*/
package com.powsybl.dynawaltz.xml;

import com.powsybl.dynawaltz.models.automatons.phaseshifters.AbstractPhaseShifterAutomaton;
import com.powsybl.dynawaltz.models.BlackBoxModel;
import com.powsybl.dynawaltz.models.automatons.phaseshifters.PhaseShifterIAutomaton;
import com.powsybl.dynawaltz.models.automatons.phaseshifters.PhaseShifterPAutomaton;
import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatio;
import com.powsybl.iidm.network.TwoWindingsTransformer;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -22,6 +22,7 @@

import javax.xml.stream.XMLStreamException;
import java.io.IOException;
import java.util.function.Function;
import java.util.stream.Stream;

/**
Expand All @@ -33,13 +34,8 @@ class PhaseShiftersXmlTest extends AbstractParametrizedDynamicModelXmlTest {
private static final String PHASE_SHIFTER_NAME = "phase_shifter";
private static final String DYN_NAME = "BBM_" + PHASE_SHIFTER_NAME;

@FunctionalInterface
interface TriFunction<A, B, C, R> {
R apply(A a, B b, C c);
}

@BeforeEach
void setup(String dydName, TriFunction<String, TwoWindingsTransformer, String, AbstractPhaseShifterAutomaton> phaseShifterConstructor, boolean dynamicTransformer) {
void setup(String dydName, Function<Network, BlackBoxModel> phaseShifterConstructor, boolean dynamicTransformer) {
setupNetwork();
addDynamicModels(phaseShifterConstructor, dynamicTransformer);
setupDynawaltzContext();
Expand All @@ -49,24 +45,24 @@ protected void setupNetwork() {
network = EurostagTutorialExample1Factory.create();
}

protected void addDynamicModels(TriFunction<String, TwoWindingsTransformer, String, AbstractPhaseShifterAutomaton> phaseShifterConstructor, boolean dynamicTransformer) {
dynamicModels.add(phaseShifterConstructor.apply(DYN_NAME, network.getTwoWindingsTransformer("NGEN_NHV1"), "ps"));
protected void addDynamicModels(Function<Network, BlackBoxModel> phaseShifterConstructor, boolean dynamicTransformer) {
dynamicModels.add(phaseShifterConstructor.apply(network));
if (dynamicTransformer) {
dynamicModels.add(new TransformerFixedRatio("BBM_NGEN_NHV1", "NGEN_NHV1", "tt", "TransformerFixedRatio"));
}
}

@ParameterizedTest(name = "{0}")
@MethodSource("providePhaseShifter")
void writeLoadModel(String dydName, TriFunction<String, TwoWindingsTransformer, String, AbstractPhaseShifterAutomaton> phaseShifterConstructor, boolean dynamicTransformer) throws SAXException, IOException, XMLStreamException {
void writeLoadModel(String dydName, Function<Network, BlackBoxModel> phaseShifterConstructor, boolean dynamicTransformer) throws SAXException, IOException, XMLStreamException {
DydXml.write(tmpDir, context);
validate("dyd.xsd", dydName + ".xml", tmpDir.resolve(DynaWaltzConstants.DYD_FILENAME));
}

private static Stream<Arguments> providePhaseShifter() {
return Stream.of(
Arguments.of("phase_shifter_i_dyd", (TriFunction<String, TwoWindingsTransformer, String, AbstractPhaseShifterAutomaton>) PhaseShifterIAutomaton::new, true),
Arguments.of("phase_shifter_p_dyd", (TriFunction<String, TwoWindingsTransformer, String, AbstractPhaseShifterAutomaton>) PhaseShifterPAutomaton::new, false)
Arguments.of("phase_shifter_i_dyd", (Function<Network, BlackBoxModel>) n -> new PhaseShifterIAutomaton(DYN_NAME, n.getTwoWindingsTransformer("NGEN_NHV1"), "ps"), true),
Arguments.of("phase_shifter_p_dyd", (Function<Network, BlackBoxModel>) n -> new PhaseShifterPAutomaton(DYN_NAME, n.getTwoWindingsTransformer("NGEN_NHV1"), "ps"), false)
);
}
}

0 comments on commit 43a6a9a

Please sign in to comment.