aboutsummaryrefslogtreecommitdiffstats
path: root/validate
diff options
context:
space:
mode:
authorKanagaraj Manickam <kanagaraj.manickam@huawei.com>2017-10-26 14:52:45 +0000
committerGerrit Code Review <gerrit@onap.org>2017-10-26 14:52:45 +0000
commit5090b19cde7127ff532d422a7b18e16e2d374da2 (patch)
treec32d42c8c37e52ce9f3368ba048ed397d5a30470 /validate
parent9d1818327ce7aeb2839fec218c99e5cd89d77b9d (diff)
parent3993f730f33d81a6a1ae50eccca9ab926702ec30 (diff)
Merge changes I3bc55b53,Iff6d1f16,I19bdb8a1,Ia90bd215,I84533921
* changes: Remove the stale samples for cloud commands Add samples for cloud-delete Add samples for cloud-list Add samples for cloud-create command Fix the sample file name align with schema
Diffstat (limited to 'validate')
-rw-r--r--validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockJsonGenerator.java5
-rw-r--r--validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java2
-rw-r--r--validate/sample-yaml-generator/src/main/java/org/onap/cli/sample/yaml/SampleYamlGenerator.java7
-rw-r--r--validate/sample-yaml-generator/src/test/java/org/onap/cli/sample/yaml/SampleYamlGeneratorTest.java2
4 files changed, 7 insertions, 9 deletions
diff --git a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockJsonGenerator.java b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockJsonGenerator.java
index c3006e32..4b2e116c 100644
--- a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockJsonGenerator.java
+++ b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockJsonGenerator.java
@@ -17,9 +17,7 @@ package org.onap.cli.http.mock;
import java.io.File;
import java.io.IOException;
-import java.text.SimpleDateFormat;
import java.util.Arrays;
-import java.util.Date;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -35,8 +33,7 @@ public class MockJsonGenerator {
ObjectMapper mapper = new ObjectMapper();
ObjectWriter writer = mapper.writer(new DefaultPrettyPrinter());
- String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
- writer.writeValue(new File(jsonFilePath + "-" + timeStamp + "-moco.json"),
+ writer.writeValue(new File(jsonFilePath),
Arrays.asList(mockObject));
}
}
diff --git a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java
index 2b8fa826..7e8cdca8 100644
--- a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java
+++ b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java
@@ -38,7 +38,7 @@ public class MockResponse {
}
public void setJson(String json) throws IOException {
- if (!json.isEmpty()) {
+ if (json != null && !json.isEmpty()) {
ObjectMapper objectMapper = new ObjectMapper();
this.json = objectMapper.readTree(json);
}
diff --git a/validate/sample-yaml-generator/src/main/java/org/onap/cli/sample/yaml/SampleYamlGenerator.java b/validate/sample-yaml-generator/src/main/java/org/onap/cli/sample/yaml/SampleYamlGenerator.java
index e18b1d73..9a59cdf6 100644
--- a/validate/sample-yaml-generator/src/main/java/org/onap/cli/sample/yaml/SampleYamlGenerator.java
+++ b/validate/sample-yaml-generator/src/main/java/org/onap/cli/sample/yaml/SampleYamlGenerator.java
@@ -16,6 +16,7 @@
package org.onap.cli.sample.yaml;
+import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
@@ -27,11 +28,11 @@ public class SampleYamlGenerator {
static int nTab;
public static void generateSampleYaml(List<String> input, String ouput, String version,
- String targetFolder, boolean debug) throws IOException {
+ String targetPath, boolean debug) throws IOException {
String cmdName = input.get(0);
- PrintWriter writer = new PrintWriter(targetFolder + "/" + cmdName + "-sample.yaml", "UTF-8");
+ PrintWriter writer = new PrintWriter(targetPath, "UTF-8");
writeKeyValuePair(writer, "onap_cli_sample_version", "1.0");
writeKeyValuePair(writer, "name", cmdName);
writeKeyValuePair(writer, "version", version);
@@ -41,7 +42,7 @@ public class SampleYamlGenerator {
writeKeyValuePair(writer, "name", cmdName);
writeKeyValuePair(writer, "input", input.stream().skip(1).collect(Collectors.joining(" ")));
- writeKeyValuePair(writer, "moco", cmdName + "-sample-yaml.yaml");
+ writeKeyValuePair(writer, "moco", new File(targetPath).getName().replaceAll("-sample.yaml", "-moco.json"));
writeMultilineKeyValue(writer, "ouput", ouput, debug);
writeEndKey();
diff --git a/validate/sample-yaml-generator/src/test/java/org/onap/cli/sample/yaml/SampleYamlGeneratorTest.java b/validate/sample-yaml-generator/src/test/java/org/onap/cli/sample/yaml/SampleYamlGeneratorTest.java
index c98cb71b..98c0ce9d 100644
--- a/validate/sample-yaml-generator/src/test/java/org/onap/cli/sample/yaml/SampleYamlGeneratorTest.java
+++ b/validate/sample-yaml-generator/src/test/java/org/onap/cli/sample/yaml/SampleYamlGeneratorTest.java
@@ -26,7 +26,7 @@ public class SampleYamlGeneratorTest {
@Test
public void testGenerateSampleYaml() throws IOException {
SampleYamlGenerator.generateSampleYaml(Arrays.asList("testcmd", "-a", "argument"),
- "+--------+\n+val +\n+argument+", "test-version-1.0", "target", false);
+ "+--------+\n+val +\n+argument+", "test-version-1.0", "target/test.yaml", false);
}
}