davsclaus opened a new pull request, #30579:
URL: https://github.com/apache/camel/pull/30579

   JIRA: [CAMEL-27363](https://issues.apache.org/jira/browse/CAMEL-27363)
   
   ## What was wrong
   
   `camel validate normalize` (Camel CLI) turned
   
   ```yaml
   - setBody:
       constant: ""
   ```
   
   into `constant: {}`, which has no expression, so the empty body was lost. 
Normalize dumps the routes with the YAML model writer of `camel-yaml-io`, and 
`YamlModelWriterSupport.doWriteValue` skipped an empty expression text. So 
every route dump (`camel.main.dumpRoutes=yaml`, normalize, the YAML views) had 
the same problem.
   
   ## The fix
   
   - `doWriteValue` now writes an empty text too: `constant: {expression: ""}`.
   - The method call expression is the exception. The Java DSL gives it an 
empty text (`super("")`), because the bean is given by its attributes (`ref`, 
`beanType`, `method`). The generator template `model-yaml-writer.vm` now makes 
`doWriteMethodCallExpression` call a new `doWriteNonEmptyValue`, so `method: 
{ref: myBean}` gets no `expression: ""`. `YamlModelWriter` is regenerated with 
the changed plugin, and the diff is that one line.
   
   ## Tests
   
   - New `YamlWriterEdgeCasesTest#testEmptyExpressionText`: an empty `constant` 
and `simple` keep `expression: ""`, and a `method` call gets no `expression` 
key. It fails without the fix.
   - Ran the whole `core/camel-yaml-io` test suite against the changed 
`camel-package-maven-plugin` (installed into a scratch repo, so the build 
regenerates `YamlModelWriter` from the new template): 193 tests, 0 failures.
   - Checked end to end with a temporary test (not committed) in 
`camel-jbang-plugin-validate`. It ran `camel validate normalize` on the 
three-line route from the ticket against the fixed `camel-yaml-io`. The output 
has `constant: {expression: ""}`, and normalizing that output again gives the 
same result.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to