Skip to content

Fix BasicRequestsTest.testReadSelectPartial for nesting-preserving field projection#650

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/commons-error
Jun 11, 2026
Merged

Fix BasicRequestsTest.testReadSelectPartial for nesting-preserving field projection#650
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/commons-error

Conversation

@vharseko

Copy link
Copy Markdown
Member

Summary

After the commons change OpenIdentityPlatform/commons@3bb9a67 that makes Resources.filterResource preserve the
nested structure of requested fields (see OpenIDM discussion
#183), the
opendj-rest2ldap test BasicRequestsTest.testReadSelectPartial started
failing. This PR updates the test assertions to match the corrected,
nesting-preserving projection behavior.

Background

Previously, Resources.filterResource(JsonValue, Collection<JsonPointer>)
collapsed a nested pointer (e.g. name/surname) to its leaf name, producing a
flat result like { "surname": "user 1" }. The commons fix now writes each
requested pointer back under its full path via JsonValue.putPermissive(...),
so the same read returns:

{ "name": { "surname": "user 1" } }

Problem

testReadSelectPartial still asserted the old flattening behavior and failed
with:

java.lang.AssertionError: <{'surname'='user 1'}> should be null
    at org.forgerock.opendj.rest2ldap.BasicRequestsTest.testReadSelectPartial(BasicRequestsTest.java:808)

This is not a regression in production code — the test was encoding the very
behavior that the commons fix corrected.

Changes

Updated the assertions in testReadSelectPartial
(opendj-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/BasicRequestsTest.java)
to reflect the nesting-preserving projection:

  • get("name").asMap() is now expected to be non-null.
  • The value is read via the nested path name/surname ("user 1").
  • The top-level surname field is now expected to be null.

No production code was changed.

Testing

mvn -pl opendj-rest2ldap test -Dtest=BasicRequestsTest

All 57 tests in BasicRequestsTest pass.

…eld projection

Resources.filterResource now preserves the nested structure of requested
JsonPointers instead of collapsing them to their leaf names (see commons fix
for OpenIDM discussion OpenIdentityPlatform#183). As a result, projecting "/name/surname" over a
resource returns { "name": { "surname": "user 1" } } rather than the previously
flattened { "surname": "user 1" }.

testReadSelectPartial still asserted the old flattening behavior and started
failing with "<{'surname'='user 1'}> should be null". Update the assertions to
match the corrected, nesting-preserving projection:

- expect get("name") to be a non-null map
- read the value via the nested path name/surname ("user 1")
- expect the top-level "surname" field to be null

No production code changes; this aligns the test with the fixed
Resources.filterResource semantics.
@vharseko vharseko requested a review from maximthomas June 11, 2026 10:01
@vharseko vharseko merged commit 07496aa into OpenIdentityPlatform:master Jun 11, 2026
7 of 17 checks passed
@vharseko vharseko deleted the issues/commons-error branch June 11, 2026 11:50
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