Skip to content

Clean orphans when updating composite modifications#843

Open
Meklo wants to merge 1 commit into
mainfrom
marcellinh/clean_orphans_updating_composite_modification
Open

Clean orphans when updating composite modifications#843
Meklo wants to merge 1 commit into
mainfrom
marcellinh/clean_orphans_updating_composite_modification

Conversation

@Meklo

@Meklo Meklo commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

PR Summary

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Composite update deletion fix and test verification

Layer / File(s) Summary
Delete prior child modifications
src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java
updateCompositeModification now calls deleteModifications(...) on the composite's existing modifications before persisting the new reordered clone list.
Repository field wiring in tests
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java
Adds a ModificationRepository import and splits fields into networkModificationRepository (NetworkModificationRepository) and modificationRepository (ModificationRepository); @AfterEach cleanup now uses networkModificationRepository.
Update verification calls across composite tests
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java
Migrates stored-data assertions (getModificationInfo, getModifications, getModificationEntity) across testSplit, testInsert, createSomeSwitchModifications, testDuplicateCompositeModification, testMoveSubModificationFromCompositeToRoot, testAssembleNetworkModificationsIntoNewComposite, testMoveSubModificationFromRootToComposite, and testCreateCompositeFromSingleCompositeDoesNotWrap to use networkModificationRepository.
Verify deletion of prior composite children
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java
In testUpdateNetworkCompositeModification, captures pre-update child UUIDs and asserts via modificationRepository.findAllByIdIn(...).size() == 0 that they were deleted, alongside group-modification verification via networkModificationRepository.

Suggested reviewers: Mathieu-Deharbe, souissimai

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is just a template prompt and does not actually summarize the changes. Replace the template text with a brief summary of what changed, why, and any reviewer notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately states the main change: cleaning orphaned child modifications during composite updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java (1)

334-346: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Good 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 in NetworkModificationRepository.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

📥 Commits

Reviewing files that changed from the base of the PR and between 3bffb36 and b1143cd.

📒 Files selected for processing (2)
  • src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java
  • src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant