Skip to content

Get multiple computation statuses at once#40

Open
sBouzols wants to merge 8 commits into
mainfrom
get_computation_status_for_multiple_results_at_once
Open

Get multiple computation statuses at once#40
sBouzols wants to merge 8 commits into
mainfrom
get_computation_status_for_multiple_results_at_once

Conversation

@sBouzols

Copy link
Copy Markdown

PR Summary

Add getStatuses in AbstractComputationService
Add findStatuses in AbstractComputationResultService

@sBouzols sBouzols requested a review from SlimaneAmar April 30, 2026 14:53
@sBouzols sBouzols changed the title Get multiple computation statuses at once [WIP] Get multiple computation statuses at once Apr 30, 2026
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@sBouzols, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 7 minutes and 15 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 435e36d1-67c7-4eba-8be4-42e3504b472b

📥 Commits

Reviewing files that changed from the base of the PR and between 24a6246 and a827d57.

📒 Files selected for processing (3)
  • src/main/java/org/gridsuite/computation/service/AbstractComputationResultService.java
  • src/main/java/org/gridsuite/computation/service/AbstractComputationService.java
  • src/test/java/org/gridsuite/computation/ComputationTest.java
📝 Walkthrough

Walkthrough

The PR introduces a bulk status retrieval API in the computation service hierarchy. AbstractComputationResultService adds an abstract findStatuses(List<UUID>) and makes findStatus(UUID) delegate to it. AbstractComputationService adds getStatuses(List<UUID>) (empty-list -> Map.of()), and getStatus(UUID) now delegates through the bulk method. Tests add a mock batch implementation and unit tests for normal and empty/null inputs.

Changes

Bulk Status Retrieval Refactoring

Layer / File(s) Summary
Result Service Bulk API Contract
src/main/java/org/gridsuite/computation/service/AbstractComputationResultService.java
Adds Map import. Declares abstract findStatuses(List<UUID>) returning Map<UUID, S>. Converts findStatus(UUID) to concrete implementation delegating to bulk method via findStatuses(List.of(resultUuid)).
Computation Service Delegation Layer
src/main/java/org/gridsuite/computation/service/AbstractComputationService.java
Adds Map import. Introduces getStatuses(List<UUID>) returning Map.of() for empty lists, otherwise delegating to resultService.findStatuses(resultUuids). Updates getStatus(UUID) to delegate through getStatuses(List.of(resultUuid)).
Test Mock and Unit Tests
src/test/java/org/gridsuite/computation/ComputationTest.java
Adds stream utility imports. Implements findStatuses(List<UUID>) in mock by mapping input UUIDs to stored statuses from mockDBStatus. Adds testGetStatuses verifying returned map contents and delegation. Adds testGetStatusesWithNoResultUuids asserting empty-map return for empty and null UUID lists.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding bulk status retrieval capability for multiple computation statuses in one operation.
Description check ✅ Passed The description is directly related to the changeset, listing the two key methods added (getStatuses and findStatuses) which matches the actual code modifications.
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.

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

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
`@src/main/java/org/gridsuite/computation/service/AbstractComputationService.java`:
- Around line 108-111: In getStatuses in AbstractComputationService, guard
against a null resultUuids before calling isEmpty(): check if resultUuids ==
null (or use Objects.requireNonNull with a custom message) and throw the same
ComputationException(EMPTY_PARAMS, "Result uuids cannot be empty") so that null
input produces the controlled ComputationException instead of an NPE; update the
null/empty conditional that currently calls resultUuids.isEmpty() to handle both
cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 824339f1-07ca-48c3-8854-193d14900d07

📥 Commits

Reviewing files that changed from the base of the PR and between 4c2eb2c and a2b157b.

📒 Files selected for processing (4)
  • src/main/java/org/gridsuite/computation/error/ComputationBusinessErrorCode.java
  • src/main/java/org/gridsuite/computation/service/AbstractComputationResultService.java
  • src/main/java/org/gridsuite/computation/service/AbstractComputationService.java
  • src/test/java/org/gridsuite/computation/ComputationTest.java


