Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gansheer committed Jan 24, 2025
1 parent 394490d commit 33ba00d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 */
Expand All @@ -18,6 +37,9 @@ public class AddCamelPluginAction extends AbstractCamelJBangAction {
/** Camel Jbang command arguments */
private final List<String> args;

/**
* Default constructor.
*/
public AddCamelPluginAction(AddCamelPluginAction.Builder builder) {
super("plugin", builder);
this.name = builder.name;
Expand All @@ -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<String> installedPlugins = camelJBang().getPlugins();

logger.info("Executing plugin operation");
if(!installedPlugins.contains(name)){
logger.debug("Installing plugin {}", name);
if (!installedPlugins.contains(name)) {
List<String> 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));
}


}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -43,7 +59,7 @@ public static final class Builder extends AbstractCamelJBangAction.Builder<Camel


/**
* .
* Set add plugin action.
* @param addPluginAction
* @return
*/
Expand All @@ -54,7 +70,7 @@ public Builder addPluginAction(AddCamelPluginAction addPluginAction) {


/**
* .
* Set export kubernetes plugin action.
* @param exportKubernetesPluginAction
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import java.util.List;


/**
* Export a Camel project given Camel integration with Camel JBang tooling.
*/
public class ExportKubernetesCamelPluginAction extends AbstractCamelJBangAction {

/** Logger */
Expand All @@ -49,6 +52,9 @@ public class ExportKubernetesCamelPluginAction extends AbstractCamelJBangAction
/** Camel Jbang command traits */
private final List<String> traits;

/**
* Default constructor.
*/
public ExportKubernetesCamelPluginAction(ExportKubernetesCamelPluginAction.Builder builder) {
super("export-kubernetes", builder);

Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
~ limitations under the License.
-->

<test name="CamelJBangTest" author="Christoph" status="FINAL" xmlns="http://citrusframework.org/schema/xml/testcase"
<test name="CamelJBangPluginTest" author="Gaelle" status="FINAL" xmlns="http://citrusframework.org/schema/xml/testcase"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://citrusframework.org/schema/xml/testcase http://citrusframework.org/schema/xml/testcase/citrus-testcase.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "CamelJBangTest"
author: "Christoph"
name: "CamelJBangPluginTest"
author: "Gaelle"
status: "FINAL"
actions:
- camel:
Expand Down

0 comments on commit 33ba00d

Please sign in to comment.