Skip to content

Remove directory server dependency#193

Merged
antoinebhs merged 5 commits into
mainfrom
remove-directory-server-dependency
May 12, 2026
Merged

Remove directory server dependency#193
antoinebhs merged 5 commits into
mainfrom
remove-directory-server-dependency

Conversation

@carojeandat
Copy link
Copy Markdown
Contributor

PR Summary

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

The PR removes the DirectoryService and its ElementAttributes DTO, simplifies the /filters/infos endpoint to drop the userId header, updates FilterService to accept only filterUuids, and changes cycle reporting to use UUID chains. Local directory-server config and directory-related test stubs/assertions were removed.

Changes

Filter service + API refactor

Layer / File(s) Summary
Data Shape / DTO removal
src/main/java/org/gridsuite/filter/server/dto/ElementAttributes.java
Deleted ElementAttributes record used for directory responses.
Core Implementation
src/main/java/org/gridsuite/filter/server/FilterService.java
Removed DirectoryService dependency; changed getFiltersAttributes(List<UUID>, String)getFiltersAttributes(List<UUID>); replaced name-based cycle reporting with getCyclicFilterIds(...) that emits UUID chains; removed directory lookups and related fallback logic.
Controller / API contract
src/main/java/org/gridsuite/filter/server/FilterController.java
Changed /filters/infos GET signature to drop the userId @RequestHeader; now calls service with only filterUuids.
Deleted service implementation
src/main/java/org/gridsuite/filter/server/service/DirectoryService.java
Removed entire DirectoryService class, its constants, REST client usage, and getElementsName(...) method.
Configuration
src/main/resources/application-local.yaml
Removed gridsuite.services.directory-server.base-uri local configuration entry.
Tests
src/test/java/org/gridsuite/filter/server/FilterEntityControllerTest.java, src/test/java/org/gridsuite/filter/server/FilterServiceTest.java
Removed WireMock/DirectoryService stubbing and assertions about resolved names; updated FilterService tests and helpers to assert UUID-based cycle reporting; controller test no longer asserts FilterAttributes.name values.

Suggested reviewers

  • thangqp
  • antoinebhs
🚥 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 The pull request description contains only a placeholder template with no actual descriptive content about the changes or their purpose. Provide a meaningful description explaining the changes, their motivation, and any important context for reviewers to understand the rationale for removing the directory server dependency.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: removing the directory server dependency from the filter server, which is the primary objective reflected in all file 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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/java/org/gridsuite/filter/server/FilterService.java (1)

69-72: Use a Set for missing-UUID lookup to avoid quadratic scans.

foundUuids.contains(...) on a List makes the missing-ID pass O(n*m). Converting to a Set keeps this efficient for larger batches.

♻️ Proposed refactor
-            List<UUID> foundUuids = filterAttributes.stream().map(FilterAttributes::getId).toList();
-            List<UUID> notFoundUuids = filterUuids.stream().filter(filterUuid -> !foundUuids.contains(filterUuid)).toList();
+            Set<UUID> foundUuids = filterAttributes.stream()
+                .map(FilterAttributes::getId)
+                .collect(Collectors.toSet());
+            List<UUID> notFoundUuids = filterUuids.stream()
+                .filter(filterUuid -> !foundUuids.contains(filterUuid))
+                .toList();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/gridsuite/filter/server/FilterService.java` around lines 69
- 72, The current missing-UUID detection in FilterService uses a List
(foundUuids) and calls foundUuids.contains(...) inside the filterUuids stream,
causing O(n*m) behavior; change the intermediate collection to a Set for O(1)
lookups: build a Set<UUID> (e.g., foundUuidSet from
filterAttributes.stream().map(FilterAttributes::getId)) and then compute
notFoundUuids by filtering filterUuids with !foundUuidSet.contains(uuid) (keep
the variable names filterAttributes, filterUuids, notFoundUuids, and use
FilterAttributes::getId to locate the mapping).
🤖 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/test/java/org/gridsuite/filter/server/FilterServiceTest.java`:
- Line 47: Rename the test method getCyclicFilterNamesUsesResolvedIdsAndIds to
reflect ID-based behavior (for example getCyclicFilterIdsUsesResolvedIdsAndIds
or getCyclicFilterChainIdsUsesResolvedIdsAndIds), update the method declaration
and any references/annotations/usages in FilterServiceTest so the name matches
that assertions validate UUID chain formatting, and run the test suite to ensure
there are no remaining references to the old method name.
- Line 43: The test FilterServiceTest constructs filterService with potentially
null collaborators because the `@Mock` fields are never initialized; add explicit
mock initialization by calling MockitoAnnotations.openMocks(this) in a
`@BeforeEach` method (or replace field `@Mock` annotations with Spring `@MockBean`) so
repositoryService, networkStoreService, and notificationService are non-null
when used in the FilterService constructor; also consider renaming the test
method invokeGetCyclicFilterNames to invokeGetCyclicFilterIds to match its
ID-based behavior.

---

Nitpick comments:
In `@src/main/java/org/gridsuite/filter/server/FilterService.java`:
- Around line 69-72: The current missing-UUID detection in FilterService uses a
List (foundUuids) and calls foundUuids.contains(...) inside the filterUuids
stream, causing O(n*m) behavior; change the intermediate collection to a Set for
O(1) lookups: build a Set<UUID> (e.g., foundUuidSet from
filterAttributes.stream().map(FilterAttributes::getId)) and then compute
notFoundUuids by filtering filterUuids with !foundUuidSet.contains(uuid) (keep
the variable names filterAttributes, filterUuids, notFoundUuids, and use
FilterAttributes::getId to locate the mapping).
🪄 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: 0fec1c05-1aba-456e-b924-a0b4185ff91c

📥 Commits

Reviewing files that changed from the base of the PR and between c6296e4 and 87152d2.

📒 Files selected for processing (7)
  • src/main/java/org/gridsuite/filter/server/FilterController.java
  • src/main/java/org/gridsuite/filter/server/FilterService.java
  • src/main/java/org/gridsuite/filter/server/dto/ElementAttributes.java
  • src/main/java/org/gridsuite/filter/server/service/DirectoryService.java
  • src/main/resources/application-local.yaml
  • src/test/java/org/gridsuite/filter/server/FilterEntityControllerTest.java
  • src/test/java/org/gridsuite/filter/server/FilterServiceTest.java
💤 Files with no reviewable changes (4)
  • src/main/java/org/gridsuite/filter/server/dto/ElementAttributes.java
  • src/main/resources/application-local.yaml
  • src/test/java/org/gridsuite/filter/server/FilterEntityControllerTest.java
  • src/main/java/org/gridsuite/filter/server/service/DirectoryService.java

