aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sdc/src/main/resources/onap-cli-schema/vsp/vsp-create-schema.yaml7
-rw-r--r--plugins/so/src/main/resources/onap-cli-schema/services/service-create-schema-1.1.yaml8
-rw-r--r--plugins/so/src/main/resources/onap-cli-schema/services/service-delete-schema-1.1.yaml6
-rw-r--r--plugins/so/src/main/resources/onap-cli-schema/services/vf-create-schema-1.1.yaml11
-rw-r--r--plugins/so/src/main/resources/onap-cli-schema/services/vf-delete-schema-1.1.yaml4
-rw-r--r--plugins/so/src/main/resources/onap-cli-schema/services/vfmodule-create-schema-1.1.yaml14
-rw-r--r--validate/validation/src/test/java/org/onap/cli/moco/OnapCommandHttpMocoServer.java64
-rw-r--r--validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java44
8 files changed, 148 insertions, 10 deletions
diff --git a/plugins/sdc/src/main/resources/onap-cli-schema/vsp/vsp-create-schema.yaml b/plugins/sdc/src/main/resources/onap-cli-schema/vsp/vsp-create-schema.yaml
index bdc77563..4ce83d4b 100644
--- a/plugins/sdc/src/main/resources/onap-cli-schema/vsp/vsp-create-schema.yaml
+++ b/plugins/sdc/src/main/resources/onap-cli-schema/vsp/vsp-create-schema.yaml
@@ -24,39 +24,46 @@ parameters:
- name: vsp-category
description: Category of the VSP
type: string
+ short_option: b
long_option: vsp-category
is_optional: true
default_value: resourceNewCategory.generic
- name: vsp-subcategory
description: Sub Category of VSP
type: string
+ short_option: c
long_option: vsp-subcategory
is_optional: true
default_value: resourceNewCategory.generic.abstract
- name: vlm-version
description: License version
type: string
+ short_option: e
long_option: vlm-version
is_optional: true
default_value: 1.0
- name: vlm-vendor
description: License Model Name
type: string
+ short_option: g
long_option: vlm-vendor
is_optional: false
- name: vlm-id
description: License Model ID
type: string
+ short_option: i
long_option: vlm-id
is_optional: false
- name: vlm-agreement-id
description: License Agreement ID
type: string
+ short_option: j
long_option: vlm-agreement-id
is_optional: false
- name: vlm-feature-group-id
description: Feature Group ID
type: string
+ short_option: k
long_option: vlm-feature-group-id
is_optional: false
results:
diff --git a/plugins/so/src/main/resources/onap-cli-schema/services/service-create-schema-1.1.yaml b/plugins/so/src/main/resources/onap-cli-schema/services/service-create-schema-1.1.yaml
index a4593644..31fca411 100644
--- a/plugins/so/src/main/resources/onap-cli-schema/services/service-create-schema-1.1.yaml
+++ b/plugins/so/src/main/resources/onap-cli-schema/services/service-create-schema-1.1.yaml
@@ -12,31 +12,37 @@ parameters:
- name: cloud-region
description: cloud region identifier
type: string
+ short_option: k
long_option: cloud-region
is_optional: false
- name: tenant-id
description: tenant id
type: string
+ short_option: b
long_option: tenant-id
is_optional: false
- name: model-invariant-id
description: model invariant id generated by ASDC.
type: string
+ short_option: e
long_option: model-invariant-id
is_optional: false
- name: model-uuid
description: model uuid generated by ASDC.
type: string
+ short_option: g
long_option: model-uuid
is_optional: false
- name: model-name
description: model name as provided in ASDC design time.
type: string
+ short_option: i
long_option: model-name
is_optional: false
- name: model-version
description: model-version
type: string
+ short_option: j
long_option: model-version
is_optional: false
- name: customer
@@ -48,7 +54,7 @@ parameters:
- name: instance-name
description: service instance name
type: string
- short_option: i
+ short_option: k
long_option: instance-name
is_optional: false
- name: supress-rollback
diff --git a/plugins/so/src/main/resources/onap-cli-schema/services/service-delete-schema-1.1.yaml b/plugins/so/src/main/resources/onap-cli-schema/services/service-delete-schema-1.1.yaml
index 4c6e4a92..42ba27ae 100644
--- a/plugins/so/src/main/resources/onap-cli-schema/services/service-delete-schema-1.1.yaml
+++ b/plugins/so/src/main/resources/onap-cli-schema/services/service-delete-schema-1.1.yaml
@@ -18,21 +18,25 @@ parameters:
- name: model-invariant-id
description: model invariant id for service in SDC catalog
type: string
+ short_option: b
long_option: model-invariant-id
is_optional: false
- name: model-uuid
description: model uuid for service in SDC catalog
type: string
+ short_option: i
long_option: model-uuid
is_optional: false
- name: model-name
description: model name available in SDC catalog
type: string
+ short_option: e
long_option: model-name
is_optional: false
- name: model-version
description: model version of service (eg. 1.0)
type: string
+ short_option: g
long_option: model-version
is_optional: false
- name: customer-name
@@ -44,11 +48,13 @@ parameters:
- name: cloud-region
description: cloud region id
type: string
+ short_option: j
long_option: cloud-region
is_optional: false
- name: tenant-id
description: tenant id
type: string
+ short_option: k
long_option: tenant-id
is_optional: false
diff --git a/plugins/so/src/main/resources/onap-cli-schema/services/vf-create-schema-1.1.yaml b/plugins/so/src/main/resources/onap-cli-schema/services/vf-create-schema-1.1.yaml
index 8b1d4af7..2c364d72 100644
--- a/plugins/so/src/main/resources/onap-cli-schema/services/vf-create-schema-1.1.yaml
+++ b/plugins/so/src/main/resources/onap-cli-schema/services/vf-create-schema-1.1.yaml
@@ -30,7 +30,7 @@ parameters:
- name: instance-name
description: service instance name
type: string
- short_option: i
+ short_option: o
long_option: instance-name
is_optional: false
- name: service-instance-id
@@ -42,46 +42,55 @@ parameters:
- name: vf-model-invariant-id
description: vf model invariant id
type: string
+ short_option: b
long_option: vf-model-invariant-id
is_optional: false
- name: vf-model-uuid
description: model uuid for vf
type: string
+ short_option: c
long_option: vf-model-uuid
is_optional: false
- name: vf-model-name
description: vf model name
type: string
+ short_option: e
long_option: vf-model-name
is_optional: false
- name: vf-model-version
description: vf model version
type: string
+ short_option: g
long_option: vf-model-version
is_optional: false
- name: vf-model-customization-id
description: vf model customization id
type: string
+ short_option: i
long_option: vf-model-customization-id
is_optional: false
- name: service-model-invariant-id
description: model invariant id
type: string
+ short_option: j
long_option: service-model-invariant-id
is_optional: false
- name: service-model-uuid
description: model name version id
type: string
+ short_option: k
long_option: service-model-uuid
is_optional: false
- name: service-model-name
description: service model name
type: string
+ short_option: q
long_option: service-model-name
is_optional: false
- name: service-model-version
description: service model version
type: string
+ short_option: n
long_option: service-model-version
is_optional: false
diff --git a/plugins/so/src/main/resources/onap-cli-schema/services/vf-delete-schema-1.1.yaml b/plugins/so/src/main/resources/onap-cli-schema/services/vf-delete-schema-1.1.yaml
index 51609cc5..b34d1b59 100644
--- a/plugins/so/src/main/resources/onap-cli-schema/services/vf-delete-schema-1.1.yaml
+++ b/plugins/so/src/main/resources/onap-cli-schema/services/vf-delete-schema-1.1.yaml
@@ -35,21 +35,25 @@ parameters:
- name: model-invariant-id
description: model invariant id for service in SDC catalog
type: string
+ short_option: b
long_option: model-invariant-id
is_optional: false
- name: model-uuid
description: model uuid for service in SDC catalog
type: string
+ short_option: c
long_option: model-uuid
is_optional: false
- name: model-name
description: model name available in SDC catalog
type: string
+ short_option: e
long_option: model-name
is_optional: false
- name: model-version
description: model version of service (eg. 1.0)
type: string
+ short_option: g
long_option: model-version
is_optional: false
http:
diff --git a/plugins/so/src/main/resources/onap-cli-schema/services/vfmodule-create-schema-1.1.yaml b/plugins/so/src/main/resources/onap-cli-schema/services/vfmodule-create-schema-1.1.yaml
index 74127e92..bb018b5b 100644
--- a/plugins/so/src/main/resources/onap-cli-schema/services/vfmodule-create-schema-1.1.yaml
+++ b/plugins/so/src/main/resources/onap-cli-schema/services/vfmodule-create-schema-1.1.yaml
@@ -18,27 +18,30 @@ parameters:
- name: tenant-id
description: openstack tenant id
type: string
- short_option: z
long_option: tenant-id
is_optional: false
- name: vfmodule-invariant-id
description: vfmodule model invariant id
type: string
+ short_option: b
long_option: vfmodule-invariant-id
is_optional: false
- name: vfmodule-uuid
description: model uuid for vfmodule
type: string
+ short_option: c
long_option: vfmodule-uuid
is_optional: false
- name: vfmodule-name
description: vfmodule model name
type: string
+ short_option: e
long_option: vfmodule-name
is_optional: false
- name: vfmodule-version
description: vf module version
type: string
+ short_option: g
long_option: vfmodule-version
is_optional: false
- name: module-name
@@ -50,6 +53,7 @@ parameters:
- name: service-id
description: unique id for service
type: string
+ short_option: j
long_option: service-id
is_optional: false
- name: vf-id
@@ -61,6 +65,7 @@ parameters:
- name: vf-model-invariant-id
description: vf model invariant id
type: string
+ short_option: k
long_option: vf-model-invariant-id
is_optional: false
- name: vf-model-uuid
@@ -71,36 +76,43 @@ parameters:
- name: vf-model-name
description: vf model name
type: string
+ short_option: n
long_option: vf-model-name
is_optional: false
- name: vf-model-version
description: vf model version
type: string
+ short_option: o
long_option: vf-model-version
is_optional: false
- name: vf-model-customization-id
description: vf model customization id
type: string
+ short_option: q
long_option: vf-model-customization-id
is_optional: false
- name: service-model-invariant-id
description: model invariant id
type: string
+ short_option: r
long_option: service-model-invariant-id
is_optional: false
- name: service-model-uuid
description: model name version id
type: string
+ short_option: w
long_option: service-model-uuid
is_optional: false
- name: service-model-name
description: service model name
type: string
+ short_option: x
long_option: service-model-name
is_optional: false
- name: service-model-version
description: service model version
type: string
+ short_option: z
long_option: service-model-version
is_optional: false
diff --git a/validate/validation/src/test/java/org/onap/cli/moco/OnapCommandHttpMocoServer.java b/validate/validation/src/test/java/org/onap/cli/moco/OnapCommandHttpMocoServer.java
index a3e23a64..488c6193 100644
--- a/validate/validation/src/test/java/org/onap/cli/moco/OnapCommandHttpMocoServer.java
+++ b/validate/validation/src/test/java/org/onap/cli/moco/OnapCommandHttpMocoServer.java
@@ -16,18 +16,25 @@
package org.onap.cli.moco;
+import static com.github.dreamhead.moco.Moco.pathResource;
import static com.github.dreamhead.moco.MocoJsonRunner.jsonHttpServer;
import static com.github.dreamhead.moco.Runner.runner;
-import static com.github.dreamhead.moco.Moco.pathResource;
-import static com.github.dreamhead.moco.Moco.file;
import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStream;
import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Stream;
import org.onap.cli.fw.OnapCommandRegistrar;
import org.onap.cli.fw.error.OnapCommandException;
@@ -78,6 +85,35 @@ public class OnapCommandHttpMocoServer {
public OnapCommandHttpMocoServer() {
}
+ public static Map<String, List<OnapCommandSample>> discoverYamls(File path) throws IOException {
+ Map<String, List<OnapCommandSample>> cliProductSamples = new HashMap<>();
+
+ Stream<Path> walk = Files.walk(path.toPath());
+ walk.filter(p -> (p.toString().contains("src/test/resources/onap-cli-sample")))
+ .filter(p -> p.toString().endsWith("sample.yaml"))
+ .forEach(p -> {
+ collectSamples(new File(p.toUri()), cliProductSamples);
+ });
+
+ return cliProductSamples;
+ }
+
+ private static void collectSamples(File file, Map<String, List<OnapCommandSample>> result) {
+ OnapCommandHttpMocoServer onapCommandHttpMocoServer = new OnapCommandHttpMocoServer();
+ List<OnapCommandSample> loadSamples;
+ try {
+ loadSamples = onapCommandHttpMocoServer.loadSamples(file);
+ loadSamples.stream().forEach(sample -> {
+ if (!result.containsKey(sample.getProduct())) {
+ result.put(sample.getProduct(), new ArrayList<>());
+ }
+ result.get(sample.getProduct()).add(sample);
+ });
+ } catch (OnapCommandInvalidSample e) {
+ LOG.error("Failed to read sample file", e);
+ }
+ }
+
private List<Resource> dicoverSampleYamls() {
Resource[] resources = new Resource [] {};
try {
@@ -98,20 +134,19 @@ public class OnapCommandHttpMocoServer {
return "";
}
- private List<OnapCommandSample> loadSamples(Resource file) throws OnapCommandInvalidSample {
-
+ public List<OnapCommandSample> loadSamples(InputStream inputStream, String fileName) throws OnapCommandInvalidSample {
List<OnapCommandSample> samples = new ArrayList<>();
Map<String, ?> values = null;
try {
- values = (Map<String, ?>) new Yaml().load(file.getInputStream());
+ values = (Map<String, ?>) new Yaml().load(inputStream);
} catch (Exception e) {
- throw new OnapCommandInvalidSample(file.getFilename(), e);
+ throw new OnapCommandInvalidSample(fileName, e);
}
OnapCommandSample sample = new OnapCommandSample();
if (!this.getValue(values, SAMPLE_VERSION).equals(SAMPLE_VERSION_1_0)) {
- throw new OnapCommandInvalidSample(file.getFilename(), "Invalid sample version " + this.getValue(values, SAMPLE_VERSION));
+ throw new OnapCommandInvalidSample(fileName, "Invalid sample version " + this.getValue(values, SAMPLE_VERSION));
}
sample.setCommandName(this.getValue(values, SAMPLE_COMMAND_NAME));
@@ -132,6 +167,21 @@ public class OnapCommandHttpMocoServer {
return samples;
}
+ public List<OnapCommandSample> loadSamples(Resource file) throws OnapCommandInvalidSample {
+ try {
+ return loadSamples(file.getInputStream(), file.getFilename());
+ } catch (IOException e) {
+ throw new OnapCommandInvalidSample(file.getFilename(), e);
+ }
+ }
+
+ public List<OnapCommandSample> loadSamples(File file) throws OnapCommandInvalidSample {
+ try {
+ return loadSamples(new FileInputStream(file), file.getName());
+ } catch (FileNotFoundException e) {
+ throw new OnapCommandInvalidSample(file.getName(), e);
+ }
+ }
private void verifySample(OnapCommandSample sample) throws OnapCommandException {
List <String> args = new ArrayList<>();
diff --git a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
index f2c27fc7..71d015b5 100644
--- a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
+++ b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
@@ -16,8 +16,15 @@
package org.onap.cli.validation;
+import static org.junit.Assert.fail;
+
+import java.io.File;
import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.io.FileUtils;
import org.aspectj.lang.annotation.After;
import org.junit.Ignore;
import org.junit.Test;
@@ -26,6 +33,7 @@ import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.utils.ExternalSchema;
import org.onap.cli.main.OnapCli;
import org.onap.cli.moco.OnapCommandHttpMocoServer;
+import org.onap.cli.moco.OnapCommandSample;
public class OnapValidationTest {
@@ -83,4 +91,40 @@ public class OnapValidationTest {
server.verifySamples();
}
+ @Test
+ public void collectSampleYamlTest() {
+ try {
+ File root = new File("../../");
+ String sampleFileName = "target/sample.rst";
+
+ FileUtils.deleteQuietly(new File(sampleFileName));
+ Map<String, List<OnapCommandSample>> discoveredYamls = OnapCommandHttpMocoServer.discoverYamls(root);
+
+ writeSamples(new File(sampleFileName), discoveredYamls);
+ } catch (IOException e) {
+ fail();
+ }
+ }
+
+ private void writeSamples(File dest, Map<String, List<OnapCommandSample>> cliProductSamples) throws IOException {
+
+ for (String product: cliProductSamples.keySet()) {
+ FileUtils.write(dest, "\n" + product, "UTF-8", true);
+ FileUtils.write(dest, "\n========\n\n", "UTF-8", true);
+
+ for(OnapCommandSample sample: cliProductSamples.get(product)) {
+ FileUtils.write(dest, "\n\n" + sample.getCommandName(), "UTF-8", true);
+ FileUtils.write(dest, "\n" + String.join("", Collections.nCopies(sample.getCommandName().length(), "-"))+ "\n", "UTF-8", true);
+
+ if (!sample.getInput().isEmpty()) {
+ FileUtils.write(dest, "\ninput::\n\n " + sample.getInput() + "\n", "UTF-8", true);
+ }
+
+ if (!sample.getOutput().isEmpty()) {
+ FileUtils.write(dest, "\noutput::\n\n " + sample.getOutput().replaceAll("\n", "\n ").trim(), "UTF-8", true);
+ }
+ }
+ }
+ }
+
}