Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate the parameters in a Kamelet by looking at catalog #910

Merged
merged 1 commit into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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