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

   Batch 6 (SaaS) of #3117: a default data type on the Jira, Salesforce, Slack, 
Telegram and SNMP Kamelets whose body is fixed. Camel runs the transformer of a 
default data type on every message, so each default changes the body class or 
the `Content-Type`. The table shows what changes. It was checked with the 
Citrus tests, run before and after the change, on a local Camel main build that 
has CAMEL-27258.
   
   > **Draft:** the `jira-source`, `jira-oauth-source`, `telegram-source` and 
`snmp-source` tests need CAMEL-27258, which applies a source's output type 
before the consuming route. That fix was merged today, after the published 
Camel 4.24.0-SNAPSHOT that CI uses was built. This PR waits for a newer 
snapshot.
   
   ## What changes
   
   | Kamelet | in | out | What changes (before → after) |
   |---|---|---|---|
   | `jira-source` | - | `json` | JSON text in a stream (`InputStreamCache`) → 
JSON text in `byte[]`. `Content-Type: application/json` as before. |
   | `jira-oauth-source` | - | `json` | as `jira-source` |
   | `telegram-source` | - | `json` | as `jira-source` |
   | `salesforce-source` | - | `json` | as `jira-source` (no Citrus test: the 
streaming API cannot be stood in for easily). Checked with `camel run` that a 
JSON object `String` (`rawPayload=true`) is still a JSON object after `marshal: 
json` and the `json` type. |
   | `snmp-source` | - | `text` (D1) | `String` as before; `Content-Type` none 
→ `text/plain` |
   | `jira-add-comment-sink` | `text` | - | bytes or a stream → `String`. After 
the sink: `String`, `Content-Type` → `text/plain` (was the incoming one, here 
none). |
   | `jira-add-issue-sink` | `text` | - | as `jira-add-comment-sink`. After the 
sink: the created `Issue` as before, `Content-Type` → `text/plain`. A null or 
empty body is kept, so `ce-issueDescription` still works. |
   | `jira-transition-issue-sink` | `text` | - | as `jira-add-comment-sink` 
(test: `byte[]`, no `Content-Type` → `String`, `text/plain`) |
   | `jira-update-issue-sink` | `text` | - | as `jira-transition-issue-sink` |
   | `slack-sink` | `text` | - | as `jira-transition-issue-sink`. See "Good to 
know" below. |
   | `salesforce-composite-upsert-sink` | `json` | - | JSON text `String` → 
JSON `byte[]` before the `records` JSONPath; Salesforce receives the same 
request. After the sink: the `ArrayList` of results as before, `Content-Type` 
none → `application/json`. |
   | `salesforce-create-sink` | `json` | - | JSON text → JSON `byte[]`, sent as 
is. After the sink: the answer in a `ByteArrayInputStreamCache` as before, 
`Content-Type` none → `application/json`. Adds `camel:jackson3`. |
   | `salesforce-delete-sink` | `json` | - | JSON text → JSON `byte[]` before 
the JSONPath header steps. After the sink: empty body as before, `Content-Type` 
none → `application/json`. Adds `camel:jackson3`. |
   | `salesforce-update-sink` | `json` | - | JSON text → JSON `byte[]` before 
