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

   Fixes [CAMEL-26225](https://issues.apache.org/jira/browse/CAMEL-26225), 
found while adding the catalog body types (CAMEL-24961).
   
   ## 1. SAVE_DOCUMENT with a List writes the documents, then fails
   
   **Was:** `saveDocument` used `insertDocuments` only when the 
`CamelArangoDbMultiInsert` header was true. Without it a `List` body went to 
`insertDocument`, which sends it as a JSON array: ArangoDB inserted all the 
documents and replied with an array, and the driver then failed with "Cannot 
deserialize ... DocumentCreateEntity from Array value". The exchange failed 
although the documents were written, so a redelivery inserted them again.
   
   **Now:** A `Collection` body is inserted with `insertDocuments`, with or 
without the header, as ArangoDB inserts a JSON array as several documents 
anyway. The exchange succeeds and the body is the `MultiDocumentEntity` of the 
insert, as with the header. A single document (a `Map`, a POJO, a 
`BaseDocument`) is inserted with `insertDocument` as before.
   
   ## 2. No default operation: every message fails
   
   **Was:** The producer read the operation from the endpoint only, and when it 
was not set every message failed with "Operation not supported. Value: null", 
while the route started.
   
   **Now:** `ArangoDbEndpoint.createProducer` fails when the operation is not 
set, with an `IllegalArgumentException` that says to set the `operation` option 
on the endpoint or on the component configuration, for example 
`operation=SAVE_DOCUMENT`. A route that sends to such an endpoint fails to 
start instead of failing each message. The operation set on the component 
configuration is enough, as before.
   
   ## Tests
   
   `ArangoDbProducerTest` runs the producer with the ArangoDB driver against a 
fake of the document API on the JDK HTTP server, which, like ArangoDB, inserts 
a JSON array as several documents and replies with an array. The module has no 
Mockito, and this needs no new dependency.
   
   - A `List` of two documents with no multi-insert header: one insert of the 
array, the exchange succeeds, and the body is a `MultiDocumentEntity` of two 
documents.
   - One document: one insert of an object, and the body is a 
`DocumentCreateEntity`, as before.
   - A route to an endpoint without the operation fails to start with the 
`IllegalArgumentException`, and sends nothing.
   - The operation set on the component configuration is enough for an endpoint 
without it.
   
   Revert check: with the change to `src/main` reverted, 2 of the 4 new tests 
fail, each for its reason: the `List` is sent in one insert and the exchange 
then fails with the error of the issue, `Cannot deserialize value of type 
DocumentCreateEntity<Void> from Array value`, and the route without the 
operation starts. The 2 that pass check what must not change: one document is 
inserted as before, and the operation of the component configuration is enough.
   
   Module: 6 tests, 0 failures (the integration tests need ArangoDB in a 
container and were not run; their routes all set the operation).
   
   ## Docs and generated files
   
   - `@BodyTypes`: a `Collection` body saves several documents with or without 
the `CamelArangoDbMultiInsert` header, and the producer fails to start without 
the operation.
   - The component page says that the `operation` option must be set and that a 
route without it fails to start, and that a `Collection` body saves each of its 
documents.
   - Regenerated `arangodb.json`, and the catalog copies of the JSON and the 
page.
   - Upgrade guide entry for 4.24, as a route without the operation now fails 
to start, and a `Collection` body is now saved as several documents.
   
   ## Not changed
   
   - No header for the operation is added: the component has none, and the 
issue offers failing at startup as the alternative.
   - The `operation` option is not marked as required in the catalog, as the 
component configuration can set it for all its endpoints, and the option is 
shared by the component and the endpoint. No option or header changed.
   - `UPDATE_DOCUMENT` and `DELETE_DOCUMENT` still need their multi headers for 
a `List` body, as the issue is about `SAVE_DOCUMENT`.
   - An array body (not a `Collection`) is not turned into a list, as the issue 
names a `Collection`.
   
   Main only, as the other fixes of the CAMEL-24961 follow-ups.
   
   _Claude Code on behalf of Andrea Cosentino (oscerd)_
   
   🤖 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]

  • [PR] CAMEL-26225: camel-arang... oscerd (via GitHub) via commits

Reply via email to