Skip to content

[NAE 2441] Event permissions test - #449

Merged
mazarijuraj merged 6 commits into
release/6.5.0from
NAE-2441
Jun 12, 2026
Merged

[NAE 2441] Event permissions test#449
mazarijuraj merged 6 commits into
release/6.5.0from
NAE-2441

Conversation

@SamuelPalaj

@SamuelPalaj SamuelPalaj commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

  • rework of case search query building in CaseSearchService
  • removed mongo search endpoints mongo_search and search2 from WorkflowController
  • added tests and test nets for create, delete and view case permissions in CasePermissionsTest
  • added tests and test nets for assign, cancel and delete task permissions in TaskPermissionsTest

Implements NAE-2441

Blocking Pull requests

Depends on #442

How Has Been This Tested?

Tests included in test files TaskPermissionsTest and CasePermissionsTest

Name Tested on
OS windows 11
Runtime java 11
Dependency Manager Maven 3.9.9
Framework version Spring Boot 2.7.18
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @...
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

Release Notes

  • Deprecated Features

    • Removed legacy case search endpoints: /api/workflow/case/search2 (QueryDSL-based) and /api/workflow/case/search_mongo (Mongo-based). All case searches now use the unified Elasticsearch endpoint.
  • Tests

    • Added comprehensive permission validation tests for case and task operations across multiple permission scenarios.

- rework of case search query building in CaseSearchService
- removed mongo search endpoints mongo_search and search2 from WorkflowController
- added tests and test nets for create, delete and view case permissions in CasePermissionsTest
- added tests and test nets for assign, cancel and delete task permissions in TaskPermissionsTest
@SamuelPalaj SamuelPalaj self-assigned this Jun 4, 2026
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR refactors permission-based query filtering in case search, removes two legacy search endpoints, and adds comprehensive permission regression test suites with 150+ Petri net test fixture files validating permission behavior across case creation/deletion/viewing and task assignment/finishing/cancellation across default-enabled and default-disabled modes.

Changes

Permission Refactor and Comprehensive Regression Coverage

