-
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 the possibility to trip a busbar section. (#493)
* Add the possibility to trip a busbar section. --------- Signed-off-by: BOUTIER Charly <[email protected]>
- Loading branch information
1 parent
f496b43
commit 742c211
Showing
2 changed files
with
94 additions
and
0 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
91 changes: 91 additions & 0 deletions
91
...ridsuite/modification/server/modifications/OperatingStatusModificationTripBusBarTest.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,91 @@ | ||
/** | ||
* 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/. | ||
*/ | ||
package org.gridsuite.modification.server.modifications; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.powsybl.iidm.network.*; | ||
import com.powsybl.iidm.network.extensions.OperatingStatus; | ||
import lombok.SneakyThrows; | ||
import org.gridsuite.modification.server.dto.ModificationInfos; | ||
import org.gridsuite.modification.server.dto.OperatingStatusModificationInfos; | ||
import org.gridsuite.modification.server.utils.NetworkCreation; | ||
import org.gridsuite.modification.server.utils.TestUtils; | ||
import org.junit.Assert; | ||
import org.junit.jupiter.api.Tag; | ||
|
||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
import static com.powsybl.iidm.network.extensions.OperatingStatus.Status.FORCED_OUTAGE; | ||
import static com.powsybl.iidm.network.extensions.OperatingStatus.Status.IN_OPERATION; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@Tag("IntegrationTest") | ||
public class OperatingStatusModificationTripBusBarTest extends AbstractNetworkModificationTest { | ||
|
||
private static final String TARGET_BUSBAR_ID = "1.A"; | ||
private static final OperatingStatus.Status TARGET_BUSBAR_STATUS = FORCED_OUTAGE; | ||
private static final OperatingStatus.Status INITIAL_BUSBAR_STATUS = IN_OPERATION; | ||
|
||
@Override | ||
protected Network createNetwork(UUID networkUuid) { | ||
Network network = NetworkCreation.create(networkUuid, true); | ||
// force a branch status different from the expected one, after testCreate | ||
TestUtils.setOperatingStatus(network, TARGET_BUSBAR_ID, INITIAL_BUSBAR_STATUS); | ||
return network; | ||
} | ||
|
||
@Override | ||
protected ModificationInfos buildModification() { | ||
return OperatingStatusModificationInfos.builder() | ||
.stashed(false) | ||
.equipmentId(TARGET_BUSBAR_ID) | ||
.action(OperatingStatusModificationInfos.ActionType.TRIP).build(); | ||
} | ||
|
||
@Override | ||
protected ModificationInfos buildModificationUpdate() { | ||
return OperatingStatusModificationInfos.builder() | ||
.stashed(false) | ||
.equipmentId(TARGET_BUSBAR_ID) | ||
.action(OperatingStatusModificationInfos.ActionType.SWITCH_ON).build(); | ||
} | ||
|
||
@Override | ||
protected void assertAfterNetworkModificationCreation() { | ||
TestUtils.assertOperatingStatus(getNetwork(), TARGET_BUSBAR_ID, TARGET_BUSBAR_STATUS); | ||
assertTerminalsStatusAfterNetworkModification(false); | ||
} | ||
|
||
@Override | ||
protected void assertAfterNetworkModificationDeletion() { | ||
// back to init status | ||
TestUtils.assertOperatingStatus(getNetwork(), TARGET_BUSBAR_ID, INITIAL_BUSBAR_STATUS); | ||
assertTerminalsStatusAfterNetworkModification(true); | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
protected void testCreationModificationMessage(ModificationInfos modificationInfos) { | ||
assertEquals("OPERATING_STATUS_MODIFICATION", modificationInfos.getMessageType()); | ||
Map<String, String> createdValues = mapper.readValue(modificationInfos.getMessageValues(), new TypeReference<>() { }); | ||
assertEquals("TRIP", createdValues.get("action")); | ||
} | ||
|
||
@Override | ||
@SneakyThrows | ||
protected void testUpdateModificationMessage(ModificationInfos modificationInfos) { | ||
assertEquals("OPERATING_STATUS_MODIFICATION", modificationInfos.getMessageType()); | ||
Map<String, String> updatedValues = mapper.readValue(modificationInfos.getMessageValues(), new TypeReference<>() { }); | ||
assertEquals("SWITCH_ON", updatedValues.get("action")); | ||
} | ||
|
||
private void assertTerminalsStatusAfterNetworkModification(boolean shouldBeConnected) { | ||
BusbarSection busbarSection = getNetwork().getBusbarSection(TARGET_BUSBAR_ID); | ||
Assert.assertEquals(busbarSection.getTerminal().isConnected(), shouldBeConnected); | ||
} | ||
} |