fix: keep temporary limits in REPLACE mode when nothing is applied#191
fix: keep temporary limits in REPLACE mode when nothing is applied#191flomillot wants to merge 1 commit into
Conversation
In REPLACE mode the existing temporary limits were dropped unconditionally as soon as any limit was left untouched, even when every provided input was rejected by validation (missing field, duplicate name, no match). The limit set was emptied although no modification had actually been performed. The existing temporary limits are now kept untouched unless at least one input actually created, modified or deleted a temporary limit. The "no match" check (a MODIFY input targeting a non-existing temporary limit) is also moved before the duplicate check, so an ignored input has no side effect on the limit set. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
📝 WalkthroughWalkthroughThis PR refactors temporary limit modifications to track whether actual changes occurred and validates MODIFY operations against existing limits. The ChangesTemporary Limit Modification Tracking and Validation
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/org/gridsuite/modification/modifications/tabularmodifications/LimitSetModificationsTest.java (1)
440-458: ⚡ Quick winAdd an explicit REPLACE + no-match regression case.
This now covers missing-field rejection in REPLACE mode, but not the
MODIFY-without-match rejection path that was also part of the bug scenario. Adding that case here would better lock theisModifyWithoutMatch+atLeastOneLimitAppliedbehavior.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/org/gridsuite/modification/modifications/tabularmodifications/LimitSetModificationsTest.java` around lines 440 - 458, The test currently checks missing-field rejection for one path but lacks a regression case for a MODIFY-without-match scenario; update the MethodSource "missingTemporaryLimitFieldCases" (the provider used by testTemporaryLimitMissingFieldIsSkipped) to include an explicit case where TemporaryLimitModificationType is MODIFY and the modification targets a non-matching limit (simulate "no-match"), so the code exercises the isModifyWithoutMatch + atLeastOneLimitApplied logic; ensure the new case still results in no changes to existing temporary limits (assertEquals(2, limits.getTemporaryLimits().size()) remains valid) and reuse the existing buildMissingFieldModification/ModificationInfos setup so the test asserts the missing-field rejection path for MODIFY-without-match.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/test/java/org/gridsuite/modification/modifications/tabularmodifications/LimitSetModificationsTest.java`:
- Around line 440-458: The test currently checks missing-field rejection for one
path but lacks a regression case for a MODIFY-without-match scenario; update the
MethodSource "missingTemporaryLimitFieldCases" (the provider used by
testTemporaryLimitMissingFieldIsSkipped) to include an explicit case where
TemporaryLimitModificationType is MODIFY and the modification targets a
non-matching limit (simulate "no-match"), so the code exercises the
isModifyWithoutMatch + atLeastOneLimitApplied logic; ensure the new case still
results in no changes to existing temporary limits (assertEquals(2,
limits.getTemporaryLimits().size()) remains valid) and reuse the existing
buildMissingFieldModification/ModificationInfos setup so the test asserts the
missing-field rejection path for MODIFY-without-match.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 130d6292-3b57-4a45-ae91-64f1355c7319
📒 Files selected for processing (3)
src/main/java/org/gridsuite/modification/modifications/olg/OperationalLimitsGroupModification.javasrc/main/resources/org/gridsuite/modification/reports.propertiessrc/test/java/org/gridsuite/modification/modifications/tabularmodifications/LimitSetModificationsTest.java



Problem
In REPLACE mode, the existing temporary limits of a limit set were dropped unconditionally as soon as any limit was left untouched — even when every provided input had been rejected by validation (missing name/duration, duplicate name, no match). The limit set ended up empty although no modification had actually been performed.
Changes
modifyTemporaryLimitsnow tracks whether at least one input actually applied a change (created / modified / deleted a temporary limit). In REPLACE mode the untouched limits are dropped only when at least one input was applied; otherwise the existing temporary limits are kept intact.MODIFYinput targeting a non-existing temporary limit — is extracted intoisModifyWithoutMatchand moved before the duplicate check, so an ignored input has no side effect on the limit set.temporaryLimitsNoMatchlog message reworded for consistency with the other "ignored" messages.Tests
testTemporaryLimitMissingFieldIsSkippedupdated: an invalid input keeps the existing temporary limits for every modification type, REPLACE included.