summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/pom.xml18
-rw-r--r--common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java2
-rw-r--r--common/src/main/resources/examples/controlloop/PMSH/consul_url.txt1
-rw-r--r--common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java80
-rw-r--r--common/src/test/resources/examples/controlloop/KubernetesHelm.yaml (renamed from common/src/main/resources/examples/controlloop/KubernetesHelm.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/PMSH/consul_call_body.json (renamed from common/src/main/resources/examples/controlloop/PMSH/consul_call_body.json)0
-rw-r--r--common/src/test/resources/examples/controlloop/PMSH/consul_url.txt1
-rw-r--r--common/src/test/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml (renamed from common/src/main/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json (renamed from common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json)0
-rw-r--r--common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml (renamed from common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml (renamed from common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.json (renamed from common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.json)0
-rw-r--r--common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml (renamed from common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml (renamed from common/src/main/resources/examples/controlloop/PMSubscriptionHandling.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml (renamed from common/src/main/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml (renamed from common/src/main/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/original/cloop_base_types.yaml (renamed from common/src/main/resources/examples/controlloop/original/cloop_base_types.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/original/cloop_dcae_example.yaml (renamed from common/src/main/resources/examples/controlloop/original/cloop_dcae_example.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/original/cloop_dcae_types.yaml (renamed from common/src/main/resources/examples/controlloop/original/cloop_dcae_types.yaml)0
-rw-r--r--common/src/test/resources/examples/controlloop/original/cloop_other_types.yaml (renamed from common/src/main/resources/examples/controlloop/original/cloop_other_types.yaml)0
-rw-r--r--participant/participant-impl/pom.xml8
-rw-r--r--pom.xml6
-rw-r--r--runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml33
-rw-r--r--runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml25
24 files changed, 172 insertions, 2 deletions
diff --git a/common/pom.xml b/common/pom.xml
index d962fc74a..78789a2e7 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -33,4 +33,22 @@
<artifactId>policy-clamp-common</artifactId>
<name>${project.artifactId}</name>
<description>Common utilities and code for the TOSCA Control Loop system</description>
+
+ <build>
+ <plugins>
+ <!-- Builds examples jar -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.2.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java
index ebc9028f4..525da259f 100644
--- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java
+++ b/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java
@@ -139,7 +139,7 @@ public class CommonCommandLineArguments {
}
if (!theFile.canRead()) {
throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is ureadable");
+ fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is unreadable");
}
}
}
diff --git a/common/src/main/resources/examples/controlloop/PMSH/consul_url.txt b/common/src/main/resources/examples/controlloop/PMSH/consul_url.txt
deleted file mode 100644
index e90ded1c6..000000000
--- a/common/src/main/resources/examples/controlloop/PMSH/consul_url.txt
+++ /dev/null
@@ -1 +0,0 @@
-http://consul:31321/v1/kv/dcae-pmsh:policy \ No newline at end of file
diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java
new file mode 100644
index 000000000..2d30592e4
--- /dev/null
+++ b/common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.common.startstop;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.apache.commons.cli.Options;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+public class CommonCommandLineArgumentsTest {
+
+ public static CommonCommandLineArguments cli;
+
+ @BeforeAll
+ static void setup() {
+ cli = new CommonCommandLineArguments(new Options());
+ }
+
+ @Test
+ void testConstructor() {
+ assertThat(cli).isNotNull();
+ }
+
+ @Test
+ void testHelp() {
+ assertThat(cli.help("DummyClass", new Options()))
+ .contains("DummyClass [options...]\noptions");
+ }
+
+ @Test
+ void testVersion() {
+ assertThatCode(() -> cli.version()).doesNotThrowAnyException();
+ }
+
+ @Test
+ void testValidateEmptyFileName() {
+ assertThatThrownBy(() -> cli.validate(""))
+ .hasMessageContaining("file was not specified as an argument");
+ }
+
+ @Test
+ void testValidateFileUrlNull() {
+ assertThatThrownBy(() -> cli.validate("abcd"))
+ .hasMessageContaining("does not exist");
+ }
+
+ @Test
+ void testValidateFileFound() {
+ String configFile = "demo/config/RuntimeConfig.json";
+ assertThatCode(() -> cli.validate(configFile)).doesNotThrowAnyException();
+ }
+
+ @Test
+ void testValidateNotNormalFile() {
+ String badFile = "demo/config";
+ assertThatThrownBy(() -> cli.validate(badFile)).hasMessageContaining("is not a normal file");
+ }
+
+}
diff --git a/common/src/main/resources/examples/controlloop/KubernetesHelm.yaml b/common/src/test/resources/examples/controlloop/KubernetesHelm.yaml
index 2a5f76082..2a5f76082 100644
--- a/common/src/main/resources/examples/controlloop/KubernetesHelm.yaml
+++ b/common/src/test/resources/examples/controlloop/KubernetesHelm.yaml
diff --git a/common/src/main/resources/examples/controlloop/PMSH/consul_call_body.json b/common/src/test/resources/examples/controlloop/PMSH/consul_call_body.json
index 9118e9a6f..9118e9a6f 100644
--- a/common/src/main/resources/examples/controlloop/PMSH/consul_call_body.json
+++ b/common/src/test/resources/examples/controlloop/PMSH/consul_call_body.json
diff --git a/common/src/test/resources/examples/controlloop/PMSH/consul_url.txt b/common/src/test/resources/examples/controlloop/PMSH/consul_url.txt
new file mode 100644
index 000000000..2a2e77e86
--- /dev/null
+++ b/common/src/test/resources/examples/controlloop/PMSH/consul_url.txt
@@ -0,0 +1 @@
+http://consul:31321/v1/kv/dcae-pmsh:policy
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml b/common/src/test/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml
index 7cdc6d5b9..7cdc6d5b9 100644
--- a/common/src/main/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml
+++ b/common/src/test/resources/examples/controlloop/PMSH/pmsh_cloudify_blueprint.yaml
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json b/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json
index 5b64b5b6f..5b64b5b6f 100644
--- a/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json
+++ b/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.json
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml b/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml
index 6021f36bc..6021f36bc 100644
--- a/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml
+++ b/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy.yaml
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml b/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml
index e282bf5ba..e282bf5ba 100644
--- a/common/src/main/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml
+++ b/common/src/test/resources/examples/controlloop/PMSH/pmsh_monitoring_policy_type.yaml
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.json b/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.json
index 6bd681d71..6bd681d71 100644
--- a/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.json
+++ b/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.json
diff --git a/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml b/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml
index faf579012..faf579012 100644
--- a/common/src/main/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml
+++ b/common/src/test/resources/examples/controlloop/PMSH/pmsh_operational_policy.yaml
diff --git a/common/src/main/resources/examples/controlloop/PMSubscriptionHandling.yaml b/common/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml
index f9f97420a..f9f97420a 100644
--- a/common/src/main/resources/examples/controlloop/PMSubscriptionHandling.yaml
+++ b/common/src/test/resources/examples/controlloop/PMSubscriptionHandling.yaml
diff --git a/common/src/main/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml b/common/src/test/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml
index 51e369696..51e369696 100644
--- a/common/src/main/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml
+++ b/common/src/test/resources/examples/controlloop/PMSubscriptionHandling_GuilinFormat.yaml
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml b/common/src/test/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml
index 96ea133c2..96ea133c2 100644
--- a/common/src/main/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml
+++ b/common/src/test/resources/examples/controlloop/original/cloop_DCAE_VES_TCA_substitution.yaml
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_base_types.yaml b/common/src/test/resources/examples/controlloop/original/cloop_base_types.yaml
index 4f29e5635..4f29e5635 100644
--- a/common/src/main/resources/examples/controlloop/original/cloop_base_types.yaml
+++ b/common/src/test/resources/examples/controlloop/original/cloop_base_types.yaml
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_dcae_example.yaml b/common/src/test/resources/examples/controlloop/original/cloop_dcae_example.yaml
index 4629f6f75..4629f6f75 100644
--- a/common/src/main/resources/examples/controlloop/original/cloop_dcae_example.yaml
+++ b/common/src/test/resources/examples/controlloop/original/cloop_dcae_example.yaml
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_dcae_types.yaml b/common/src/test/resources/examples/controlloop/original/cloop_dcae_types.yaml
index 5f96cd5df..5f96cd5df 100644
--- a/common/src/main/resources/examples/controlloop/original/cloop_dcae_types.yaml
+++ b/common/src/test/resources/examples/controlloop/original/cloop_dcae_types.yaml
diff --git a/common/src/main/resources/examples/controlloop/original/cloop_other_types.yaml b/common/src/test/resources/examples/controlloop/original/cloop_other_types.yaml
index d743f499f..d743f499f 100644
--- a/common/src/main/resources/examples/controlloop/original/cloop_other_types.yaml
+++ b/common/src/test/resources/examples/controlloop/original/cloop_other_types.yaml
diff --git a/participant/participant-impl/pom.xml b/participant/participant-impl/pom.xml
index ecc16e633..3d099e747 100644
--- a/participant/participant-impl/pom.xml
+++ b/participant/participant-impl/pom.xml
@@ -78,5 +78,13 @@
<artifactId>policy-clamp-participant-intermediary</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp-common</artifactId>
+ <classifier>tests</classifier>
+ <type>test-jar</type>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/pom.xml b/pom.xml
index b9d0efd98..8661998ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -69,6 +69,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
diff --git a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
index 5fd242282..b3c4edbe6 100644
--- a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
+++ b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
@@ -1543,6 +1543,39 @@
</route>
</post>
+ <get uri="/v2/toscaControlLoop/getToscaInstantiation" outType="java.lang.String" bindingMode="off" produces="application/json">
+ <route>
+ <doTry>
+ <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'GET Tosca Instantiation ')"/>
+ <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')"/>
+ <setHeader name="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setProperty name="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ <to uri="direct:get-tosca-instantiation"/>
+ <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=endLog()"/>
+ <doCatch>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/>
+ <log loggingLevel="ERROR"
+ message="GET Tosca Instantiation JSON request failed: ${exception.stacktrace}"/>
+ <setHeader name="CamelHttpResponseCode">
+ <constant>500</constant>
+ </setHeader>
+ <setBody>
+ <simple>GET Tosca Instantiation JSON FAILED</simple>
+ </setBody>
+ </doCatch>
+ </doTry>
+ </route>
+ </get>
+
<get uri="/v2/clampInformation" outType="org.onap.policy.clamp.clds.model.ClampInformation"
produces="application/json">
<route>
diff --git a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
index 0641b326e..009e00fca 100644
--- a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
+++ b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
@@ -52,4 +52,29 @@
</doFinally>
</doTry>
</route>
+ <route id="get-tosca-instantiation">
+ <from uri="direct:get-tosca-instantiation"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Getting the Tosca instantiation"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('ControlLoop', 'Getting the Tosca instantiation')"/>
+ <setHeader name="CamelHttpMethod">
+ <constant>GET</constant>
+ </setHeader>
+ <setHeader name="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to get Tosca Instantiation: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instantiation"></log>
+ <toD
+ uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instantiation?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.controlloop.runtime.userName}}&amp;authPassword={{clamp.config.controlloop.runtime.password}}&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <convertBodyTo type="java.lang.String"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ </doFinally>
+ </doTry>
+ </route>
</routes>