@BeforeEach
void setUp() {
filterService = new FilterService(repositoryService, networkStoreService, notificationService, directoryService);
filterService = new FilterService(repositoryService, networkStoreService, notificationService);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="$(fd -a 'FilterServiceTest.java' | head -n1)"
echo "Inspecting: $FILE"

# Show test wiring annotations and mock initialization patterns
rg -n '@SpringBootTest|@Mock\b|@MockBean\b|@ExtendWith|MockitoAnnotations\.openMocks|MockitoExtension' "$FILE"

Repository: gridsuite/filter-server

Length of output: 220


🏁 Script executed:

cat -n /home/jailuser/git/src/test/java/org/gridsuite/filter/server/FilterServiceTest.java | sed -n '25,55p'

Repository: gridsuite/filter-server

Length of output: 1169


🏁 Script executed:

rg -n 'MockitoAnnotations|@ExtendWith|@BeforeAll|@BeforeClass' /home/jailuser/git/src/test/java/org/gridsuite/filter/server/FilterServiceTest.java

Repository: gridsuite/filter-server

Length of output: 49


🏁 Script executed:

cat -n /home/jailuser/git/src/test/java/org/gridsuite/filter/server/FilterServiceTest.java | sed -n '47,75p'

Repository: gridsuite/filter-server

Length of output: 1522


Mock collaborators are uninitialized in this test setup.

The @Mock fields lack proper initialization under @SpringBootTest: there is no @ExtendWith(MockitoExtension.class), no MockitoAnnotations.openMocks() call, and no @MockBean annotation. Line 43 passes potentially null parameters to the FilterService constructor, creating brittle test wiring. The test passes only because the current assertions never invoke methods on these collaborators. Initialize mocks explicitly via MockitoAnnotations.openMocks() in a @BeforeEach method or use Spring @MockBean annotations to ensure stable test behavior.

As a secondary note, the test method name at line 47 references "Names" but the test behavior is ID-based (invokeGetCyclicFilterIds); consider renaming for clarity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/gridsuite/filter/server/FilterServiceTest.java` at line 43,
The test FilterServiceTest constructs filterService with potentially null
collaborators because the `@Mock` fields are never initialized; add explicit mock
initialization by calling MockitoAnnotations.openMocks(this) in a `@BeforeEach`
method (or replace field `@Mock` annotations with Spring `@MockBean`) so
repositoryService, networkStoreService, and notificationService are non-null
when used in the FilterService constructor; also consider renaming the test
method invokeGetCyclicFilterNames to invokeGetCyclicFilterIds to match its
ID-based behavior.

Comment thread src/test/java/org/gridsuite/filter/server/FilterServiceTest.java Outdated
Comment thread src/test/java/org/gridsuite/filter/server/FilterServiceTest.java Outdated
Co-authored-by: carojeandat <112859659+carojeandat@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

Comment thread src/test/java/org/gridsuite/filter/server/FilterServiceTest.java Outdated
public List<FilterAttributes> getFiltersAttributes(List<UUID> filterUuids, String userId) {
public List<FilterAttributes> getFiltersAttributes(List<UUID> filterUuids) {
List<FilterAttributes> filterAttributes = this.repositoriesService.getFiltersAttributes(filterUuids).collect(Collectors.toList());
// call directory server to add name information
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

may be done in a next PR to avoid complexity in this ticket

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Co-authored-by: Thang PHAM <117309322+thangqp@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/test/java/org/gridsuite/filter/server/FilterServiceTest.java (1)

72-75: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Unsafe Throwable → Exception cast will mask Error failures with a ClassCastException.

If the reflected invocation ever throws an Error subtype (e.g., AssertionError, OutOfMemoryError), targetException.getCause() returns a Throwable, and (Exception) cause will itself throw a ClassCastException, hiding the original failure entirely.

🐛 Proposed fix
         } catch (InvocationTargetException targetException) {
             Throwable cause = targetException.getCause();
-            throw (Exception) cause;
+            if (cause instanceof Exception e) {
+                throw e;
+            }
+            throw new RuntimeException("Unexpected Error from reflected invocation", cause);
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/gridsuite/filter/server/FilterServiceTest.java` around
lines 72 - 75, In the catch for InvocationTargetException in FilterServiceTest,
avoid casting the Throwable from targetException.getCause() directly to
Exception; instead check the cause: if it's an Exception rethrow it, if it's an
Error rethrow it as an Error, otherwise wrap the Throwable in a new Exception
and throw that (use the symbols InvocationTargetException,
targetException.getCause(), and the test method in FilterServiceTest to locate
the catch block).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/test/java/org/gridsuite/filter/server/FilterServiceTest.java`:
- Around line 72-75: In the catch for InvocationTargetException in
FilterServiceTest, avoid casting the Throwable from targetException.getCause()
directly to Exception; instead check the cause: if it's an Exception rethrow it,
if it's an Error rethrow it as an Error, otherwise wrap the Throwable in a new
Exception and throw that (use the symbols InvocationTargetException,
targetException.getCause(), and the test method in FilterServiceTest to locate
the catch block).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ec7a3934-dccf-4fd8-8991-c80d8cea537e

📥 Commits

Reviewing files that changed from the base of the PR and between 87152d2 and e4bd5a0.

📒 Files selected for processing (1)
  • src/test/java/org/gridsuite/filter/server/FilterServiceTest.java

Copy link
Copy Markdown
Contributor

@antoinebhs antoinebhs left a comment

Choose a reason for hiding this comment

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

lgtm

@antoinebhs antoinebhs merged commit bb5e3fc into main May 12, 2026
5 checks passed
@antoinebhs antoinebhs deleted the remove-directory-server-dependency branch May 12, 2026 13:43
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.

3 participants