-
Notifications
You must be signed in to change notification settings - Fork 0
remove operational limits groups #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
EtienneLt
wants to merge
8
commits into
main
Choose a base branch
from
remove-operational-limits-groups
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+125
−16
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4b4b7d8
remove operational limits groups
EtienneLt 1f3bb06
add test
EtienneLt 1337bb0
review
EtienneLt 118d568
fix
EtienneLt b2742c1
fix
EtienneLt aaa0363
Merge branch 'main' into remove-operational-limits-groups
Mathieu-Deharbe df413fe
Merge branch 'main' into remove-operational-limits-groups
Mathieu-Deharbe 4cec012
Merge branch 'main' into remove-operational-limits-groups
EtienneLt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| package org.gridsuite.modification.modifications; | ||
|
|
||
| import com.fasterxml.jackson.core.type.TypeReference; | ||
| import com.powsybl.commons.PowsyblException; | ||
| import com.powsybl.iidm.network.*; | ||
| import com.powsybl.iidm.network.extensions.ConnectablePosition; | ||
| import com.powsybl.iidm.network.extensions.Measurement; | ||
|
|
@@ -23,6 +24,7 @@ | |
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.gridsuite.modification.NetworkModificationException.Type.LINE_NOT_FOUND; | ||
| import static org.gridsuite.modification.dto.OperationalLimitsGroupInfos.Applicability.*; | ||
| import static org.gridsuite.modification.dto.OperationalLimitsGroupModificationType.DELETE; | ||
| import static org.gridsuite.modification.dto.OperationalLimitsGroupModificationType.MODIFY_OR_ADD; | ||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
|
|
@@ -325,6 +327,79 @@ void testConnectWhenNoSwitchesOpened() { | |
| assertEquals("BRANCH_MODIFICATION_ERROR : Could not connect equipment 'line1' on side 1 & 2", exception.getMessage()); | ||
| } | ||
|
|
||
| @Test | ||
| void testDelete() { | ||
| Line line = getNetwork().getLine("line1"); | ||
| // side 1 | ||
| line.newOperationalLimitsGroup1("NewLimitsGroup1").newCurrentLimits() | ||
| .setPermanentLimit(10.0) | ||
| .add(); | ||
| line.newOperationalLimitsGroup1("NewLimitsGroup2").newCurrentLimits() | ||
| .setPermanentLimit(10.0) | ||
| .add(); | ||
| // side 2 | ||
| line.newOperationalLimitsGroup2("NewLimitsGroup1").newCurrentLimits() | ||
| .setPermanentLimit(10.0) | ||
| .add(); | ||
| line.newOperationalLimitsGroup2("NewLimitsGroup3").newCurrentLimits() | ||
| .setPermanentLimit(10.0) | ||
| .add(); | ||
|
Comment on lines
+346
to
+355
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for "NewLimitsGroup2" and "NewLimitsGroup3" to have 2 different names ? Wouldn't it be more useful to have the same name in order to check that the DELETE correctly handle the applicability and doesn't delete both ? |
||
|
|
||
| // modification 1 remove olg on both side | ||
| OperationalLimitsGroupModificationInfos opLimitsGroupInfos1 = OperationalLimitsGroupModificationInfos.builder() | ||
| .id("NewLimitsGroup1").applicability(EQUIPMENT).modificationType(DELETE).build(); | ||
| LineModificationInfos lineModificationInfos1 = LineModificationInfos.builder() | ||
| .enableOLGModification(true) | ||
| .equipmentId("line1") | ||
| .operationalLimitsGroups(Collections.singletonList(opLimitsGroupInfos1)).build(); | ||
| lineModificationInfos1.toModification().apply(getNetwork()); | ||
|
|
||
| assertTrue(line.getOperationalLimitsGroup1("NewLimitsGroup1").isEmpty()); | ||
| assertTrue(line.getOperationalLimitsGroup2("NewLimitsGroup1").isEmpty()); | ||
| assertTrue(line.getOperationalLimitsGroup1("NewLimitsGroup2").isPresent()); | ||
| assertTrue(line.getOperationalLimitsGroup2("NewLimitsGroup3").isPresent()); | ||
|
|
||
| // modification 2 remove olg on side one | ||
| OperationalLimitsGroupModificationInfos opLimitsGroupInfos2 = OperationalLimitsGroupModificationInfos.builder() | ||
| .id("NewLimitsGroup2").applicability(SIDE1).modificationType(DELETE).build(); | ||
| LineModificationInfos lineModificationInfos2 = LineModificationInfos.builder() | ||
| .enableOLGModification(true) | ||
| .equipmentId("line1") | ||
| .operationalLimitsGroups(Collections.singletonList(opLimitsGroupInfos2)).build(); | ||
| lineModificationInfos2.toModification().apply(getNetwork()); | ||
|
|
||
| assertTrue(line.getOperationalLimitsGroup1("NewLimitsGroup1").isEmpty()); | ||
| assertTrue(line.getOperationalLimitsGroup2("NewLimitsGroup1").isEmpty()); | ||
| assertTrue(line.getOperationalLimitsGroup1("NewLimitsGroup2").isEmpty()); | ||
| assertTrue(line.getOperationalLimitsGroup2("NewLimitsGroup3").isPresent()); | ||
|
|
||
| // modification 3 remove olg on side two | ||
| OperationalLimitsGroupModificationInfos opLimitsGroupInfos3 = OperationalLimitsGroupModificationInfos.builder() | ||
| .id("NewLimitsGroup3").applicability(SIDE2).modificationType(DELETE).build(); | ||
| LineModificationInfos lineModificationInfos3 = LineModificationInfos.builder() | ||
| .enableOLGModification(true) | ||
| .equipmentId("line1") | ||
| .operationalLimitsGroups(Collections.singletonList(opLimitsGroupInfos3)).build(); | ||
| lineModificationInfos3.toModification().apply(getNetwork()); | ||
|
|
||
| assertTrue(line.getOperationalLimitsGroup1("NewLimitsGroup1").isEmpty()); | ||
| assertTrue(line.getOperationalLimitsGroup2("NewLimitsGroup1").isEmpty()); | ||
| assertTrue(line.getOperationalLimitsGroup1("NewLimitsGroup2").isEmpty()); | ||
| assertTrue(line.getOperationalLimitsGroup2("NewLimitsGroup3").isEmpty()); | ||
|
|
||
| // try to remove not existing group | ||
| OperationalLimitsGroupModificationInfos opLimitsGroupInfos4 = OperationalLimitsGroupModificationInfos.builder() | ||
| .id("doesNotExist").applicability(SIDE2).modificationType(DELETE).build(); | ||
| LineModificationInfos lineModificationInfos4 = LineModificationInfos.builder() | ||
| .enableOLGModification(true) | ||
| .equipmentId("line1") | ||
| .operationalLimitsGroups(Collections.singletonList(opLimitsGroupInfos4)).build(); | ||
| Network network = getNetwork(); | ||
| AbstractModification modification = lineModificationInfos4.toModification(); | ||
| String errorMessage = assertThrows(PowsyblException.class, () -> modification.apply(network)).getMessage(); | ||
| assertEquals("Cannot delete operational limit group doesNotExist which has not been found in equipment on side SIDE2", errorMessage); | ||
| } | ||
|
|
||
| private void changeLineConnectionState(Line existingEquipment, boolean expectedState) { | ||
| LineModificationInfos modificationInfos = (LineModificationInfos) buildModification(); | ||
| modificationInfos.setTerminal1Connected(new AttributeModification<>(expectedState, OperationType.SET)); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sur we should throw here ? Why not just log an error ?