Implement state estimation result provider and service#44
Implement state estimation result provider and service#44
Conversation
Signed-off-by: achour94 <berrahmaachour@gmail.com>
📝 WalkthroughWalkthroughA new state estimation result type is introduced to the monitoring commons enum, paired with two Spring services (StateEstimationService and StateEstimationResultProvider) that handle fetching and deleting state estimation results via REST. Configuration and comprehensive unit tests are included. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ResultProvider as StateEstimationResultProvider
participant Service as StateEstimationService
participant REST as RestTemplate
participant Server as State Estimation Server
Client->>ResultProvider: getResult(resultId)
ResultProvider->>Service: getResult(resultId)
Service->>REST: GET /v1/results/{resultId}
REST->>Server: HTTP GET Request
Server-->>REST: 200 OK + JSON Response
REST-->>Service: Response Body (String)
Service-->>ResultProvider: Result String
ResultProvider-->>Client: Result String
Client->>ResultProvider: deleteResult(resultId)
ResultProvider->>Service: deleteResult(resultId)
Service->>REST: DELETE /v1/results?resultsUuids={resultId}
REST->>Server: HTTP DELETE Request
Server-->>REST: 200 OK
REST-->>Service: Void
Service-->>ResultProvider: Void
ResultProvider-->>Client: Void
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 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. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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: 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/StateEstimationService.java`:
- Around line 36-38: The helper getStateEstimationServerBaseUri() currently
concatenates stateEstimationServerBaseUri, DELIMITER and SE_API_VERSION which
can produce double slashes when stateEstimationServerBaseUri already ends with a
slash; change it to normalize the base by trimming any trailing '/' from
stateEstimationServerBaseUri (or conditionally avoid adding DELIMITER when it
already ends with one) before appending DELIMITER + SE_API_VERSION + DELIMITER
so constructed URLs like //v1//results are eliminated; update any callers
relying on getStateEstimationServerBaseUri() accordingly.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
monitor-commons/src/main/java/org/gridsuite/monitor/commons/ResultType.javamonitor-server/src/main/java/org/gridsuite/monitor/server/services/StateEstimationResultProvider.javamonitor-server/src/main/java/org/gridsuite/monitor/server/services/StateEstimationService.javamonitor-server/src/main/resources/application-local.yamlmonitor-server/src/test/java/org/gridsuite/monitor/server/services/StateEstimationResultProviderTest.javamonitor-server/src/test/java/org/gridsuite/monitor/server/services/StateEstimationServiceTest.java
| private String getStateEstimationServerBaseUri() { | ||
| return this.stateEstimationServerBaseUri + DELIMITER + SE_API_VERSION + DELIMITER; | ||
| } |
There was a problem hiding this comment.
Normalize the base URI to avoid //v1//results requests.
With a trailing slash in the default base URI and leading slashes in paths, the constructed URLs contain double slashes, which can break strict path matching and won’t match the test expectations.
🔧 Proposed fix
- private String getStateEstimationServerBaseUri() {
- return this.stateEstimationServerBaseUri + DELIMITER + SE_API_VERSION + DELIMITER;
- }
+ private String getStateEstimationServerBaseUri() {
+ String baseUri = this.stateEstimationServerBaseUri;
+ if (baseUri.endsWith(DELIMITER)) {
+ baseUri = baseUri.substring(0, baseUri.length() - 1);
+ }
+ return baseUri + DELIMITER + SE_API_VERSION;
+ }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@monitor-server/src/main/java/org/gridsuite/monitor/server/services/StateEstimationService.java`
around lines 36 - 38, The helper getStateEstimationServerBaseUri() currently
concatenates stateEstimationServerBaseUri, DELIMITER and SE_API_VERSION which
can produce double slashes when stateEstimationServerBaseUri already ends with a
slash; change it to normalize the base by trimming any trailing '/' from
stateEstimationServerBaseUri (or conditionally avoid adding DELIMITER when it
already ends with one) before appending DELIMITER + SE_API_VERSION + DELIMITER
so constructed URLs like //v1//results are eliminated; update any callers
relying on getStateEstimationServerBaseUri() accordingly.



PR Summary
This pull request adds support for handling state estimation results in the monitoring server. The changes introduce new service and provider classes for state estimation.