diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/pom.xml | 18 | ||||
-rw-r--r-- | common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java | 2 | ||||
-rw-r--r-- | common/src/main/resources/examples/controlloop/PMSH/consul_url.txt | 1 | ||||
-rw-r--r-- | common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java | 80 | ||||
-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.txt | 1 | ||||
-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 |
20 files changed, 100 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 |