You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "davsclaus (via GitHub)" <gi...@apache.org> on 2026/10/02 06:20:56 UTC
[PR] chore: camel-jbang - the route tree shows the otherwise of a Switch as otherwise[..], not to: otherwise[..] [camel]
davsclaus opened a new pull request, #27252:
URL: https://github.com/apache/camel/pull/27252
The mini route tree next to the route diagram labelled the otherwise branch of a Switch EIP as `to: otherwise[direct:normal]`:
```
switch
├─ case[direct:gold]
└─ to: otherwise[direct:normal]
```
The otherwise of a Switch is a node of type `to` whose code names it (`otherwise[...]`); `RouteTreePreview.buildLabel` only left out the type when the code started with the node's own type. Now a code that names its own node (a word followed by `[` or `(`) is shown as it is: `otherwise[direct:normal]`. An endpoint keeps its type (`to: kafka:out`).
### Testing
- New `RouteTreePreviewTest.theOtherwiseOfASwitchIsLabelledAsItself` (fails without the fix); the class passes.
_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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the route tree shows the otherwise of a Switch as otherwise[..], not to: otherwise[..] [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27252:
URL: https://github.com/apache/camel/pull/27252#issuecomment-5946893253
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `dsl/camel-jbang/camel-jbang-plugin-tui`
---
<details><summary>:microscope: Scalpel shadow comparison — Scalpel: 2 of 697 tested, 1 compile-only — current: 2 all tested</summary>
[Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **2 affected modules** (current approach: 2).
**Skip-tests mode would test 2 modules** (1 direct + 1 downstream), **skip tests for 1** (generated code, meta-modules)
<details><summary>Modules Scalpel would test (2)</summary>
- `camel-jbang-plugin-tui` ← dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteTreePreview.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteTreePreviewTest.java
- `camel-launcher-container` ← downstream of org.apache.camel:camel-launcher
</details>
<details><summary>Modules with tests skipped (1)</summary>
- `camel-launcher`
</details>
> :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
</details>
<details><summary>All tested modules (3 modules, 1m 28s total)</summary>
**Total reactor time:** 1m 28s
| Module | Duration | Status |
| --- | --- | --- |
| Camel :: JBang :: Plugin :: TUI | 50.2s | SUCCESS |
| Camel :: Launcher | 37.3s | SUCCESS |
| Camel :: Launcher :: Container | 0.9s | SUCCESS |
**Top 20 slowest modules:**
- `Camel :: JBang :: Plugin :: TUI` (50.2s)
- `Camel :: Launcher` (37.3s)
- `Camel :: Launcher :: Container` (0.9s)
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/36973728446)
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the route tree shows the otherwise of a Switch as otherwise[..], not to: otherwise[..] [camel]
Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #27252:
URL: https://github.com/apache/camel/pull/27252#discussion_r4163353651
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteTreePreviewTest.java:
##########
@@ -154,6 +154,30 @@ private LayoutRoute buildContentBasedRouterLayout() {
return layout;
}
+ @Test
+ void theOtherwiseOfASwitchIsLabelledAsItself() {
+ LayoutRoute layout = new LayoutRoute();
+ TreeNode root = node("from", "kafka:orders");
+ TreeNode sw = node("switch", null);
+ TreeNode case1 = node("case", "case[direct:gold]");
+ // the otherwise of a Switch is a node of type to whose code names it
+ TreeNode otherwise = node("to", "otherwise[direct:normal]");
+ TreeNode out = node("to", "kafka:out");
+ addChild(root, sw);
+ addChild(sw, case1);
+ addChild(sw, otherwise);
+ addChild(root, out);
+ for (TreeNode n : List.of(root, sw, case1, otherwise, out)) {
+ addLayoutNode(layout, n);
+ }
+
+ String tree = lineToPlainText(RouteTreePreview.buildTree(layout, 20, 60, null));
+ assertTrue(tree.contains("otherwise[direct:normal]"), tree);
+ assertTrue(!tree.contains("to: otherwise"), tree);
Review Comment:
💡 **Nit:** `assertFalse` reads better than `assertTrue(!...)` for negative assertions:
```suggestion
assertFalse(tree.contains("to: otherwise"), tree);
```
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteTreePreview.java:
##########
@@ -36,6 +37,8 @@ class RouteTreePreview {
"throttle", "threads", "onException", "onCompletion",
"intercept", "interceptFrom", "interceptSendToEndpoint");
+ private static final Pattern SELF_NAMED = Pattern.compile("[A-Za-z]+[\\[(]");
Review Comment:
💡 **Nit:** The pattern `[A-Za-z]+[\\[(]` is broader than the `otherwise[...]` case it targets — it matches *any* alphabetic word followed by `[` or `(` (e.g. `direct(foo)`, `MyBean(arg)`). In practice this is fine because Camel endpoint URIs use colons (`direct:foo`), so the regex won't false-positive on real endpoint codes.
If you wanted to be more precise, you could anchor to the known self-naming patterns (e.g. `otherwise`, `case`), but frankly YAGNI — the current pattern works for the tree model's actual data.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the route tree shows the otherwise of a Switch as otherwise[..], not to: otherwise[..] [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #27252:
URL: https://github.com/apache/camel/pull/27252
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the route tree shows the otherwise of a Switch as otherwise[..], not to: otherwise[..] [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #27252:
URL: https://github.com/apache/camel/pull/27252#discussion_r4163372576
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteTreePreview.java:
##########
@@ -36,6 +37,8 @@ class RouteTreePreview {
"throttle", "threads", "onException", "onCompletion",
"intercept", "interceptFrom", "interceptSendToEndpoint");
+ private static final Pattern SELF_NAMED = Pattern.compile("[A-Za-z]+[\\[(]");
Review Comment:
Kept as is, agreeing with the YAGNI: the codes of this tree are endpoint URIs (with a colon, `direct:foo`) or names that label themselves (`otherwise[..]`, `case[..]`), so the broader pattern matches what the tree model has without a list of names to keep in sync.
_Claude Code on behalf of davsclaus_
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteTreePreviewTest.java:
##########
@@ -154,6 +154,30 @@ private LayoutRoute buildContentBasedRouterLayout() {
return layout;
}
+ @Test
+ void theOtherwiseOfASwitchIsLabelledAsItself() {
+ LayoutRoute layout = new LayoutRoute();
+ TreeNode root = node("from", "kafka:orders");
+ TreeNode sw = node("switch", null);
+ TreeNode case1 = node("case", "case[direct:gold]");
+ // the otherwise of a Switch is a node of type to whose code names it
+ TreeNode otherwise = node("to", "otherwise[direct:normal]");
+ TreeNode out = node("to", "kafka:out");
+ addChild(root, sw);
+ addChild(sw, case1);
+ addChild(sw, otherwise);
+ addChild(root, out);
+ for (TreeNode n : List.of(root, sw, case1, otherwise, out)) {
+ addLayoutNode(layout, n);
+ }
+
+ String tree = lineToPlainText(RouteTreePreview.buildTree(layout, 20, 60, null));
+ assertTrue(tree.contains("otherwise[direct:normal]"), tree);
+ assertTrue(!tree.contains("to: otherwise"), tree);
Review Comment:
Done in 736b73aec9dd: `assertFalse`.
_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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: camel-jbang - the route tree shows the otherwise of a Switch as otherwise[..], not to: otherwise[..] [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #27252:
URL: https://github.com/apache/camel/pull/27252#issuecomment-5946697066
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
* You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org