Skip to content

Add process configs duplication endpoint#74

Open
carojeandat wants to merge 4 commits intomainfrom
add-duplicate-process-config
Open

Add process configs duplication endpoint#74
carojeandat wants to merge 4 commits intomainfrom
add-duplicate-process-config

Conversation

@carojeandat
Copy link

PR Summary

New endpoint to duplicate a ProcessConfig

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eeaa5d8d-9d0d-4143-b463-1f9cf3567398

📥 Commits

Reviewing files that changed from the base of the PR and between 7c0d148 and e4fa2a1.

📒 Files selected for processing (4)
  • monitor-server/src/main/java/org/gridsuite/monitor/server/controllers/ProcessConfigController.java
  • monitor-server/src/main/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigService.java
  • monitor-server/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.java
  • monitor-server/src/test/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigServiceTest.java
🚧 Files skipped from review as they are similar to previous changes (4)
  • monitor-server/src/main/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigService.java
  • monitor-server/src/main/java/org/gridsuite/monitor/server/controllers/ProcessConfigController.java
  • monitor-server/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.java
  • monitor-server/src/test/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigServiceTest.java

📝 Walkthrough

Walkthrough

Added two endpoints: GET /metadata to return persisted process-config metadata for given UUIDs, and POST /duplication to duplicate a process config by UUID. Service methods for bulk metadata retrieval and duplication (returning new UUID or empty) were added; tests were added for both behaviors.

Changes

Cohort / File(s) Summary
Controller
monitor-server/src/main/java/org/gridsuite/monitor/server/controllers/ProcessConfigController.java
Added GET /v1/process-configs/metadata accepting ids: List<UUID> delegating to service and returning 200 with list; added POST /v1/process-configs/duplication?duplicateFrom={uuid} delegating to service and returning 200 with new UUID or 404 when absent.
Service
monitor-server/src/main/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigService.java
Extracted creation to doCreateProcessConfig(...); added @Transactional(readOnly = true) getProcessConfigsMetadata(List<UUID>) to bulk-load and map metadata; added @Transactional duplicateProcessConfig(UUID) to clone a found entity and return new UUID or empty.
Controller Tests
monitor-server/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.java
Added tests for GET /metadata returning JSON list and verifying service invocation; added duplication tests covering success (200 + new UUID) and not-found (404), verifying service calls.
Service Tests
monitor-server/src/test/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigServiceTest.java
Added tests for getProcessConfigsMetadata() mapping entities to PersistedProcessConfig; added duplication tests for found (returns new UUID, verifies save) and not-found (returns empty, verifies lookup only).

Sequence Diagram

sequenceDiagram
    participant Client
    participant Controller as ProcessConfigController
    participant Service as ProcessConfigService
    participant Repo as ProcessConfigRepository
    participant DB as Database

    Client->>Controller: POST /v1/process-configs/duplication?duplicateFrom={uuid}
    Controller->>Service: duplicateProcessConfig(sourceUuid)
    Service->>Repo: findById(sourceUuid)
    Repo->>DB: SELECT process_config
    DB-->>Repo: ProcessConfigEntity

    alt Source Found
        Repo-->>Service: Optional(ProcessConfigEntity)
        Service->>Service: map to ProcessConfig & prepare duplicate
        Service->>Repo: save(newEntity)
        Repo->>DB: INSERT process_config
        DB-->>Repo: Saved entity (id=newUuid)
        Repo-->>Service: Saved entity
        Service-->>Controller: Optional(newUuid)
        Controller-->>Client: 200 OK + newUuid
    else Source Not Found
        Repo-->>Service: Optional.empty
        Service-->>Controller: Optional.empty
        Controller-->>Client: 404 Not Found
    end
Loading

Suggested Reviewers

  • FranckLecuyer
  • khouadrired
  • antoinebhs
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a new endpoint for duplicating process configs, which matches the core functionality introduced across the controller, service, and test files.
Description check ✅ Passed The description is related to the changeset, mentioning the new endpoint to duplicate a ProcessConfig, which aligns with the primary objective of the 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.

@carojeandat carojeandat changed the title Duplicate ProcessConfig Add process configs duplication endpoint Mar 20, 2026
Copy link

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@monitor-server/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.java`:
- Around line 153-165: Update the test duplicateSecurityAnalysisConfig() in
ProcessConfigControllerTest to assert the response body contains the returned
UUID: after the mockMvc.perform(...) call, add an expectation that the response
content equals newProcessConfigId.toString() (e.g.,
andExpect(content().string(newProcessConfigId.toString()))), keeping the
existing status assertion and the verify of
processConfigService.duplicateProcessConfig(any(UUID.class)).

In
`@monitor-server/src/test/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigServiceTest.java`:
- Around line 147-153: The two empty test methods in ProcessConfigServiceTest
must exercise the service method duplicateProcessConfig: implement one test
(duplicateSecurityAnalysisConfig) that sets up a mock repository to return an
existing ProcessConfig when findById(...) is called, invokes
ProcessConfigService.duplicateProcessConfig(id), asserts the returned Optional
contains a new UUID different from the source id, and verifies
repository.save(...) was called with an entity that copies the relevant fields
from the source (name, settings, etc.) but has a new id; implement the second
test (duplicateSecurityAnalysisConfigNotFound) to have the repository return
Optional.empty(), call duplicateProcessConfig(id), and assert Optional.empty()
is returned and repository.save(...) is never called. Ensure you reference the
service method duplicateProcessConfig and repository.save/findById in the mocks
and assertions to validate behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b3677d95-3cac-4002-97a4-e08181bc7048

📥 Commits

Reviewing files that changed from the base of the PR and between c216da6 and 4342c6c.

📒 Files selected for processing (4)
  • monitor-server/src/main/java/org/gridsuite/monitor/server/controllers/ProcessConfigController.java
  • monitor-server/src/main/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigService.java
  • monitor-server/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.java
  • monitor-server/src/test/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigServiceTest.java

Copy link

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@monitor-server/src/main/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigService.java`:
- Around line 69-73: duplicateProcessConfig currently calls
processConfigRepository.save(sourceEntity) which will merge the existing entity
instead of inserting a new row; change the logic in ProcessConfigService. In
duplicateProcessConfig(UUID) fetch the source via
processConfigRepository.findById, create a new ProcessConfig instance (or
deep/shallow copy relevant fields from sourceEntity) and ensure its id is
null/cleared (and detach/avoid using the same entity instance), then call
processConfigRepository.save(newEntity) so JPA inserts a new record and returns
a new UUID; also copy or reset any relationship IDs, audit fields, or unique
constraints as appropriate before saving.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9f0a8841-eb67-4643-aea9-4f44d1ec4428

📥 Commits

Reviewing files that changed from the base of the PR and between 4342c6c and 6d66f6a.

📒 Files selected for processing (3)
  • monitor-server/src/main/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigService.java
  • monitor-server/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.java
  • monitor-server/src/test/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigServiceTest.java
✅ Files skipped from review due to trivial changes (1)
  • monitor-server/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • monitor-server/src/test/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigServiceTest.java

@sonarqubecloud
Copy link

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