Fix Java example template to properly wrap long scenario names in comments #3305
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.
What does this PR do?
Fixes a code generation issue where long scenario names (>120 characters) in Java examples were being word-wrapped incorrectly, causing Java compilation errors.
Problem
When a scenario name exceeds 120 characters, the Jinja2
wordwrapfilter was creating a new line without preserving the comment prefix//. This resulted in invalid Java syntax like:The word
responseon line 2 is not valid Java syntax, causing compilation errors:Solution
Updated the
example.j2template to use thewrapstringparameter in thewordwrapfilter:// {{ scenario.name|wordwrap(width=120, wrapstring='\n// ')}}This ensures that when the scenario name wraps to a new line, it preserves the
//comment prefix, resulting in valid Java code:Related PRs
This fixes the compilation errors seen in:
Testing
After this fix is merged, the generated Java examples for PR #3291 should compile successfully.