Skip to content

WW-4858 Cover nested-leaf accepted-name and include patterns in JSON filtering#1783

Merged
lukaszlenart merged 1 commit into
mainfrom
WW-4858-nested-leaf-filter-tests
Jul 14, 2026
Merged

WW-4858 Cover nested-leaf accepted-name and include patterns in JSON filtering#1783
lukaszlenart merged 1 commit into
mainfrom
WW-4858-nested-leaf-filter-tests

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Fixes WW-4858

What & why

Follow-up test coverage for the JSON parameter-filtering work in #1773. That PR
tested the flat-key cases and a nested excluded name pattern, but left the
nested-leaf behaviour of accepted-name and include patterns uncovered.
These two paths behave differently through JSONInterceptor's recursive
tree-walk, and the difference is easy to regress silently:

  • Accepted name patterns (AcceptedPatternsChecker) are raw full-match
    regexes with no hierarchy expansion. The intermediate node (bean) must
    itself match an accepted pattern, otherwise the entire subtree is dropped
    before the leaf (bean.stringField) is ever visited.
  • Include patterns (includeProperties, via JSONUtil.processIncludePatterns)
    do expand across the hierarchy: bean.stringField compiles patterns for
    both the intermediate bean and the leaf, so the nested leaf populates while
    the excluded sibling bean.intField is dropped.

Tests added (JSONInterceptorTest)

  • testAcceptedNamePatternRejectsNestedKey
  • testIncludePropertiesAppliedToNestedInputWhenEnabled

Both document the intermediate-node semantics in comments so the divergence is
explicit rather than surprising.

Testing

mvn test -pl plugins/json -DskipAssembly -Dtest=JSONInterceptorTest — 40 tests, all pass.

🤖 Generated with Claude Code

Add two tests to JSONInterceptorTest exercising the nested-object path for
the name/value filtering added in WW-4858:

- testAcceptedNamePatternRejectsNestedKey: accepted name patterns are raw
  full-match regexes with no hierarchy expansion, so the intermediate node
  ("bean") must itself match an accepted pattern or the whole subtree is
  dropped before the leaf is visited.
- testIncludePropertiesAppliedToNestedInputWhenEnabled: include patterns do
  expand across the hierarchy, so "bean.stringField" also matches the
  intermediate "bean" and the nested leaf populates while the excluded
  sibling "bean.intField" is dropped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@lukaszlenart lukaszlenart merged commit 40fcae3 into main Jul 14, 2026
10 checks passed
@lukaszlenart lukaszlenart deleted the WW-4858-nested-leaf-filter-tests branch July 14, 2026 11:31
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.

1 participant