aboutsummaryrefslogtreecommitdiffstats
path: root/validate
diff options
context:
space:
mode:
authorItohan Ukponmwan <itohan.ukponmwan@intel.com>2019-08-05 16:30:20 +0000
committerGerrit Code Review <gerrit@onap.org>2019-08-05 16:30:20 +0000
commit55f55f93890a2c4745ee89505cc889f54ba3c3dd (patch)
tree5eb804de9b3907b38621a3f5d8169ae3f6a64c21 /validate
parentd53b78f51ed1a37f13163fe0ffd77ebd1c7f6f6f (diff)
parentb9d85a33892c99949aff8e3471eb0fdc039d44aa (diff)
Merge changes I816a1dbb,Ice38da57,I1217d391,I07d22e81,I0ddcdc1c, ...
* changes: Add integration support Update framework Add vf model add artifact command Add service model artifact add command Add VF model checkout command Add VF checkin command Add sdc service resource property set Add sdc consumer-show command Add sdc consumer create command Add ID output in service-model commands Update open-cli.properties Update the sample command OCS YAML Add product into service and schema list Update the version format Update the README Set SNAPSHOT versioning clean-up stale onap profiles Ignore python build artifacts from git
Diffstat (limited to 'validate')
-rw-r--r--validate/pom.xml2
-rw-r--r--validate/sample-mock-generator/pom.xml14
-rw-r--r--validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java9
-rw-r--r--validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java10
-rw-r--r--validate/sample-mock-generator/src/test/java/org/onap/cli/http/mock/MockJsonGeneratorTest.java28
-rw-r--r--validate/sample-yaml-generator/pom.xml14
-rw-r--r--validate/sample-yaml-generator/src/main/java/org/onap/cli/sample/yaml/SampleYamlGenerator.java8
-rw-r--r--validate/sample-yaml-generator/src/test/java/org/onap/cli/sample/yaml/SampleYamlGeneratorTest.java2
-rw-r--r--validate/validation/pom.xml14
9 files changed, 58 insertions, 43 deletions
diff --git a/validate/pom.xml b/validate/pom.xml
index 46a899cc..5c9b9ee2 100644
--- a/validate/pom.xml
+++ b/validate/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.cli</groupId>
<artifactId>cli</artifactId>
- <version>3.0.0</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>cli-validate</artifactId>
diff --git a/validate/sample-mock-generator/pom.xml b/validate/sample-mock-generator/pom.xml
index 6b3eb54c..dfa5b9b7 100644
--- a/validate/sample-mock-generator/pom.xml
+++ b/validate/sample-mock-generator/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.cli</groupId>
<artifactId>cli-validate</artifactId>
- <version>3.0.0</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>cli-sample-mock-generator</artifactId>
@@ -39,6 +39,18 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit-coverage</artifactId>
+ <version>1.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.4</version>
diff --git a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java
index cbb2a26a..d1d8b08d 100644
--- a/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java
+++ b/validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.net.URL;
import java.util.Map;
+import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -61,8 +62,12 @@ public class MockRequest {
public void setJson(String json) throws IOException {
if (!json.isEmpty()) {
- ObjectMapper objectMapper = new ObjectMapper();
- this.json = objectMapper.readTree(json);
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ this.json = objectMapper.readTree(json);
+ } catch (Exception e) {
+ this.json = new ObjectMapper().readTree("{}");
+ }
}
}
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 7e8cdca8..d7999bea 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,9 +38,13 @@ public class MockResponse {
}
public void setJson(String json) throws IOException {
- if (json != null && !json.isEmpty()) {
- ObjectMapper objectMapper = new ObjectMapper();
- this.json = objectMapper.readTree(json);
+ if (!json.isEmpty()) {
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ this.json = objectMapper.readTree(json);
+ } catch (Exception e) {
+ this.json = new ObjectMapper().readTree("{}");
+ }
}
}
}
diff --git a/validate/sample-mock-generator/src/test/java/org/onap/cli/http/mock/MockJsonGeneratorTest.java b/validate/sample-mock-generator/src/test/java/org/onap/cli/http/mock/MockJsonGeneratorTest.java
index 3b79057f..0e0c0f59 100644
--- a/validate/sample-mock-generator/src/test/java/org/onap/cli/http/mock/MockJsonGeneratorTest.java
+++ b/validate/sample-mock-generator/src/test/java/org/onap/cli/http/mock/MockJsonGeneratorTest.java
@@ -34,32 +34,4 @@ public class MockJsonGeneratorTest {
MockJsonGenerator.generateMocking(mockRequest, mockResponse, "target/test");
}
-
- @Test(expected=IOException.class)
- public void mocoGenerateFailedInvalidBodyTest() throws IOException {
- MockRequest mockRequest = new MockRequest();
- mockRequest.setJson("{\"value\" : \"234sdf-345\"");
- mockRequest.setMethod("get");
- mockRequest.setUri("http://1.1.1.1:80/getResource");
-
- MockResponse mockResponse = new MockResponse();
- mockResponse.setStatus(200);
- mockResponse.setJson("{\"value\" : \"234sdf-345\"");
-
- MockJsonGenerator.generateMocking(mockRequest, mockResponse, "target/test");
- }
-
- @Test(expected=IOException.class)
- public void mocoGenerateFailedInvalidUrlTest() throws IOException {
- MockRequest mockRequest = new MockRequest();
- mockRequest.setJson("{\"value\" : \"234sdf-345\"");
- mockRequest.setMethod("get");
- mockRequest.setUri("http://1.1.1.1:80:invalid");
-
- MockResponse mockResponse = new MockResponse();
- mockResponse.setStatus(200);
- mockResponse.setJson("{\"value\" : \"234sdf-345\"");
-
- MockJsonGenerator.generateMocking(mockRequest, mockResponse, "target/test");
- }
}
diff --git a/validate/sample-yaml-generator/pom.xml b/validate/sample-yaml-generator/pom.xml
index 400d72f1..c9503c5e 100644
--- a/validate/sample-yaml-generator/pom.xml
+++ b/validate/sample-yaml-generator/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.cli</groupId>
<artifactId>cli-validate</artifactId>
- <version>3.0.0</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>cli-sample-yaml-generator</artifactId>
@@ -38,6 +38,18 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit-coverage</artifactId>
+ <version>1.19</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
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 179eaa36..b2e2dc88 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
@@ -27,11 +27,9 @@ public class SampleYamlGenerator {
static int nTab;
- public static void generateSampleYaml(List<String> input, String output, String version,
+ public static void generateSampleYaml(String cmdName, List<String> input, String output, String version,
String targetPath, boolean debug) throws IOException {
- String cmdName = input.get(0);
-
PrintWriter writer = new PrintWriter(targetPath, "UTF-8");
writeKeyValuePair(writer, "open_cli_sample_version", "1.0");
writeKeyValuePair(writer, "name", cmdName);
@@ -41,7 +39,7 @@ public class SampleYamlGenerator {
writeKey(writer, "sample1");
writeKeyValuePair(writer, "name", cmdName);
- writeKeyValuePair(writer, "input", input.stream().skip(1).collect(Collectors.joining(" ")).trim());
+ writeKeyValuePair(writer, "input", input.stream().collect(Collectors.joining(" ")).trim());
writeKeyValuePair(writer, "moco", new File(targetPath).getName().replaceAll("-sample.yaml", "-moco.json"));
writeMultilineKeyValue(writer, "output", output.trim(), debug);
@@ -60,7 +58,7 @@ public class SampleYamlGenerator {
writer.write(" |\n");
nTab++;
String[] lines = value.split("\n");
- long skipLines = debug ? 11 : 0;
+ long skipLines = debug ? 0 : 0;
Arrays.stream(lines).skip(skipLines ).forEach(line -> writer.write(printTabs() + line + "\n")); // NOSONAR
}
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 98c0ce9d..fba93e62 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
@@ -25,7 +25,7 @@ public class SampleYamlGeneratorTest {
@Test
public void testGenerateSampleYaml() throws IOException {
- SampleYamlGenerator.generateSampleYaml(Arrays.asList("testcmd", "-a", "argument"),
+ SampleYamlGenerator.generateSampleYaml("testcmd", Arrays.asList("-a", "argument"),
"+--------+\n+val +\n+argument+", "test-version-1.0", "target/test.yaml", false);
}
diff --git a/validate/validation/pom.xml b/validate/validation/pom.xml
index 7767913c..526aa0f6 100644
--- a/validate/validation/pom.xml
+++ b/validate/validation/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.cli</groupId>
<artifactId>cli-validate</artifactId>
- <version>3.0.0</version>
+ <version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>cli-validation</artifactId>
@@ -38,6 +38,18 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit-coverage</artifactId>
+ <version>1.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.onap.cli</groupId>
<artifactId>cli-main</artifactId>
<version>${project.version}</version>