public Map<UUID, S> getStatuses(List<UUID> resultUuids) {
if (resultUuids.isEmpty()) {
throw new ComputationException(EMPTY_PARAMS, "Result uuids cannot be empty");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Really an error ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok I removed the error management here. returning an empty Map then

Comment thread src/test/java/org/gridsuite/computation/ComputationTest.java Outdated
Comment thread src/test/java/org/gridsuite/computation/ComputationTest.java Outdated
Co-authored-by: Copilot <[email protected]>
Signed-off-by: sBouzols <[email protected]>

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/org/gridsuite/computation/service/AbstractComputationResultService.java (1)

25-29: LGTM!

The contract inversion is clean: findStatus now provides a default implementation by delegating to the bulk findStatuses method. This allows subclasses to optimize by implementing only the batch operation.

Optional: Consider documenting the contract for missing UUIDs.

The implicit contract for findStatuses when a UUID doesn't exist in the database could be clarified:

  • Should the map omit the key (current behavior based on the mock)?
  • Or include the key with a null value?

Adding a Javadoc comment on findStatuses specifying that missing UUIDs should be omitted from the returned map (not included with null values) would help implementers and prevent subtle bugs.

🤖 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/main/java/org/gridsuite/computation/service/AbstractComputationResultService.java`
around lines 25 - 29, Add a Javadoc to the abstract method findStatuses in
AbstractComputationResultService that documents the contract for missing UUIDs:
state that implementations should omit keys for UUIDs not found (do not include
keys with null values), and mention that findStatus delegates to findStatuses so
callers rely on that omission behavior; update the method's JavaDoc to clearly
describe input (List<UUID> resultUuids), expected Map<UUID, S> return (only
present entries), and any null-safety expectations for S implementations.
🤖 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.

Inline comments:
In `@src/test/java/org/gridsuite/computation/ComputationTest.java`:
- Around line 136-139: The findStatuses method can NPE when mockDBStatus.get
returns null because Collectors.toMap rejects null values; change the logic to
guard against missing keys by filtering resultUuids to only those present in
mockDBStatus (use mockDBStatus.containsKey(uuid)) before collecting, or
alternatively map each UUID to a non-null default (e.g., Optional/placeholder)
instead of allowing nulls; update the method that references resultUuids,
mockDBStatus, and findStatuses accordingly so the returned Map contains no null
values.

---

Nitpick comments:
In
`@src/main/java/org/gridsuite/computation/service/AbstractComputationResultService.java`:
- Around line 25-29: Add a Javadoc to the abstract method findStatuses in
AbstractComputationResultService that documents the contract for missing UUIDs:
state that implementations should omit keys for UUIDs not found (do not include
keys with null values), and mention that findStatus delegates to findStatuses so
callers rely on that omission behavior; update the method's JavaDoc to clearly
describe input (List<UUID> resultUuids), expected Map<UUID, S> return (only
present entries), and any null-safety expectations for S implementations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: faf64c40-7b4a-41da-8b0d-4fa148a07e4a

📥 Commits

Reviewing files that changed from the base of the PR and between a2b157b and 735b23c.

📒 Files selected for processing (3)
  • src/main/java/org/gridsuite/computation/service/AbstractComputationResultService.java
  • src/main/java/org/gridsuite/computation/service/AbstractComputationService.java
  • src/test/java/org/gridsuite/computation/ComputationTest.java

Comment thread src/test/java/org/gridsuite/computation/ComputationTest.java
@sBouzols sBouzols changed the title [WIP] Get multiple computation statuses at once Get multiple computation statuses at once May 21, 2026
sBouzols and others added 2 commits May 21, 2026 16:55
Avoid `NullPointerException` if any UUID in `resultUuids` is not present in `mockDBStatus`

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: sBouzols <[email protected]>
@sonarqubecloud

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

389-399: ⚡ Quick win

Consider adding test coverage for partial results.

The test verifies the happy path where all requested UUIDs exist in the database. However, it doesn't test the behavior when getStatuses is called with a mix of existing and non-existing UUIDs. Given that findStatuses (lines 138-140) filters out missing UUIDs, calling getStatuses with non-existent UUIDs will silently omit them from the result. This behavior should be tested and documented.

🧪 Proposed additional test case
`@Test`
void testGetStatusesWithMixedExistingAndNonExistingUuids() {
    UUID existingUuid = UUID.randomUUID();
    UUID nonExistingUuid = UUID.randomUUID();
    computationService.setStatus(List.of(existingUuid), MockComputationStatus.RUNNING);

    Map<UUID, MockComputationStatus> statuses = computationService.getStatuses(List.of(existingUuid, nonExistingUuid));

    assertThat(statuses).hasSize(1);
    assertThat(statuses).containsEntry(existingUuid, MockComputationStatus.RUNNING);
    assertThat(statuses).doesNotContainKey(nonExistingUuid);
}
🤖 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/computation/ComputationTest.java` around lines
389 - 399, Add a new unit test named
testGetStatusesWithMixedExistingAndNonExistingUuids that calls
computationService.getStatuses with one UUID that was set via
computationService.setStatus and one random UUID that was not set, then assert
the returned Map contains only the existing UUID entry (use
assertThat(...).hasSize(1) and containsEntry(existingUuid,
MockComputationStatus.RUNNING)) and doesNotContainKey(nonExistingUuid); also
verify the call to resultService.findStatuses was made with the full list of
UUIDs to ensure the filtering behavior in getStatuses/resultService.findStatuses
is exercised.
🤖 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/computation/ComputationTest.java`:
- Around line 389-399: Add a new unit test named
testGetStatusesWithMixedExistingAndNonExistingUuids that calls
computationService.getStatuses with one UUID that was set via
computationService.setStatus and one random UUID that was not set, then assert
the returned Map contains only the existing UUID entry (use
assertThat(...).hasSize(1) and containsEntry(existingUuid,
MockComputationStatus.RUNNING)) and doesNotContainKey(nonExistingUuid); also
verify the call to resultService.findStatuses was made with the full list of
UUIDs to ensure the filtering behavior in getStatuses/resultService.findStatuses
is exercised.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 36447fd6-48bc-45aa-a97b-242dfd580523

📥 Commits

Reviewing files that changed from the base of the PR and between 735b23c and 306390e.

📒 Files selected for processing (1)
  • src/test/java/org/gridsuite/computation/ComputationTest.java

@sonarqubecloud

Copy link
Copy Markdown

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