Clean orphans when updating composite modifications#843
Conversation
📝 WalkthroughWalkthroughThe repository's updateCompositeModification method now deletes a composite's previously held child modifications before reassigning the new ordered modification list. CompositeControllerTest is updated to use a dedicated networkModificationRepository for most stored-data queries while using modificationRepository specifically to verify deletion of stale child modifications. ChangesComposite update deletion fix and test verification
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
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/server/CompositeControllerTest.java (1)
334-346: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winGood regression test for the orphan-cleanup fix.
Capturing the composite's actual cloned child UUIDs before update and asserting their deletion via
modificationRepository.findAllByIdIn(...)correctly targets the fix inNetworkModificationRepository.updateCompositeModification.This only covers flat/leaf sub-modifications though. Given the nested-composite orphan gap flagged in
NetworkModificationRepository.java(Lines 183-186), consider adding a variant where one of the composite's children is itself a nested composite, and assert its descendants are also deleted after the update.🤖 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/server/CompositeControllerTest.java` around lines 334 - 346, Add a regression test that covers the nested-composite orphan cleanup gap in addition to the existing flat child case. In CompositeControllerTest, reuse the composite update flow around get(URI_GET_COMPOSITE_NETWORK_MODIF_CONTENT) and put(URI_COMPOSITE_NETWORK_MODIF_BASE, ...) but build a child structure where one child is itself a composite, then capture both the nested composite UUID and its descendant UUIDs before the update. After calling the update, assert via modificationRepository.findAllByIdIn(...) that the nested child and its descendants are all deleted, so the test exercises the behavior fixed in NetworkModificationRepository.updateCompositeModification.
🤖 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/server/CompositeControllerTest.java`:
- Around line 334-346: Add a regression test that covers the nested-composite
orphan cleanup gap in addition to the existing flat child case. In
CompositeControllerTest, reuse the composite update flow around
get(URI_GET_COMPOSITE_NETWORK_MODIF_CONTENT) and
put(URI_COMPOSITE_NETWORK_MODIF_BASE, ...) but build a child structure where one
child is itself a composite, then capture both the nested composite UUID and its
descendant UUIDs before the update. After calling the update, assert via
modificationRepository.findAllByIdIn(...) that the nested child and its
descendants are all deleted, so the test exercises the behavior fixed in
NetworkModificationRepository.updateCompositeModification.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8357d15a-7348-4b0d-98a1-28cc8a761552
📒 Files selected for processing (2)
src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.javasrc/test/java/org/gridsuite/modification/server/CompositeControllerTest.java



PR Summary