Skip to content

Commit

Permalink
Validate the parameters in a Kamelet by looking at catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
oscerd committed May 3, 2022
1 parent 18c8415 commit 7161052
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions library/camel-kamelets-catalog/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>

<parent>
<groupId>org.apache.camel.kamelets</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class KameletsCatalogTest {
Expand Down Expand Up @@ -131,6 +133,8 @@ void testAllKameletDependencies() throws Exception {

@Test
void testOptionsParams() throws Exception {
String[] bannedDeps = {"mvn:", "camel:gson", "camel:core", "camel:kamelet", "github:apache.camel-kamelets:camel-kamelets-utils:main-SNAPSHOT"};
List<String> bannedDepsList = Arrays.asList(bannedDeps);
DefaultCamelCatalog cc = new DefaultCamelCatalog();
List<String> names = catalog.getKameletsName();
for (String name:
Expand All @@ -139,8 +143,7 @@ void testOptionsParams() throws Exception {
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());
.filter(Predicate.not(bannedDepsList::contains)).collect(Collectors.toList());
String cleanName;
if (!deps.isEmpty()) {
if (deps.get(0).equals("camel:jackson") && deps.size() > 1) {
Expand Down

0 comments on commit 7161052

Please sign in to comment.