Skip to content

move endpoints that update network modifications to supervision controller#815

Merged
khouadrired merged 2 commits into
mainfrom
move-endpoints-to-supervision
May 20, 2026
Merged

move endpoints that update network modifications to supervision controller#815
khouadrired merged 2 commits into
mainfrom
move-endpoints-to-supervision

Conversation

@khouadrired
Copy link
Copy Markdown
Contributor

No description provided.

…oller

Signed-off-by: Radouane Khouadri <redouane.khouadri_externe@rte-france.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR relocates line-type catalog management endpoints from NetworkModificationController to SupervisionController. The endpoints accept multipart file uploads and handle deletion via a newly injected LineTypesCatalogService. All related test coverage is migrated from ModificationControllerTest to SupervisionControllerTest with expanded test cases for limits-aware retrieval and error scenarios.

Changes

Catalog Endpoint Migration

Layer / File(s) Summary
Remove catalog endpoints from NetworkModificationController
src/main/java/org/gridsuite/modification/server/NetworkModificationController.java
POST /network-modifications/catalog/line_types (multipart) and DELETE /network-modifications/catalog/line_types endpoints are removed, along with MultipartFile import.
Add catalog endpoints to SupervisionController
src/main/java/org/gridsuite/modification/server/SupervisionController.java
Inject LineTypesCatalogService dependency, add multipart-related imports, and implement POST (file upload) and DELETE (catalog deletion) endpoints that delegate to the catalog service. Both return 200 OK with empty body.
Remove catalog tests from ModificationControllerTest
src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java
Remove line-type catalog CRUD tests, "with/without limits" retrieval tests, multipart error handling, helper method, and related constants; replace wildcard static imports with explicit imports.
Add comprehensive catalog tests to SupervisionControllerTest
src/test/java/org/gridsuite/modification/server/SupervisionControllerTest.java
Add test setup with LineTypesCatalogService and ObjectMapper injection; introduce tests for upload/delete flow, limits-aware catalog retrieval with field validation, non-existing resource error handling, and catalog retrieval without limits; add createMockMultipartFile helper for multipart test construction.

Suggested reviewers

  • antoinebhs
  • souissimai
  • SlimaneAmar
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess its relevance to the changeset. Add a pull request description explaining the rationale for moving these endpoints and any related context about the refactoring.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving the line-types catalog endpoints from NetworkModificationController to SupervisionController.
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.

✏️ 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.

❤️ Share

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

@khouadrired khouadrired requested a review from antoinebhs May 18, 2026 12:18
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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/SupervisionControllerTest.java (1)

136-169: ⚡ Quick win

Centralize catalog cleanup to avoid inter-test state leakage.

These tests rely on an empty shared catalog at start; if a test fails before its trailing DELETE, subsequent tests can fail for the wrong reason. Add an @AfterEach cleanup (or @BeforeEach reset) to make isolation deterministic.

♻️ Suggested cleanup pattern
+import org.junit.jupiter.api.AfterEach;
...
 class SupervisionControllerTest {
 ...
+    `@AfterEach`
+    void cleanupCatalog() {
+        lineTypesCatalogService.deleteLineTypesCatalog();
+    }

Also applies to: 171-208, 223-251

🤖 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/SupervisionControllerTest.java`
around lines 136 - 169, Add deterministic catalog cleanup in
SupervisionControllerTest by introducing an `@AfterEach` (or `@BeforeEach`) method
that resets the line types catalog regardless of test outcome; implement it to
call the same delete endpoint used in tests
(mockMvc.perform(delete(SUPERVISION_URI_LINE_CATALOG)).andExpect(status().isOk()))
or use a direct service clear method if available
(lineTypesCatalogService.getAllLineTypes()/clear), and invoke this cleanup for
every test including testGetLineTypesCatalog and the other catalog tests to
prevent inter-test state leakage.
🤖 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/SupervisionControllerTest.java`:
- Around line 136-169: Add deterministic catalog cleanup in
SupervisionControllerTest by introducing an `@AfterEach` (or `@BeforeEach`) method
that resets the line types catalog regardless of test outcome; implement it to
call the same delete endpoint used in tests
(mockMvc.perform(delete(SUPERVISION_URI_LINE_CATALOG)).andExpect(status().isOk()))
or use a direct service clear method if available
(lineTypesCatalogService.getAllLineTypes()/clear), and invoke this cleanup for
every test including testGetLineTypesCatalog and the other catalog tests to
prevent inter-test state leakage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2c96415-fd32-4d1e-abe6-1d0603700b80

📥 Commits

Reviewing files that changed from the base of the PR and between 5ad3cb3 and ffe2205.

📒 Files selected for processing (4)
  • src/main/java/org/gridsuite/modification/server/NetworkModificationController.java
  • src/main/java/org/gridsuite/modification/server/SupervisionController.java
  • src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java
  • src/test/java/org/gridsuite/modification/server/SupervisionControllerTest.java
💤 Files with no reviewable changes (1)
  • src/main/java/org/gridsuite/modification/server/NetworkModificationController.java

@sonarqubecloud
Copy link
Copy Markdown

@khouadrired khouadrired merged commit 389b334 into main May 20, 2026
5 checks passed
@khouadrired khouadrired deleted the move-endpoints-to-supervision branch May 20, 2026 09:07
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.

2 participants