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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to