This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch fix/CAMEL-25636
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 750f43c6217519087438643fbe63f3550da729bd
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Oct 14 10:06:25 2026 +0200

    CAMEL-25636: camel-core - the label of marshal and unmarshal shows the name 
of the data format
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../org/apache/camel/model/MarshalDefinition.java  | 10 +++-
 .../apache/camel/model/UnmarshalDefinition.java    | 10 ++--
 .../model/MarshalUnmarshalDefinitionLabelTest.java | 59 ++++++++++++++++++++++
 3 files changed, 75 insertions(+), 4 deletions(-)

diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/MarshalDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/MarshalDefinition.java
index d48b784c760c..3eebc0121e29 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/MarshalDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/MarshalDefinition.java
@@ -178,7 +178,15 @@ public class MarshalDefinition extends 
NoOutputDefinition<MarshalDefinition> imp
     }
 
     protected String description() {
-        return dataFormatType != null ? dataFormatType.toString() : "";
+        if (dataFormatType == null) {
+            return "";
+        }
+        // the name of the data format (such as jackson or csv), as its 
toString is the object for most data formats
+        String name = dataFormatType.getDataFormatName();
+        if (name == null && dataFormatType.getDataFormat() != null) {
+            name = dataFormatType.getDataFormat().getClass().getSimpleName();
+        }
+        return name != null ? name : dataFormatType.toString();
     }
 
     @Override
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
index 70818601e37a..3455fbbaa044 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
@@ -176,11 +176,15 @@ public class UnmarshalDefinition extends 
NoOutputDefinition<UnmarshalDefinition>
     }
 
     protected String description() {
-        if (dataFormatType != null) {
-            return dataFormatType.toString();
-        } else {
+        if (dataFormatType == null) {
             return "";
         }
+        // the name of the data format (such as jackson or csv), as its 
toString is the object for most data formats
+        String name = dataFormatType.getDataFormatName();
+        if (name == null && dataFormatType.getDataFormat() != null) {
+            name = dataFormatType.getDataFormat().getClass().getSimpleName();
+        }
+        return name != null ? name : dataFormatType.toString();
     }
 
     @Override
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/model/MarshalUnmarshalDefinitionLabelTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/model/MarshalUnmarshalDefinitionLabelTest.java
new file mode 100644
index 000000000000..9f6085710edb
--- /dev/null
+++ 
b/core/camel-core/src/test/java/org/apache/camel/model/MarshalUnmarshalDefinitionLabelTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model;
+
+import org.apache.camel.model.dataformat.CsvDataFormat;
+import org.apache.camel.model.dataformat.CustomDataFormat;
+import org.apache.camel.model.dataformat.DummyDataformat;
+import org.apache.camel.model.dataformat.JsonDataFormat;
+import org.apache.camel.model.dataformat.JsonLibrary;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class MarshalUnmarshalDefinitionLabelTest {
+
+    @Test
+    public void testLabelShowsDataFormatName() {
+        assertEquals("unmarshal[jackson]", new UnmarshalDefinition(new 
JsonDataFormat()).getLabel());
+        assertEquals("Unmarshal[jackson]", new UnmarshalDefinition(new 
JsonDataFormat()).toString());
+        assertEquals("marshal[gson]", new MarshalDefinition(new 
JsonDataFormat(JsonLibrary.Gson)).getLabel());
+        assertEquals("Marshal[gson]", new MarshalDefinition(new 
JsonDataFormat(JsonLibrary.Gson)).toString());
+        assertEquals("marshal[csv]", new MarshalDefinition(new 
CsvDataFormat()).getLabel());
+        assertEquals("unmarshal[csv]", new UnmarshalDefinition(new 
CsvDataFormat()).getLabel());
+    }
+
+    @Test
+    public void testLabelOfDataFormatInstance() {
+        DataFormatDefinition instance = new DataFormatDefinition(new 
DummyDataformat());
+        assertEquals("marshal[DummyDataformat]", new 
MarshalDefinition(instance).getLabel());
+        assertEquals("unmarshal[DummyDataformat]", new 
UnmarshalDefinition(instance).getLabel());
+    }
+
+    @Test
+    public void testLabelOfCustomDataFormat() {
+        assertEquals("marshal[CustomDataFormat[myFormat]]", new 
MarshalDefinition(new CustomDataFormat("myFormat")).getLabel());
+        assertEquals("unmarshal[CustomDataFormat[myFormat]]",
+                new UnmarshalDefinition(new 
CustomDataFormat("myFormat")).getLabel());
+    }
+
+    @Test
+    public void testLabelWithoutDataFormat() {
+        assertEquals("marshal[]", new MarshalDefinition().getLabel());
+        assertEquals("unmarshal[]", new UnmarshalDefinition().getLabel());
+    }
+}

Reply via email to