Layer / File(s) Summary
Search filtering and permission constraint refactoring
src/main/java/com/netgrif/application/engine/workflow/web/WorkflowController.java, src/main/java/com/netgrif/application/engine/workflow/service/LegacyCaseSearchService.java, src/test/groovy/com/netgrif/application/engine/elastic/DataSearchRequestTest.groovy, src/test/resources/petriNets/impersonation_test.xml
LegacyCaseSearchService consolidates search predicates into OR trees before applying permission constraints via AND; view-role and view-user matching are simplified to direct containment checks; role-based Petri net filtering is removed. WorkflowController removes search2 (QueryDSL) and searchMongo (Mongo) endpoints. DataSearchRequestTest updates logged user context; impersonation_test.xml adds view permission to test role.
Case permission integration test suite and fixtures
src/test/groovy/com/netgrif/application/engine/workflow/CasePermissionsTest.groovy, src/test/resources/petriNets/permissions/case/default/*, src/test/resources/petriNets/permissions/case/defaultDisabled/*
CasePermissionsTest validates create, delete, and view permissions using CSV-driven expected-permission maps for both default-enabled and default-disabled modes. Covers 81 case permission scenarios (9 role/default/user combinations × 3 permission types, across 2 default role states); includes role assignment, HTTP request execution, and search-based permission resolution helpers.
Task permission integration test suite and fixtures
src/test/groovy/com/netgrif/application/engine/workflow/TaskPermissionsTest.groovy, src/test/resources/petriNets/permissions/{assign,cancel,finish,view}_permission_combinations*.xml
TaskPermissionsTest validates view, assign, finish, and cancel permissions via Elasticsearch and Mongo search APIs; includes per-endpoint permission checks (assign/finish/cancel via HTTP GET). Covers 27 transition-permission combinations per action type in both default-enabled and default-disabled modes; provides CSV-driven expected-permission sets and per-user/permission assertion helpers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Title check ❓ Inconclusive The title '[NAE 2441] Event permissions test' is vague and does not clearly convey the main changes in the pull request, which include removing deprecated search endpoints and comprehensive permission testing. Consider a more descriptive title such as 'NAE-2441: Add comprehensive permission tests and remove legacy search endpoints' to better reflect the scope and primary objectives of the changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

@coderabbitai coderabbitai Bot added improvement A change that improves on an existing feature breaking change Fix or feature that would cause existing functionality doesn't work as expected Large Medium labels Jun 4, 2026

@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: 2

🤖 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/groovy/com/netgrif/application/engine/workflow/CasePermissionsTest.groovy`:
- Line 311: The FileInputStream created inline in the PetriNet import call is
never closed; update the code in CasePermissionsTest so that the stream passed
to petriNetService.importPetriNet is opened into a local InputStream variable
and closed reliably (use try-with-resources or try/finally) around the call to
petriNetService.importPetriNet(...) so each testNet file's stream is closed
after import; reference the petriNetService.importPetriNet(...) invocation and
ensure the InputStream is closed even when import throws.

In
`@src/test/groovy/com/netgrif/application/engine/workflow/TaskPermissionsTest.groovy`:
- Line 455: The current assertion in TaskPermissionsTest.groovy uses a compound
boolean that obscures which size comparison failed; change it to clearer
assertions by either replacing the single assertTrue(...) with two assertEquals
calls comparing presentInBoth.size() to actualTransitionIds.size() and
presentInBoth.size() to expectedTransitionIds.size(), or keep a single assertion
but add a descriptive message that states the expected and actual sizes
(referencing presentInBoth, actualTransitionIds, expectedTransitionIds) so
failures indicate which comparison broke.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 92b9850e-8337-43a9-86ea-d2f6d10d66d1

📥 Commits

Reviewing files that changed from the base of the PR and between 7dabfe9 and a2e1a98.

⛔ Files ignored due to path filters (4)
  • src/test/resources/csv/create case permissions - correct default disabled.csv is excluded by !**/*.csv
  • src/test/resources/csv/create case permissions - correct.csv is excluded by !**/*.csv
  • src/test/resources/csv/permissions - correct default disabled.csv is excluded by !**/*.csv
  • src/test/resources/csv/permissions - correct.csv is excluded by !**/*.csv
📒 Files selected for processing (104)
  • src/main/java/com/netgrif/application/engine/elastic/service/ElasticTaskService.java
  • src/main/java/com/netgrif/application/engine/elastic/service/ElasticViewPermissionService.java
  • src/main/java/com/netgrif/application/engine/importer/service/Importer.java
  • src/main/java/com/netgrif/application/engine/workflow/domain/Case.java
  • src/main/java/com/netgrif/application/engine/workflow/domain/Task.java
  • src/main/java/com/netgrif/application/engine/workflow/service/CaseSearchService.java
  • src/main/java/com/netgrif/application/engine/workflow/service/TaskSearchService.java
  • src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java
  • src/main/java/com/netgrif/application/engine/workflow/service/WorkflowService.java
  • src/main/java/com/netgrif/application/engine/workflow/web/WorkflowController.java
  • src/test/groovy/com/netgrif/application/engine/workflow/CasePermissionsTest.groovy
  • src/test/groovy/com/netgrif/application/engine/workflow/TaskPermissionsTest.groovy
  • src/test/resources/petriNets/permissions/assign_permission_combinations.xml
  • src/test/resources/petriNets/permissions/assign_permission_combinations_no_default.xml
  • src/test/resources/petriNets/permissions/cancel_permission_combinations.xml
  • src/test/resources/petriNets/permissions/cancel_permission_combinations_no_default.xml
  • src/test/resources/petriNets/permissions/case/default/create/create_case_role_false_default_false.xml
  • src/test/resources/petriNets/permissions/case/default/create/create_case_role_false_default_true.xml
  • src/test/resources/petriNets/permissions/case/default/create/create_case_role_false_default_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/create/create_case_role_true_default_false.xml
  • src/test/resources/petriNets/permissions/case/default/create/create_case_role_true_default_true.xml
  • src/test/resources/petriNets/permissions/case/default/create/create_case_role_true_default_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/create/create_case_role_undefined_default_false.xml
  • src/test/resources/petriNets/permissions/case/default/create/create_case_role_undefined_default_true.xml
  • src/test/resources/petriNets/permissions/case/default/create/create_case_role_undefined_default_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_false_default_false_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_false_default_false_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_false_default_false_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_false_default_true_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_false_default_true_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_false_default_true_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_false_default_undefined_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_false_default_undefined_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_false_default_undefined_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_true_default_false_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_true_default_false_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_true_default_false_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_true_default_true_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_true_default_true_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_true_default_true_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_true_default_undefined_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_true_default_undefined_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_true_default_undefined_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_undefined_default_false_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_undefined_default_false_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_undefined_default_false_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_undefined_default_true_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_undefined_default_true_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_undefined_default_true_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_undefined_default_undefined_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_undefined_default_undefined_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/delete/delete_case_role_undefined_default_undefined_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_false_default_false_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_false_default_false_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_false_default_false_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_false_default_true_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_false_default_true_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_false_default_true_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_false_default_undefined_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_false_default_undefined_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_false_default_undefined_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_true_default_false_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_true_default_false_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_true_default_false_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_true_default_true_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_true_default_true_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_true_default_true_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_true_default_undefined_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_true_default_undefined_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_true_default_undefined_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_undefined_default_false_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_undefined_default_false_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_undefined_default_false_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_undefined_default_true_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_undefined_default_true_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_undefined_default_true_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_undefined_default_undefined_user_false.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_undefined_default_undefined_user_true.xml
  • src/test/resources/petriNets/permissions/case/default/view/view_case_role_undefined_default_undefined_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/create/create_case_role_false.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/create/create_case_role_true.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/create/create_case_role_undefined.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/delete/delete_case_role_false_user_false.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/delete/delete_case_role_false_user_true.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/delete/delete_case_role_false_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/delete/delete_case_role_true_user_false.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/delete/delete_case_role_true_user_true.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/delete/delete_case_role_true_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/delete/delete_case_role_undefined_user_false.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/delete/delete_case_role_undefined_user_true.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/delete/delete_case_role_undefined_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/view/view_case_role_false_user_false.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/view/view_case_role_false_user_true.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/view/view_case_role_false_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/view/view_case_role_true_user_false.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/view/view_case_role_true_user_true.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/view/view_case_role_true_user_undefined.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/view/view_case_role_undefined_user_false.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/view/view_case_role_undefined_user_true.xml
  • src/test/resources/petriNets/permissions/case/defaultDisabled/view/view_case_role_undefined_user_undefined.xml
  • src/test/resources/petriNets/permissions/finish_permission_combinations.xml
  • src/test/resources/petriNets/permissions/finish_permission_combinations_no_default.xml
  • src/test/resources/petriNets/permissions/view_permission_combinations.xml
  • src/test/resources/petriNets/permissions/view_permission_combinations_no_default.xml
💤 Files with no reviewable changes (2)
  • src/main/java/com/netgrif/application/engine/workflow/web/WorkflowController.java
  • src/main/java/com/netgrif/application/engine/elastic/service/ElasticTaskService.java

println("Present only in test results (${presentOnlyInMap.size()}): ${presentOnlyInMap}")
println("Present only in correct results (${presentOnlyInCorrectResultsWithDefaultRoleMap.size()}): ${presentOnlyInCorrectResultsWithDefaultRoleMap}")

assertTrue(presentInBoth.size() == actualTransitionIds.size() && presentInBoth.size() == expectedTransitionIds.size())

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 | 🔵 Trivial | ⚡ Quick win

Consider adding a descriptive assertion message.

The compound boolean condition makes it harder to diagnose failures. Consider using separate assertEquals calls or adding a descriptive message to explain which comparison failed.

♻️ Proposed improvement
-                assertTrue(presentInBoth.size() == actualTransitionIds.size() && presentInBoth.size() == expectedTransitionIds.size())
+                assertEquals(expectedTransitionIds.size(), actualTransitionIds.size(), 
+                    "Mismatch in transition count for user ${userEmail} ${defaultRoleKey}: expected ${expectedTransitionIds.size()}, got ${actualTransitionIds.size()}")
+                assertEquals(expectedTransitionIds, actualTransitionIds,
+                    "Transition ID mismatch for user ${userEmail} ${defaultRoleKey}")
🤖 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/groovy/com/netgrif/application/engine/workflow/TaskPermissionsTest.groovy`
at line 455, The current assertion in TaskPermissionsTest.groovy uses a compound
boolean that obscures which size comparison failed; change it to clearer
assertions by either replacing the single assertTrue(...) with two assertEquals
calls comparing presentInBoth.size() to actualTransitionIds.size() and
presentInBoth.size() to expectedTransitionIds.size(), or keep a single assertion
but add a descriptive message that states the expected and actual sizes
(referencing presentInBoth, actualTransitionIds, expectedTransitionIds) so
failures indicate which comparison broke.

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

Caution

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

⚠️ Outside diff range comments (2)
src/test/groovy/com/netgrif/application/engine/workflow/CasePermissionsTest.groovy (2)

327-329: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add null check to prevent cryptic NPE when role is missing.

If a test Petri net doesn't define a role with importId == "process_role", find returns null and the subsequent .stringId call throws an NPE without context.

🛡️ Proposed fix
 void assignRoleToUser(PetriNet net, IUser user) {
-    testUsers.put(user.email, userService.addRole(user, net.roles.values().find { role -> role.importId == "process_role" }.stringId))
+    def role = net.roles.values().find { it.importId == "process_role" }
+    if (role == null) {
+        throw new IllegalStateException("PetriNet '${net.identifier}' is missing required role with importId='process_role'")
+    }
+    testUsers.put(user.email, userService.addRole(user, role.stringId))
 }
🤖 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/groovy/com/netgrif/application/engine/workflow/CasePermissionsTest.groovy`
around lines 327 - 329, The method assignRoleToUser currently calls
net.roles.values().find { role -> role.importId == "process_role" }.stringId
which will NPE if no role is found; modify assignRoleToUser to first assign the
result of the find to a local variable (e.g., foundRole), check for null, and
either throw an informative IllegalStateException (or IllegalArgumentException)
naming the missing "process_role" and the PetriNet id/name, or handle the
missing role gracefully before calling userService.addRole and putting into
testUsers; update references to use foundRole.stringId only after the null
check.

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

Add descriptive assertion message for easier debugging.

When this assertion fails in CI, there's no indication of which user or scenario failed. The diagnostic println statements above help, but the assertion message itself should include context.

🔧 Proposed fix
-                assertTrue(presentInBoth.size() == actualNetIdentifiersIds.size() && presentInBoth.size() == expectedNetIdentifiers.size())
+                assertTrue(
+                    presentInBoth.size() == actualNetIdentifiersIds.size() && presentInBoth.size() == expectedNetIdentifiers.size(),
+                    "Mismatch for user '${userEmail}' [${defaultRoleKey}]: unexpected=${presentOnlyInMap}, missing=${presentOnlyInCorrectResultsWithDefaultRoleMap}"
+                )
🤖 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/groovy/com/netgrif/application/engine/workflow/CasePermissionsTest.groovy`
at line 440, Replace the bare assertion on the three collections with one that
includes a descriptive failure message: update the assertion that currently
references presentInBoth, actualNetIdentifiersIds and expectedNetIdentifiers to
include context (e.g., the tested user/role or test scenario) and the
sizes/contents of those collections so CI failures show which user/scenario and
what values mismatched; locate the assertion line using the variables
presentInBoth, actualNetIdentifiersIds, and expectedNetIdentifiers in
CasePermissionsTest and augment it with a clear message that prints the relevant
identifiers and sizes.
🤖 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.

Outside diff comments:
In
`@src/test/groovy/com/netgrif/application/engine/workflow/CasePermissionsTest.groovy`:
- Around line 327-329: The method assignRoleToUser currently calls
net.roles.values().find { role -> role.importId == "process_role" }.stringId
which will NPE if no role is found; modify assignRoleToUser to first assign the
result of the find to a local variable (e.g., foundRole), check for null, and
either throw an informative IllegalStateException (or IllegalArgumentException)
naming the missing "process_role" and the PetriNet id/name, or handle the
missing role gracefully before calling userService.addRole and putting into
testUsers; update references to use foundRole.stringId only after the null
check.
- Line 440: Replace the bare assertion on the three collections with one that
includes a descriptive failure message: update the assertion that currently
references presentInBoth, actualNetIdentifiersIds and expectedNetIdentifiers to
include context (e.g., the tested user/role or test scenario) and the
sizes/contents of those collections so CI failures show which user/scenario and
what values mismatched; locate the assertion line using the variables
presentInBoth, actualNetIdentifiersIds, and expectedNetIdentifiers in
CasePermissionsTest and augment it with a clear message that prints the relevant
identifiers and sizes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4240f34a-643e-4fc0-a63f-506aabc4df7a

📥 Commits

Reviewing files that changed from the base of the PR and between a2e1a98 and 5d31f4b.

📒 Files selected for processing (1)
  • src/test/groovy/com/netgrif/application/engine/workflow/CasePermissionsTest.groovy

@Retoocs

Retoocs commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

there are test failures

2026-06-04T10:57:25.4542513Z [INFO] Results:
2026-06-04T10:57:25.4542854Z [INFO] 
2026-06-04T10:57:25.4544238Z [ERROR] Failures: 
2026-06-04T10:57:25.4551310Z [ERROR]   DataSearchRequestTest.testDatSearchRequests:230 assert result.size() == 1
2026-06-04T10:57:25.4551807Z        |      |      |
2026-06-04T10:57:25.4552036Z        |      0      false
2026-06-04T10:57:25.4552538Z        Page 1 of 0 containing UNKNOWN instances
2026-06-04T10:57:25.4553126Z [ERROR]   ReindexTest.reindexTest:85 assert result.size() == 1
2026-06-04T10:57:25.4553799Z        |      |      |
2026-06-04T10:57:25.4554024Z        []     0      false
2026-06-04T10:57:25.4554802Z [ERROR]   ImpersonationServiceTest.testTaskSearchAssignFinish:213 assert !cases.content.isEmpty()
2026-06-04T10:57:25.4555297Z        ||     |       |
2026-06-04T10:57:25.4555689Z        ||     []      true
2026-06-04T10:57:25.4556013Z        |Page 1 of 0 containing UNKNOWN instances
2026-06-04T10:57:25.4556309Z        false
2026-06-04T10:57:25.4556510Z [INFO] 
2026-06-04T10:57:25.4557080Z [ERROR] Tests run: 423, Failures: 3, Errors: 0, Skipped: 32

mazarijuraj
mazarijuraj previously approved these changes Jun 5, 2026
@SamuelPalaj
SamuelPalaj dismissed mazarijuraj’s stale review June 5, 2026 08:20

The merge-base changed after approval.

@Retoocs Retoocs mentioned this pull request Jun 9, 2026
18 tasks
Kovy95
Kovy95 previously approved these changes Jun 10, 2026
# Conflicts:
#	src/main/java/com/netgrif/application/engine/workflow/service/LegacyCaseSearchService.java

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

Caution

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

⚠️ Outside diff range comments (1)
src/main/java/com/netgrif/application/engine/workflow/service/LegacyCaseSearchService.java (1)

59-82: ⚠️ Potential issue | 🟠 Major

Filter out null predicates before calling constructPredicateTree in LegacyCaseSearchService#buildQuery.

  • buildQuery() unconditionally does singleQueries.add(...) for predicates like petriNet(), author(), transition(), fullText(), role(), data(), tags(), caseId(), while several of these methods can return null (e.g., fullText() returns null when petriNets is empty, and petriNet()/author()/transition()/role()/caseId() return null on unsupported input types).
  • MongoSearchService#constructPredicateTree() builds each subtree with new BooleanBuilder(predicateIterator.next()) and has no null handling, so a null element in the list is unsafe.
  • Either guard/filter singleQueries to remove nulls (or return early) before calling constructPredicateTree (similar to LegacyTaskSearchService).
🤖 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/com/netgrif/application/engine/workflow/service/LegacyCaseSearchService.java`
around lines 59 - 82, In buildQuery replace the unconditional
singleQueries.add(...) pattern with null-safe behavior: either only add
predicates when the returned value is non-null (check result of petriNet(...),
author(...), transition(...), fullText(...), role(...), data(...), tags(...),
caseId(...)) or, after populating singleQueries, call
singleQueries.removeIf(Objects::isNull) (or return early if empty) before
passing it to MongoSearchService.constructPredicateTree; follow the same
null-filtering approach used in LegacyTaskSearchService so
constructPredicateTree never receives null elements.
🤖 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.

Outside diff comments:
In
`@src/main/java/com/netgrif/application/engine/workflow/service/LegacyCaseSearchService.java`:
- Around line 59-82: In buildQuery replace the unconditional
singleQueries.add(...) pattern with null-safe behavior: either only add
predicates when the returned value is non-null (check result of petriNet(...),
author(...), transition(...), fullText(...), role(...), data(...), tags(...),
caseId(...)) or, after populating singleQueries, call
singleQueries.removeIf(Objects::isNull) (or return early if empty) before
passing it to MongoSearchService.constructPredicateTree; follow the same
null-filtering approach used in LegacyTaskSearchService so
constructPredicateTree never receives null elements.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 63be1915-58c9-479c-ade0-3ef4c3ade5d5

📥 Commits

Reviewing files that changed from the base of the PR and between 5d31f4b and 5c2a0eb.

📒 Files selected for processing (3)
  • src/main/java/com/netgrif/application/engine/workflow/service/LegacyCaseSearchService.java
  • src/test/groovy/com/netgrif/application/engine/elastic/DataSearchRequestTest.groovy
  • src/test/resources/petriNets/impersonation_test.xml

@mazarijuraj
mazarijuraj self-requested a review June 12, 2026 06:18
@mazarijuraj
mazarijuraj merged commit 29129f9 into release/6.5.0 Jun 12, 2026
5 of 7 checks passed
@mazarijuraj
mazarijuraj deleted the NAE-2441 branch June 12, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Fix or feature that would cause existing functionality doesn't work as expected improvement A change that improves on an existing feature Large Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants