-
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 support for two windings transformer tabular modifications. (#396)
Signed-off-by: Florent MILLOT <[email protected]>
- Loading branch information
Showing
4 changed files
with
113 additions
and
6 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
98 changes: 98 additions & 0 deletions
98
...er/modifications/tabularmodifications/TabularTwoWindingsTransformerModificationsTest.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,98 @@ | ||
/** | ||
* 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/. | ||
*/ | ||
|
||
package org.gridsuite.modification.server.modifications.tabularmodifications; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.powsybl.iidm.network.Network; | ||
import lombok.SneakyThrows; | ||
import org.gridsuite.modification.server.ModificationType; | ||
import org.gridsuite.modification.server.dto.*; | ||
import org.gridsuite.modification.server.modifications.AbstractNetworkModificationTest; | ||
import org.gridsuite.modification.server.utils.NetworkCreation; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Tag; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
import static org.gridsuite.modification.server.utils.TestUtils.assertLogMessage; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author Florent MILLOT <florent.millot at rte-france.com> | ||
*/ | ||
@Tag("IntegrationTest") | ||
public class TabularTwoWindingsTransformerModificationsTest extends AbstractNetworkModificationTest { | ||
@Override | ||
protected Network createNetwork(UUID networkUuid) { | ||
return NetworkCreation.create(networkUuid, true); | ||
} | ||
|
||
@Override | ||
protected ModificationInfos buildModification() { | ||
List<ModificationInfos> modifications = List.of( | ||
buildOneModification("trf1", 0.0), | ||
buildOneModification("trf2", 1.0), | ||
buildOneModification("unknownTwt", 1.0) | ||
); | ||
return TabularModificationInfos.builder() | ||
.modificationType("TWO_WINDINGS_TRANSFORMER_MODIFICATION") | ||
.modifications(modifications) | ||
.stashed(false) | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected ModificationInfos buildModificationUpdate() { | ||
List<ModificationInfos> modifications = List.of( | ||
buildOneModification("trf1", 3.0), | ||
buildOneModification("trf2", 4.0) | ||
); | ||
return TabularModificationInfos.builder() | ||
.modificationType("TWO_WINDINGS_TRANSFORMER_MODIFICATION") | ||
.modifications(modifications) | ||
.stashed(false) | ||
.build(); | ||
} | ||
|
||
protected TwoWindingsTransformerModificationInfos buildOneModification(String equipmentId, Double seriesResistance) { | ||
return TwoWindingsTransformerModificationInfos.builder().equipmentId(equipmentId) | ||
.seriesResistance(new AttributeModification<>(seriesResistance, OperationType.SET)) | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected void assertAfterNetworkModificationCreation() { | ||
assertEquals(0.0, getNetwork().getTwoWindingsTransformer("trf1").getR(), 0.001); | ||
assertEquals(1.0, getNetwork().getTwoWindingsTransformer("trf2").getR(), 0.001); | ||
assertLogMessage("TWO_WINDINGS_TRANSFORMER_NOT_FOUND : Two windings transformer with ID 'unknownTwt' does not exist in the network", ModificationType.TWO_WINDINGS_TRANSFORMER_MODIFICATION.name() + "1", reportService); | ||
} | ||
|
||
@Override | ||
protected void assertAfterNetworkModificationDeletion() { | ||
assertEquals(2.0, getNetwork().getTwoWindingsTransformer("trf1").getR(), 0.001); | ||
assertEquals(2.0, getNetwork().getTwoWindingsTransformer("trf2").getR(), 0.001); | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
protected void testCreationModificationMessage(ModificationInfos modificationInfos) { | ||
assertEquals("TABULAR_MODIFICATION", modificationInfos.getMessageType()); | ||
Map<String, String> createdValues = mapper.readValue(modificationInfos.getMessageValues(), new TypeReference<>() { }); | ||
Assertions.assertEquals("TWO_WINDINGS_TRANSFORMER_MODIFICATION", createdValues.get("tabularModificationType")); | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
protected void testUpdateModificationMessage(ModificationInfos modificationInfos) { | ||
assertEquals("TABULAR_MODIFICATION", modificationInfos.getMessageType()); | ||
Map<String, String> updatedValues = mapper.readValue(modificationInfos.getMessageValues(), new TypeReference<>() { }); | ||
Assertions.assertEquals("TWO_WINDINGS_TRANSFORMER_MODIFICATION", updatedValues.get("tabularModificationType")); | ||
} | ||
} |