-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an equipment setter in AbstractEquipmentModelBuilder
Signed-off-by: lisrte <[email protected]>
- Loading branch information
Showing
4 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
dynawaltz/src/test/java/com/powsybl/dynawaltz/models/BuilderEquipmentSetterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2024, 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; | ||
|
||
import com.powsybl.commons.reporter.ReporterModel; | ||
import com.powsybl.commons.test.TestUtil; | ||
import com.powsybl.dynawaltz.models.lines.LineBuilder; | ||
import com.powsybl.iidm.network.Line; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.iidm.network.test.PhaseShifterTestCaseFactory; | ||
import com.powsybl.iidm.network.test.SvcTestCaseFactory; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.StringWriter; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>} | ||
*/ | ||
class BuilderEquipmentSetterTest { | ||
|
||
@Test | ||
void addEquipmentFromAnotherNetwork() { | ||
|
||
Network network = SvcTestCaseFactory.create(); | ||
Line ln1 = network.getLine("L1"); | ||
Network network2 = PhaseShifterTestCaseFactory.create(); | ||
Line ln2 = network2.getLine("L1"); | ||
ReporterModel reporter = new ReporterModel("builderTests", "Builder tests"); | ||
|
||
BlackBoxModel bbm1 = LineBuilder.of(network) | ||
.dynamicModelId("BBM_LINE_NETWORK_1") | ||
.equipment(ln1) | ||
.parameterSetId("sl") | ||
.build(); | ||
BlackBoxModel bbm2 = LineBuilder.of(network, reporter) | ||
.dynamicModelId("BBM_LINE_NETWORK_2") | ||
.equipment(ln2) | ||
.parameterSetId("sl") | ||
.build(); | ||
|
||
assertNotNull(bbm1); | ||
assertNull(bbm2); | ||
StringWriter sw = new StringWriter(); | ||
reporter.export(sw); | ||
assertEquals(""" | ||
+ Builder tests | ||
'equipment' field value LINE L1 does not belong to the builder network | ||
Model BBM_LINE_NETWORK_2 cannot be instantiated | ||
""", | ||
TestUtil.normalizeLineSeparator(sw.toString())); | ||
} | ||
} |