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

   Fixes [CAMEL-26120](https://issues.apache.org/jira/browse/CAMEL-26120).
   
   ### 1. The id of the started case was thrown away
   
   `BonitaStartProducer.process` called `api.startCase(...)` and ignored the 
returned `CaseCreationResponse`. The `caseId` of the new case was not in the 
body or in a header, so a route could not follow the case.
   
   **Change:** the producer sets the case id in a new `CamelBonitaCaseId` 
header (`BonitaConstants.CASE_ID`, now the `headersClass` of the endpoint). The 
body stays the `Map` of the inputs, as before.
   
   I chose a header over replacing the body: the out body is documented as 
unchanged (catalog body types), and a route may read the inputs after the call. 
A header adds the id without breaking that.
   
   ### 2. A JSON text body failed with "The contract input is null"
   
   The producer read the body with `getBody(Map.class)`. A JSON `String` does 
not convert to a `Map`, so `null` was passed on and `BonitaAPI.startCase` 
failed with `IllegalArgumentException: The contract input is null`, although a 
body was sent.
   
   **Change:** the producer uses `getMandatoryBody(Map.class)`. A body that is 
missing or not a `Map` now fails with `InvalidPayloadException`, which names 
the body type. It fails before the process lookup, so no request goes to Bonita.
   
   **Not changed:** the producer does not parse JSON text into a `Map`. That 
would be a new feature; `unmarshal().json()` before the endpoint does it 
already. The docs say so.
   
   ### Tests
   
   New `BonitaStartProducerTest` (WireMock Bonita server, no external service):
   - `caseIdOfTheStartedCaseIsInAHeader`: the header holds the `caseId` of the 
response, the body is the input `Map`.
   - `jsonTextBodyFailsWithItsType`: a JSON text body fails with 
`InvalidPayloadException` naming `java.lang.String`; no case is started.
   - `missingBodyFailsAsNoBody`: no body fails with `InvalidPayloadException`; 
no case is started.
   
   All three fail on main (null header; `IllegalArgumentException` instead of 
`InvalidPayloadException`) and pass with the fix. `mvn clean install 
-Psourcecheck` in `components/camel-bonita`: 28 tests, 0 failures (1 manual IT 
skipped).
   
   ### Docs and generated files
   
   - `bonita-component.adoc`: the body section says that other bodies fail with 
`InvalidPayloadException` and that the case id is in `CamelBonitaCaseId`. The 
header table is generated.
   - Regenerated `bonita.json` (new header, updated body type descriptions), 
the catalog copies of the json and adoc, and the endpoint DSL 
(`BonitaEndpointBuilderFactory`, `EndpointHeaderBuilders`).
   - Upgrade guide 4.24: a short entry on the exception type change 
(`IllegalArgumentException` -> `InvalidPayloadException`) for a missing or 
non-`Map` body.
   
   _Claude Code on behalf of Claus Ibsen (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