the JSONPath steps. After the sink: no visible change (the payload as JSON text 
in a stream, `application/json` from the template's `marshal: json`). |
   
   With `json`, a `Map` or a `List` body is written as JSON, and text that is 
not a JSON object or array is sent as a JSON string (`hello` → `"hello"`); the 
Salesforce sinks needed a JSON object before as well. The `Output:` paragraphs 
of these Kamelets now say the body class and the `Content-Type`.
   
   ## Not done / good to know
   - **No default dropped** from the Kamelets of this batch.
   - **Skipped:** `github-pullrequest-source`, 
`github-pullrequest-comment-source` and `github-tag-source`. Open PR #3293 
rewrites their output, so their defaults go into that PR or after it.
   - **`telegram-source` and update kinds the Telegram component does not 
model** (for example an edited message): the component leaves the body null, 
`marshal: json` writes `null`, and the `json` type turns that into the JSON 
string `"null"` (checked with `camel run`). Both are unusable today; C2 in the 
proposal (keep text that is already JSON when `Content-Type` is 
`application/json`) would keep `null`.
   - **`slack-sink` with a Slack `Message` or `SlackMessage` object body:** the 
Slack component posts such an object with its blocks and attachments. With 
`text` it is posted as the object's `toString()` instead. The description has 
always said the body is text, and no Kamelet gives such an object, so the 
default stays. This is from reading `SlackProducer`, not a test.
   - The Salesforce sinks keep their `json` default although C6 (validator) is 
not in Camel yet (D3).
   
   ## Tests
   - Citrus, run before and after the change, with Camel main + CAMEL-27258 in 
`~/.m2`. The expected `X-Body-Type`/`X-Content-Type` values are updated.
   - `JiraIT`: the `jira-source`, `jira-add-comment-sink` and 
`jira-add-issue-sink` routes now record the body class and `Content-Type` 
(`jira-source` also checks `key` and `summary` with JSONPath). The four sink 
routes send the body as bytes, so the test shows it is read as text. The 
`jira-add-issue-sink` test now also answers the request that reads the created 
issue back, which it left unanswered before.
   - `ServicesIT`: new Citrus tests for `salesforce-create-sink`, 
`salesforce-update-sink` and `salesforce-delete-sink` (stand-in for the login 
and the REST API, like the upsert test). `telegram-source`, `snmp-source` and 
the upsert test expect the new values.
   - `SlackIT`: the `slack-sink` route sends bytes and records what the sink 
leaves.
   - `./mvnw -o verify -pl tests/camel-kamelets-itest 
-Dit.test='JiraIT,ServicesIT,SlackIT'`: the 18 tests of these three classes for 
the Kamelets here pass (Jira 6, Services 10 of 11, Slack 2). 
`ibm-cos-source-route-test` fails locally with `ct=application/octet-stream`: 
that is its existing `binary` out default reaching the consuming route with 
CAMEL-27258 (handled by #3304), not this PR.
   - `./mvnw clean install` from the root passes, run twice.
   
   ## Overlap with open PRs
   - **#3294** (descriptions) changes the same `Output:` sentence of 
`jira-source`, `jira-oauth-source` and `telegram-source` to "JSON text (a 
stream)". With the `json` default it is "JSON text in bytes", as here; 
whichever PR merges second keeps "in bytes". Edits here are limited to the 
`dataTypes` block and the `Output:` sentence.
   - **#3293** changes the GitHub sources, which this PR leaves alone.
   
   ## Upgrade note for #3190
   ```markdown
   - **Default data types on the SaaS Kamelets (#3305):**
     - `jira-source`, `jira-oauth-source`, `telegram-source` and 
`salesforce-source` (`out: json`) give the JSON text in a `byte[]` instead of a 
stream. `Content-Type` stays `application/json`.
     - `snmp-source` (`out: text`) sets `Content-Type: text/plain` on the XML 
text.
     - `jira-add-comment-sink`, `jira-add-issue-sink`, 
`jira-transition-issue-sink`, `jira-update-issue-sink` and `slack-sink` (`in: 
text`) read the body as a `String` and set `Content-Type: text/plain`, which 
stays on the message after the sink. A Slack `Message` object body is now 
posted as its text form.
     - `salesforce-create-sink`, `salesforce-update-sink`, 
`salesforce-delete-sink` and `salesforce-composite-upsert-sink` (`in: json`) 
turn the body into JSON bytes and set `Content-Type: application/json`, which 
stays on the message after the sink. Text that is not a JSON object or array is 
sent as a JSON string.
   ```
   The CAMEL-27258 bullet in #3190 can list the four `json` sources and 
`snmp-source`.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
   


-- 
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