From 33ba00d7a8a83cc178ff4597e7faa653789599d5 Mon Sep 17 00:00:00 2001 From: Gaelle Fournier Date: Thu, 23 Jan 2025 17:21:59 +0100 Subject: [PATCH] Cleanup --- .../camel/actions/AddCamelPluginAction.java | 32 +++++++++++++++---- .../actions/CamelJBangActionBuilder.java | 4 +-- .../camel/actions/CamelPluginAction.java | 20 ++++++++++-- .../ExportKubernetesCamelPluginAction.java | 17 ++++++++++ .../citrusframework/camel/xml/JBangTest.java | 4 +-- .../citrusframework/camel/yaml/JBangTest.java | 6 ++-- .../camel/xml/camel-jbang-plugin-test.xml | 2 +- .../camel/yaml/camel-jbang-plugin-test.yaml | 4 +-- 8 files changed, 69 insertions(+), 20 deletions(-) diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/AddCamelPluginAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/AddCamelPluginAction.java index 7027a0c58f..a34c8b2f3b 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/AddCamelPluginAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/AddCamelPluginAction.java @@ -1,3 +1,19 @@ +/* + * Copyright the original author or authors. + * + * Licensed 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.citrusframework.camel.actions; import org.citrusframework.context.TestContext; @@ -8,6 +24,9 @@ import java.util.Arrays; import java.util.List; +/** + * Install a specific plugin to a Camel JBang tooling. + */ public class AddCamelPluginAction extends AbstractCamelJBangAction { /** Logger */ @@ -18,6 +37,9 @@ public class AddCamelPluginAction extends AbstractCamelJBangAction { /** Camel Jbang command arguments */ private final List args; + /** + * Default constructor. + */ public AddCamelPluginAction(AddCamelPluginAction.Builder builder) { super("plugin", builder); this.name = builder.name; @@ -31,23 +53,19 @@ public String getName() { @Override public void doExecute(TestContext context) { - logger.debug("Add camel plugin {} action:", name); - logger.info("Checking Camel plugins installed"); + logger.info("Adding Camel plugin '%s' ...".formatted(name)); List installedPlugins = camelJBang().getPlugins(); - logger.info("Executing plugin operation"); - if(!installedPlugins.contains(name)){ - logger.debug("Installing plugin {}", name); + if (!installedPlugins.contains(name)) { List fullArgs = new ArrayList<>(); fullArgs.add("add"); fullArgs.add(name); fullArgs.addAll(args); camelJBang().camelApp().run("plugin", fullArgs.toArray(String[]::new)); } else { - logger.debug("Plugin {} already installed", name); + logger.info("Adding Camel plugin '%s' skipped: already installed".formatted(name)); } - } /** diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelJBangActionBuilder.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelJBangActionBuilder.java index afa440bbb9..e035520d6f 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelJBangActionBuilder.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelJBangActionBuilder.java @@ -88,7 +88,7 @@ public CamelStopIntegrationAction.Builder stop(String name) { /** - * ? + * Add a plugin to Camel JBang. */ public AddCamelPluginAction.Builder addPlugin() { AddCamelPluginAction.Builder builder = new AddCamelPluginAction.Builder(); @@ -100,7 +100,7 @@ public AddCamelPluginAction.Builder addPlugin() { /** - * ? + * Export a Camel project given Camel integration. */ public ExportKubernetesCamelPluginAction.Builder exportKubernetesPlugin() { ExportKubernetesCamelPluginAction.Builder builder = new ExportKubernetesCamelPluginAction.Builder(); diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelPluginAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelPluginAction.java index 31762ffd30..b915ac37c4 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelPluginAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelPluginAction.java @@ -1,3 +1,19 @@ +/* + * Copyright the original author or authors. + * + * Licensed 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.citrusframework.camel.actions; import org.citrusframework.context.TestContext; @@ -43,7 +59,7 @@ public static final class Builder extends AbstractCamelJBangAction.Builder traits; + /** + * Default constructor. + */ public ExportKubernetesCamelPluginAction(ExportKubernetesCamelPluginAction.Builder builder) { super("export-kubernetes", builder); @@ -61,6 +67,7 @@ public ExportKubernetesCamelPluginAction(ExportKubernetesCamelPluginAction.Build @Override public void doExecute(TestContext context) { logger.debug("Export kubernetes camel plugin action:"); + logger.info("Exporting integration in a Camel Kubernetes project ..."); Path integrationFile; if (integrationResource != null) { integrationFile = integrationResource.getFile().toPath(); @@ -141,11 +148,21 @@ public Builder integration(Resource resource) { return this; } + /** + * Define container image builder type. + * @param imageBuilder + * @return + */ public Builder imageBuilder(String imageBuilder) { this.imageBuilder = imageBuilder; return this; } + /** + * Set container image registry. + * @param imageRegistry + * @return + */ public Builder imageRegistry(String imageRegistry) { this.imageRegistry = imageRegistry; return this; diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/JBangTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/JBangTest.java index e264c72b55..24d09010be 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/JBangTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/JBangTest.java @@ -81,8 +81,8 @@ public void shouldLoadCamelPluginActions() throws Exception { testLoader.load(); TestCase result = testLoader.getTestCase(); - Assert.assertEquals(result.getName(), "CamelJBangTest"); - Assert.assertEquals(result.getMetaInfo().getAuthor(), "Christoph"); + Assert.assertEquals(result.getName(), "CamelJBangPluginTest"); + Assert.assertEquals(result.getMetaInfo().getAuthor(), "Gaelle"); Assert.assertEquals(result.getMetaInfo().getStatus(), TestCaseMetaInfo.Status.FINAL); Assert.assertEquals(result.getActionCount(), 2L); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/JBangTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/JBangTest.java index bf18fc252f..98e7b0ff01 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/JBangTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/JBangTest.java @@ -22,12 +22,10 @@ import org.citrusframework.TestCase; import org.citrusframework.TestCaseMetaInfo; import org.citrusframework.camel.CamelSettings; -import org.citrusframework.camel.actions.AddCamelPluginAction; import org.citrusframework.camel.actions.CamelPluginAction; import org.citrusframework.camel.actions.CamelRunIntegrationAction; import org.citrusframework.camel.actions.CamelStopIntegrationAction; import org.citrusframework.camel.actions.CamelVerifyIntegrationAction; -import org.citrusframework.camel.actions.ExportKubernetesCamelPluginAction; import org.citrusframework.yaml.YamlTestLoader; import org.testng.Assert; import org.testng.annotations.Test; @@ -82,8 +80,8 @@ public void shouldLoadCamelPluginActions() throws Exception { testLoader.load(); TestCase result = testLoader.getTestCase(); - Assert.assertEquals(result.getName(), "CamelJBangTest"); - Assert.assertEquals(result.getMetaInfo().getAuthor(), "Christoph"); + Assert.assertEquals(result.getName(), "CamelJBangPluginTest"); + Assert.assertEquals(result.getMetaInfo().getAuthor(), "Gaelle"); Assert.assertEquals(result.getMetaInfo().getStatus(), TestCaseMetaInfo.Status.FINAL); Assert.assertEquals(result.getActionCount(), 2L); diff --git a/endpoints/citrus-camel/src/test/resources/org/citrusframework/camel/xml/camel-jbang-plugin-test.xml b/endpoints/citrus-camel/src/test/resources/org/citrusframework/camel/xml/camel-jbang-plugin-test.xml index 770ac313a2..46122161f2 100644 --- a/endpoints/citrus-camel/src/test/resources/org/citrusframework/camel/xml/camel-jbang-plugin-test.xml +++ b/endpoints/citrus-camel/src/test/resources/org/citrusframework/camel/xml/camel-jbang-plugin-test.xml @@ -14,7 +14,7 @@ ~ limitations under the License. --> - diff --git a/endpoints/citrus-camel/src/test/resources/org/citrusframework/camel/yaml/camel-jbang-plugin-test.yaml b/endpoints/citrus-camel/src/test/resources/org/citrusframework/camel/yaml/camel-jbang-plugin-test.yaml index 69022b5ad4..c6da5d7628 100644 --- a/endpoints/citrus-camel/src/test/resources/org/citrusframework/camel/yaml/camel-jbang-plugin-test.yaml +++ b/endpoints/citrus-camel/src/test/resources/org/citrusframework/camel/yaml/camel-jbang-plugin-test.yaml @@ -1,5 +1,5 @@ -name: "CamelJBangTest" -author: "Christoph" +name: "CamelJBangPluginTest" +author: "Gaelle" status: "FINAL" actions: - camel: