davsclaus commented on code in PR #30029:
URL: https://github.com/apache/camel/pull/30029#discussion_r4578942645
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java:
##########
@@ -162,6 +162,11 @@ public class CamelSendAction extends ActionBaseCommand {
@Option(name = "logging-color", hasValue = false, description = "Use
colored logging", defaultValue = "true")
boolean loggingColor = true;
+ @Option(name = "json", hasValue = false,
+ description = "Output the outcome of the send in JSON Format: the
status, the exchange id and, with --reply, the"
+ + " reply message (as --show-headers, --show-body
and the other --show options say)")
+ boolean jsonOutput;
Review Comment:
Done in f938ec3946d6: "Output the outcome in JSON Format: the status, the
exchange id, and the reply message with --reply".
_Claude Code on behalf of davsclaus_
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendActionResultTest.java:
##########
@@ -253,4 +253,32 @@ private static JsonObject answer(String status) {
answer.put("message", message);
return answer;
}
+
+ @Test
+ void theOutcomeAsJson() throws Exception {
+ // CAMEL-26929: send had no --json, so a script or an AI agent had to
read the status line and the table
+ writeStatusFile(TEST_PID, "orders");
+
+ int exit = callWithResponse(command("orders",
"--endpoint=direct:start", "--body=hello", "--reply", "--json"),
+ answer("success"));
+
+ assertThat(exit).isEqualTo(CliExitCode.OK);
+ JsonObject out = (JsonObject) Jsoner.deserialize(printer.getStdout());
+ assertThat(out.getString("status")).isEqualTo("success");
+ assertThat(out.getString("exchangeId")).isEqualTo("ex-1");
+ assertThat(out.getLong("pid")).isEqualTo(TEST_PID);
+ assertThat(printer.getStdout()).doesNotContain("Sent (");
+ }
+
+ @Test
+ void aFailedSendAsJsonIsAFailure() throws Exception {
+ writeStatusFile(TEST_PID, "orders");
+
+ int exit = callWithResponse(command("orders",
"--endpoint=direct:start", "--json"), answer("error"));
+
+ assertThat(exit).isEqualTo(CliExitCode.FAILURE);
+ JsonObject out = (JsonObject) Jsoner.deserialize(printer.getStdout());
+ assertThat(out.getString("status")).isEqualTo("error");
+ assertThat(out.containsKey("exception")).isTrue();
+ }
}
Review Comment:
Added in f938ec3946d6: theSummaryOfARepeatAsJson covers the summary of a
repeat (the sent counts) as JSON.
_Claude Code on behalf of davsclaus_
--
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]