Skip to content

Commit

Permalink
Unit Tests update
Browse files Browse the repository at this point in the history
Signed-off-by: BOUTIER Charly <[email protected]>
  • Loading branch information
BOUTIER Charly committed Sep 5, 2024
1 parent 3927955 commit f8e9d14
Showing 1 changed file with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2022, RTE (http://www.rte-france.com)
* 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/.
Expand All @@ -21,22 +21,21 @@
import java.util.UUID;

import static com.powsybl.iidm.network.extensions.OperatingStatus.Status.FORCED_OUTAGE;
import static com.powsybl.iidm.network.extensions.OperatingStatus.Status.PLANNED_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 String UPDATE_BRANCH_ID = "line1";
private static final OperatingStatus.Status TARGET_BRANCH_STATUS = FORCED_OUTAGE;
private static final OperatingStatus.Status OTHER_BRANCH_STATUS = PLANNED_OUTAGE;
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, OTHER_BRANCH_STATUS);
TestUtils.setOperatingStatus(network, TARGET_BUSBAR_ID, INITIAL_BUSBAR_STATUS);
return network;
}

Expand All @@ -45,29 +44,27 @@ protected ModificationInfos buildModification() {
return OperatingStatusModificationInfos.builder()
.stashed(false)
.equipmentId(TARGET_BUSBAR_ID)
.energizedVoltageLevelId("energizedVoltageLevelId")
.action(OperatingStatusModificationInfos.ActionType.TRIP).build();
}

@Override
protected ModificationInfos buildModificationUpdate() {
return OperatingStatusModificationInfos.builder()
.stashed(false)
.equipmentId(UPDATE_BRANCH_ID)
.energizedVoltageLevelId("energizedVoltageLevelIdEdited")
.equipmentId(TARGET_BUSBAR_ID)
.action(OperatingStatusModificationInfos.ActionType.SWITCH_ON).build();
}

@Override
protected void assertAfterNetworkModificationCreation() {
TestUtils.assertOperatingStatus(getNetwork(), TARGET_BUSBAR_ID, TARGET_BRANCH_STATUS);
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, OTHER_BRANCH_STATUS);
TestUtils.assertOperatingStatus(getNetwork(), TARGET_BUSBAR_ID, INITIAL_BUSBAR_STATUS);
assertTerminalsStatusAfterNetworkModification(true);
}

Expand All @@ -76,19 +73,15 @@ protected void assertAfterNetworkModificationDeletion() {
protected void testCreationModificationMessage(ModificationInfos modificationInfos) {
assertEquals("OPERATING_STATUS_MODIFICATION", modificationInfos.getMessageType());
Map<String, String> createdValues = mapper.readValue(modificationInfos.getMessageValues(), new TypeReference<>() { });
assertEquals("energizedVoltageLevelId", createdValues.get("energizedVoltageLevelId"));
assertEquals("TRIP", createdValues.get("action"));
assertEquals("1.A", createdValues.get("equipmentId"));
}

@Override
@SneakyThrows
protected void testUpdateModificationMessage(ModificationInfos modificationInfos) {
assertEquals("OPERATING_STATUS_MODIFICATION", modificationInfos.getMessageType());
Map<String, String> updatedValues = mapper.readValue(modificationInfos.getMessageValues(), new TypeReference<>() { });
assertEquals("energizedVoltageLevelIdEdited", updatedValues.get("energizedVoltageLevelId"));
assertEquals("SWITCH_ON", updatedValues.get("action"));
assertEquals("line1", updatedValues.get("equipmentId"));
}

private void assertTerminalsStatusAfterNetworkModification(boolean shouldBeConnected) {
Expand Down

0 comments on commit f8e9d14

Please sign in to comment.