Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdded two endpoints: Changes
Sequence DiagramsequenceDiagram
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
Suggested Reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
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
📒 Files selected for processing (4)
monitor-server/src/main/java/org/gridsuite/monitor/server/controllers/ProcessConfigController.javamonitor-server/src/main/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigService.javamonitor-server/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.javamonitor-server/src/test/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigServiceTest.java
...rver/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.java
Show resolved
Hide resolved
.../test/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigServiceTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
monitor-server/src/main/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigService.javamonitor-server/src/test/java/org/gridsuite/monitor/server/controllers/ProcessConfigControllerTest.javamonitor-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
.../src/main/java/org/gridsuite/monitor/server/services/processconfig/ProcessConfigService.java
Show resolved
Hide resolved
|



PR Summary
New endpoint to duplicate a ProcessConfig