You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SD-3207: Split TNT scenarios by party role (producer/consumer)
✨ Enhancement🕐 10-20 Minutes
AI Description
• Restructures TNT v3.0.0 scenario builder to assign scenarios per party role instead of a single
shared list.
• Producer gets POST scenarios plus GET query-parameter and pagination scenarios; consumer gets
POST/GET-by-type scenarios only.
• Only scenarios for the currently tested party roles (derived from getReportRoleNames) are
included in the generated conformance report.
• Introduces MapUtils.orderedMap helper to build ordered maps of scenario entries.
["enhancement", "refactor"]
Partitioning scenarios by role via a nested map and filtering by tested role names is a straightforward, low-risk approach consistent with existing patterns (getReportRoleNames is already used elsewhere in AbstractComponentFactory). No meaningfully better alternative was identified for this scope of change.
Files changed (2) +56 / -52
Enhancement (2) +56 / -52
TntComponentFactory.javaPass tested party role names into scenario list builder+1/-0
Pass tested party role names into scenario list builder
• createModuleScenarioListBuilders now calls getReportRoleNames to compute the set of tested party roles and forwards it into TntScenarioListBuilder.createModuleScenarioListBuilders so scenarios can be filtered per role.
TntScenarioListBuilder.javaSplit scenario list into producer and consumer specific maps+55/-52
Split scenario list into producer and consumer specific maps
• Reworks createModuleScenarioListBuilders to build a nested map of scenarios keyed by party role (producer/consumer) using the new MapUtils.orderedMap helper, then filters the returned scenarios to only the roles present in testedPartyRoleNames. Producer scenarios include POST, GET-by-type, query-parameter filter, and pagination scenarios; consumer scenarios include only POST and GET-by-type scenarios.
TntScenarioListBuilder.createModuleScenarioListBuilders() calls
scenarios.putAll(partyScenariosMap.get(role)) without handling unknown role names; if a role in
testedPartyRoleNames is not present in partyScenariosMap, this throws a NullPointerException during
scenario generation.
+ Map<String, TntScenarioListBuilder> scenarios = new LinkedHashMap<>();+ testedPartyRoleNames.forEach(role -> scenarios.putAll(partyScenariosMap.get(role)));+
Evidence
The scenario builder merges per-role maps using partyScenariosMap.get(role) without a null check,
and the role set is derived from configuration role strings in getReportRoleNames, so an
unsupported role string can reach this lookup and trigger an NPE.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`TntScenarioListBuilder.createModuleScenarioListBuilders` merges role-specific scenario maps via `scenarios.putAll(partyScenariosMap.get(role))` without guarding for missing keys. If `testedPartyRoleNames` contains any role name other than the two keys present in `partyScenariosMap` (Producer/Consumer), `partyScenariosMap.get(role)` returns `null` and `putAll(null)` throws a `NullPointerException`.
## Issue Context
`testedPartyRoleNames` is passed from `TntComponentFactory.getReportRoleNames(...)`, which derives role names from configuration and does not constrain them to the set of known TNT roles in the non-all-in-one case.
## Fix Focus Areas
- tnt/src/main/java/org/dcsa/conformance/standards/tnt/v300/TntScenarioListBuilder.java[84-86]
- tnt/src/main/java/org/dcsa/conformance/standards/tnt/v300/TntComponentFactory.java[103-116]
## Suggested fix
- Add a null-safe merge:
- `var roleScenarios = partyScenariosMap.get(role); if (roleScenarios != null) scenarios.putAll(roleScenarios); else throw new IllegalArgumentException("Unsupported role: " + role);`
- (Or, if silently ignoring is desired: `scenarios.putAll(partyScenariosMap.getOrDefault(role, Map.of()));`)
- Optionally, also filter/validate `testedPartyRoleNames` against `TntRole.values()` in `getReportRoleNames(...)` (or at least ensure the returned set only contains supported role config names).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.