You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/05/03 12:55:21 UTC

[camel-kamelets] branch fix-part-889 created (now c8ad24ea)

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

acosentino pushed a change to branch fix-part-889
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git


      at c8ad24ea Validate the parameters in a Kamelet by looking at catalog

This branch includes the following new commits:

     new 8b5e1d52 Validate the parameters in a Kamelet by looking at catalog
     new c8ad24ea Validate the parameters in a Kamelet by looking at catalog

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel-kamelets] 02/02: Validate the parameters in a Kamelet by looking at catalog

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch fix-part-889
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git

commit c8ad24eaf0b850685694d84713bb71649fd685f1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue May 3 14:54:06 2022 +0200

    Validate the parameters in a Kamelet by looking at catalog
---
 library/camel-kamelets-catalog/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/library/camel-kamelets-catalog/pom.xml b/library/camel-kamelets-catalog/pom.xml
index 73b4a65e..0bb8816f 100644
--- a/library/camel-kamelets-catalog/pom.xml
+++ b/library/camel-kamelets-catalog/pom.xml
@@ -71,7 +71,7 @@
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-catalog</artifactId>
-            <version>3.16.0</version>
+            <version>${camel.version}</version>
         </dependency>
 
         <!-- logging -->


[camel-kamelets] 01/02: Validate the parameters in a Kamelet by looking at catalog

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch fix-part-889
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git

commit 8b5e1d52ecf85b9849d47fc2433508c8654322a8
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue May 3 14:53:14 2022 +0200

    Validate the parameters in a Kamelet by looking at catalog
---
 library/camel-kamelets-catalog/pom.xml             |  6 +++
 .../kamelets/catalog/KameletsCatalogTest.java      | 47 ++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/library/camel-kamelets-catalog/pom.xml b/library/camel-kamelets-catalog/pom.xml
index a0ed86c1..73b4a65e 100644
--- a/library/camel-kamelets-catalog/pom.xml
+++ b/library/camel-kamelets-catalog/pom.xml
@@ -68,6 +68,12 @@
             <version>${classgraph.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-catalog</artifactId>
+            <version>3.16.0</version>
+        </dependency>
+
         <!-- logging -->
         <dependency>
             <groupId>org.apache.logging.log4j</groupId>
diff --git a/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java b/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java
index ae229b46..7db7c4f2 100644
--- a/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java
+++ b/library/camel-kamelets-catalog/src/test/java/org/apache/camel/kamelets/catalog/KameletsCatalogTest.java
@@ -20,7 +20,9 @@ import io.fabric8.camelk.v1alpha1.Kamelet;
 import io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps;
 import io.github.classgraph.ClassGraph;
 
+import org.apache.camel.catalog.DefaultCamelCatalog;
 import org.apache.camel.kamelets.catalog.model.KameletTypeEnum;
+import org.apache.camel.tooling.model.ComponentModel;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
@@ -31,6 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 public class KameletsCatalogTest {
     static KameletsCatalog catalog;
@@ -125,4 +128,48 @@ public class KameletsCatalogTest {
     void testAllKameletDependencies() throws Exception {
         catalog.getAllKameletDependencies();
     }
+
+    @Test
+    void testOptionsParams() throws Exception {
+        DefaultCamelCatalog cc = new DefaultCamelCatalog();
+        List<String> names = catalog.getKameletsName();
+        for (String name:
+             names) {
+            Map<String, Object> kd = catalog.getKameletTemplate(name);
+            Map<String,Object> f = (Map) kd.get("from");
+            Map<String,Object> p = (Map) f.get("parameters");
+            List<String> deps = catalog.getKameletDependencies(name).stream()
+                    .filter(d -> !d.contains("mvn:") && !d.contains("camel:gson") && !d.contains("camel:core") && !d.contains("camel:kamelet") && !d.contains("github:apache.camel-kamelets:camel-kamelets-utils:main-SNAPSHOT"))
+                    .collect(Collectors.toList());
+            String cleanName;
+            if (!deps.isEmpty()) {
+                if (deps.get(0).equals("camel:jackson") && deps.size() > 1) {
+                    cleanName = deps.get(1).replace("camel:", "");
+                } else {
+                    cleanName = deps.get(0).replace("camel:", "");
+                }
+                if (cleanName.equalsIgnoreCase("cassandraql")) {
+                    cleanName = "cql";
+                }
+                if (cleanName.equalsIgnoreCase("aws2-ddb") && name.equals("aws-ddb-streams-source")) {
+                    cleanName = "aws2-ddb-streams";
+                }
+                if (p != null && !p.isEmpty()) {
+                    ComponentModel componentModel = cc.componentModel(cleanName);
+                    if (componentModel != null) {
+                        List<ComponentModel.EndpointOptionModel> ce = componentModel.getEndpointOptions();
+                        List<String> ceInternal =
+                                ce.stream()
+                                        .map(ComponentModel.EndpointOptionModel::getName)
+                                        .collect(Collectors.toList());
+                    for (Map.Entry<String, Object> entry : p.entrySet()) {
+                            if (!entry.getKey().equals("period") && (!name.equals("kafka-ssl-source") && !name.equals("google-sheets-source") && !name.equals("google-mail-source") && !name.equals("google-calendar-source") && !name.equals("timer-source") && !name.equals("cron-source") && !name.equals("fhir-source"))) {
+                                assertTrue(ceInternal.contains(entry.getKey()));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
 }