summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerban Jora <sj2381@att.com>2018-04-10 15:33:46 -0400
committerSerban Jora <sj2381@att.com>2018-04-10 16:02:37 -0400
commitfd3287187e487d8b0789484def296074e985b7cb (patch)
treedb5e50544ac9fa515be5a647a8489815131ab711
parentdc3ecc22915249d0fb542ab23b400abd6b5ef620 (diff)
Add more unit testing
Unit testing for kwalify parser and validator and for domain model representation. Fix oparent reference in pom in datse format in docker image tag. Change-Id: Icca11ae7fc773cae3de910acb10fcacd51b909a4 Signed-off-by: Serban Jora <sj2381@att.com> Issue-ID: MODELING-53 Signed-off-by: Serban Jora <sj2381@att.com>
-rw-r--r--javatoscachecker/checker/pom.xml2
-rw-r--r--javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Capability.java4
-rw-r--r--javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Constraint.java6
-rw-r--r--javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/TOSCAProxy.java7
-rw-r--r--javatoscachecker/checker/src/test/java/org/onap/tosca/checker/test/ModelTest.java87
-rw-r--r--javatoscachecker/checker/src/test/resources/models/full.yaml48
-rw-r--r--javatoscachecker/kwalify/pom.xml15
-rw-r--r--javatoscachecker/kwalify/src/test/java/kwalify/test/ParserTest.java300
-rw-r--r--javatoscachecker/kwalify/src/test/java/kwalify/test/ValidatorTest.java150
-rw-r--r--javatoscachecker/kwalify/src/test/resources/invalidateMap.yml16
-rw-r--r--javatoscachecker/kwalify/src/test/resources/invalidateMapOfSeq.yml21
-rw-r--r--javatoscachecker/kwalify/src/test/resources/invalidateRule.yml24
-rw-r--r--javatoscachecker/kwalify/src/test/resources/invalidateSeq.yml15
-rw-r--r--javatoscachecker/kwalify/src/test/resources/invalidateSeqOfMap.yml18
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserFailIndentation.yml40
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserFailInvalidAnchor.yml40
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccess.yml40
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessFloats.yml17
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessInts.yml16
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfMap.yml18
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfSeqToSeq.yml21
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToScalar.yml15
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToSeq.yml20
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessMultipleDocs.yml21
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessOrderedMap.yml19
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessQuotedStrings.yml18
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfMap.yml20
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfScalar.yml15
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfSeq.yml15
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessTimestamps.yml16
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessTypeTags.yml25
-rw-r--r--javatoscachecker/kwalify/src/test/resources/parserSuccessUnorderedSet.yml19
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateMap.yml16
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateMapOfSeq.yml21
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateMapOfSeqSchema.yml20
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateMapSchema.yml12
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateRule.yml23
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateRuleSchema.yml30
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateSeq.yml15
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateSeqOfMap.yml18
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateSeqOfMapSchema.yml9
-rw-r--r--javatoscachecker/kwalify/src/test/resources/validateSeqSchema.yml3
-rw-r--r--javatoscachecker/pom.xml15
-rw-r--r--javatoscachecker/service/pom.xml10
44 files changed, 1260 insertions, 40 deletions
diff --git a/javatoscachecker/checker/pom.xml b/javatoscachecker/checker/pom.xml
index fc2a2c1..ee1d37b 100644
--- a/javatoscachecker/checker/pom.xml
+++ b/javatoscachecker/checker/pom.xml
@@ -18,7 +18,7 @@
<parent>
<groupId>org.onap.modeling.toscaparsers</groupId>
<artifactId>checker</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>Checker</artifactId>
<packaging>jar</packaging>
diff --git a/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Capability.java b/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Capability.java
index 72df0b7..eaf72c9 100644
--- a/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Capability.java
+++ b/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Capability.java
@@ -20,6 +20,10 @@ import java.util.List;
public interface Capability extends TOSCAObject<Capability> {
/**
+ */
+ public String name();
+
+ /**
* The required name of the Capability Type the capability definition is based upon.
*/
public String type();
diff --git a/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Constraint.java b/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Constraint.java
index 03c8d20..622b75c 100644
--- a/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Constraint.java
+++ b/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/Constraint.java
@@ -17,7 +17,11 @@ package org.onap.tosca.checker.model;
*/
public interface Constraint extends TOSCAObject<Constraint> {
- public Constraint.Type name();
+ public String name();
+
+ public default Constraint.Type type() {
+ return Type.valueOf(Type.class, name());
+ }
/* this is a one entry map so here we pick the single
*/
diff --git a/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/TOSCAProxy.java b/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/TOSCAProxy.java
index bce8675..c5339e4 100644
--- a/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/TOSCAProxy.java
+++ b/javatoscachecker/checker/src/main/java/org/onap/tosca/checker/model/TOSCAProxy.java
@@ -95,9 +95,12 @@ public class TOSCAProxy
* This is targeted at lists of one entry maps seen in in the TOSCA spec
*/
public static <T extends TOSCASeq> T buildSeq(final List<Map> theInfo, Class<T> theType) {
- theInfo.replaceAll((value) -> { Map.Entry<String,Map> entry = (Map.Entry<String,Map>)
+ theInfo.replaceAll((value) -> { Map.Entry<String,?> entry = (Map.Entry<String,?>)
value.entrySet().iterator().next();
- return buildObject(entry.getKey(), entry.getValue(), typeArgument(theType));
+
+ return entry.getValue() instanceof Map ?
+ buildObject(entry.getKey(), (Map)entry.getValue(), typeArgument(theType)) :
+ buildObject(entry.getKey(), Collections.singletonMap("value", entry.getValue()), typeArgument(theType));
});
return (T)java.lang.reflect.Proxy.newProxyInstance(
TOSCAProxy.class.getClassLoader(),
diff --git a/javatoscachecker/checker/src/test/java/org/onap/tosca/checker/test/ModelTest.java b/javatoscachecker/checker/src/test/java/org/onap/tosca/checker/test/ModelTest.java
index d6b3d8b..b01b387 100644
--- a/javatoscachecker/checker/src/test/java/org/onap/tosca/checker/test/ModelTest.java
+++ b/javatoscachecker/checker/src/test/java/org/onap/tosca/checker/test/ModelTest.java
@@ -71,14 +71,29 @@ public class ModelTest {
assertTrue(template.data_types() != null);
- for (Map.Entry<String, DataType> type: template.data_types().entrySet()) {
- assertTrue(type.getKey().startsWith("data_type_"));
+ for (DataType type: template.data_types().values()) {
+ assertTrue(type.name().startsWith("data_type_"));
+ assertTrue(type.description().startsWith("test data type"));
+ assertTrue(type.version().equals("1.0"));
- Properties props = type.getValue().properties();
+ Properties props = type.properties();
assertTrue(props != null);
- for (Map.Entry<String, Property> prop: props.entrySet()) {
- assertTrue(prop.getKey().startsWith("data_field_"));
+ for (Property prop: props.values()) {
+ assertTrue("property name prefix " + prop.name(), prop.name().startsWith("data_field_"));
+ assertTrue("property description prefix " + prop.description(), prop.description().startsWith("test data field"));
+ assertTrue(prop.required());
+
+ String propType = prop.type();
+ assertTrue(propType != null && (propType.equals("string") || propType.equals("integer")));
+
+ Constraints constraints = prop.constraints();
+ if (constraints != null) {
+ if ("integer".equals(propType))
+ assertTrue("integer constraints", constraints.get(0).name().equals("valid_values"));
+ if ("string".equals(propType))
+ assertTrue("string constraints", constraints.get(0).name().equals("max_length"));
+ }
}
}
}
@@ -104,13 +119,13 @@ public class ModelTest {
assertTrue(template.interface_types() != null);
for (Map.Entry<String, InterfaceType> type: template.interface_types().entrySet()) {
- assertTrue(type.getKey().matches("interface_type_[0-9]"));
+ assertTrue(type.getKey(), type.getKey().matches("interface_type_[0-9]"));
Operations ops = type.getValue().operations();
- assertTrue(ops != null);
-
- for (Map.Entry<String, Operation> op: ops.entrySet()) {
- assertTrue(op.getKey().matches("interface_type_[0-9]_op_[0-9]"));
+ if(ops != null) {
+ for (Map.Entry<String, Operation> op: ops.entrySet()) {
+ assertTrue(op.getKey().matches("interface_type_[0-9]_op_[0-9]"));
+ }
}
}
}
@@ -120,13 +135,13 @@ public class ModelTest {
assertTrue(template.relationship_types() != null);
for (Map.Entry<String, RelationshipType> type: template.relationship_types().entrySet()) {
- assertTrue(type.getKey().matches("relationship_type_[0-9]"));
+ assertTrue(type.getKey().matches("relationship_type_[0-9][0-9]"));
TypeInterfaces infs = type.getValue().interfaces();
assertTrue(infs != null);
for (Map.Entry<String, TypeInterface> inf: infs.entrySet()) {
- assertTrue(inf.getKey().matches("relationship_type_[0-9]_interface_[0-9]"));
+ assertTrue(inf.getKey().matches("relationship_type_[0-9]+_interface_[0-9]+"));
}
}
}
@@ -135,15 +150,42 @@ public class ModelTest {
public void testServiceTemplateNodeTypes() {
assertTrue(template.node_types() != null);
- for (Map.Entry<String, NodeType> type: template.node_types().entrySet()) {
- assertTrue(type.getKey().matches("node_type_[0-9]"));
+ for (NodeType nodeType: template.node_types().values()) {
+ assertTrue(nodeType.name().matches("node_type_[0-9]"));
- Capabilities caps = type.getValue().capabilities();
+ Capabilities caps = nodeType.capabilities();
assertTrue(caps != null);
- for (Map.Entry<String, Capability> cap: caps.entrySet()) {
- assertTrue(cap.getKey().matches("node_type_[0-9]_capability_[0-9]"));
+ for (Capability cap: caps.values()) {
+ assertTrue(cap.name().matches("node_type_[0-9]_capability_[0-9]"));
}
+
+ Requirements reqs = nodeType.requirements();
+ if (reqs != null) {
+ for (Requirement req: reqs) {
+ assertTrue(req.name().startsWith(nodeType.name() + "_requirement"));
+ assertTrue(req.capability() != null);
+ assertTrue(req.node() != null);
+ assertTrue(req.relationship() != null);
+ }
+ }
+
+ Artifacts arts = nodeType.artifacts();
+ if (arts != null) {
+ for (Artifact art: arts.values()) {
+ assertTrue(art.name().startsWith(nodeType.name() + "_artifact"));
+ assertTrue(art.type().startsWith("artifact_type"));
+ }
+ }
+
+ TypeInterfaces itfs = nodeType.interfaces();
+ if (itfs != null) {
+ for (TypeInterface itf: itfs.values()) {
+ assertTrue(itf.name().startsWith(nodeType.name() + "_interface"));
+ assertTrue(itf.type().startsWith("interface_type"));
+ }
+ }
+
}
}
@@ -164,15 +206,20 @@ public class ModelTest {
assertTrue(template.topology_template().node_templates() != null);
- for (Map.Entry<String, NodeTemplate> node: template.topology_template().node_templates().entrySet()) {
- assertTrue(node.getKey().matches("node_[0-9]"));
+ for (NodeTemplate node: template.topology_template().node_templates().values()) {
+ assertTrue(node.name().matches("node_[0-9]"));
- PropertiesAssignments props = node.getValue().properties();
+ PropertiesAssignments props = node.properties();
assertTrue(props != null);
for (Map.Entry<String, Object> prop: props.entrySet()) {
assertTrue(prop.getKey().matches("node_type_[0-9]_property_[0-9]"));
}
+
+ NodeType nodeType = template.node_types().get(node.type());
+ if (nodeType.capabilities() != null) {
+ assertTrue(node.capabilities() != null);
+ }
}
}
diff --git a/javatoscachecker/checker/src/test/resources/models/full.yaml b/javatoscachecker/checker/src/test/resources/models/full.yaml
index 3792be7..ded4c26 100644
--- a/javatoscachecker/checker/src/test/resources/models/full.yaml
+++ b/javatoscachecker/checker/src/test/resources/models/full.yaml
@@ -17,17 +17,39 @@ data_types:
data_type_1:
derived_from: tosca.datatypes.Root
+ description: test data type 1
+ version: "1.0"
properties:
data_field_11:
type: string
+ required: true
+ description: test data field 11
data_field_12:
type: integer
+ required: true
+ description: test data field 12
+ constraints:
+ - valid_values: [ 1, 12,24 ]
data_type_2:
derived_from: data_type_1
+ description: test data type 2
+ version: "1.0"
properties:
data_field_21:
type: string
+ required: true
+ description: test data field 21
+ constraints:
+ - max_length: 128
+
+artifact_types:
+
+ artifact_type_1:
+ derived_from: tosca.artifacts.File
+ description: Some test bytes
+ mime_type: application/octet-stream
+ file_ext: [ tst ]
capability_types:
@@ -55,7 +77,8 @@ node_types:
requirements:
- node_type_1_requirement_2:
capability: capability_type_2
-# relationship:
+ node: node_type_2
+ relationship: relationship_type_12
node_type_2:
properties:
@@ -64,6 +87,12 @@ node_types:
capabilities:
node_type_2_capability_2:
type: capability_type_2
+ artifacts:
+ node_type_2_artifact_1:
+ type: artifact_type_1
+ interfaces:
+ node_type_2_interface_1:
+ type: interface_type_1
interface_types:
@@ -75,15 +104,18 @@ interface_types:
# type: string
interface_type_1_op_1:
description: test interface operation
+
+ interface_type_2:
+ derived_from: tosca.interfaces.node.lifecycle.Standard
relationship_types:
- relationship_type_1:
+ relationship_type_12:
derived_from: tosca.relationships.ConnectsTo
description: test relationship type
interfaces:
- relationship_type_1_interface_1:
- type: interface_type_1
+ relationship_type_12_interface_1:
+ type: interface_type_2
topology_template:
@@ -93,11 +125,15 @@ topology_template:
type: node_type_1
properties:
node_type_1_property_1: { data_field_11: "11", data_field_12: 12 }
+ capabilities:
+ node_type_1_capability_1:
+ properties:
+ capability_type_1_property_1: value_1
requirements:
- node_type_1_requirement_2:
node_filter:
capabilities:
- - two:
+ - node_type_2_capability_2:
properties:
- capability_type_2_property_1: { equal: "value2" }
@@ -113,7 +149,7 @@ topology_template:
relationship_templates:
relationship_1:
- type: relationship_type_1
+ type: relationship_type_12
# interfaces:
# relationship_type_1_interface_1:
diff --git a/javatoscachecker/kwalify/pom.xml b/javatoscachecker/kwalify/pom.xml
index 7b07865..6a7b623 100644
--- a/javatoscachecker/kwalify/pom.xml
+++ b/javatoscachecker/kwalify/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.modeling.toscaparsers</groupId>
<artifactId>checker</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>kwalify</artifactId>
<packaging>jar</packaging>
@@ -120,6 +120,19 @@
</build>
<dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.8.0</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
diff --git a/javatoscachecker/kwalify/src/test/java/kwalify/test/ParserTest.java b/javatoscachecker/kwalify/src/test/java/kwalify/test/ParserTest.java
new file mode 100644
index 0000000..1983619
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/java/kwalify/test/ParserTest.java
@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2017 <AT&T>. All rights reserved.
+ * ===================================================================
+ * 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.
+ */
+package kwalify.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.FixMethodOrder;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.List;
+import java.util.Arrays;
+import java.io.InputStream;
+import java.io.IOException;
+
+import kwalify.PlainYamlParser;
+import kwalify.SyntaxException;
+import kwalify.Util;
+
+
+/*
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ParserTest {
+
+ @BeforeClass
+ public static void initialize() throws Exception {
+ }
+
+ private Object parse(String theResource) throws SyntaxException {
+ Object output = null;
+ InputStream source = getClass().getClassLoader().getResourceAsStream(theResource);
+ if (source == null) {
+ fail("Cannot find test resource " + theResource);
+ }
+
+ try {
+ output = new PlainYamlParser(
+ Util.readInputStream(source))
+ .parse();
+ }
+ catch (IOException iox) {
+ fail("Failed to load test resource " + theResource + ": " + iox);
+ }
+ return output;
+ }
+
+ @Test
+ public void testParserSuccess() {
+ try {
+ assertTrue(
+ parse("parserSuccess.yml") instanceof Map);
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx);
+ }
+ }
+
+
+
+ @Test
+ public void testParserFailOnInvalidAnchor() {
+ try {
+ parse("parserFailInvalidAnchor.yml");
+ }
+ catch (SyntaxException sx) {
+ assertTrue(sx.getMessage(), sx.getMessage().matches("anchor '.*' not found."));
+ assertTrue("" + sx.getLineNumber(), sx.getLineNumber() == 25);
+ }
+ }
+
+ @Test
+ public void testParserFailIndentation() {
+ try {
+ parse("parserFailIndentation.yml");
+ }
+ catch (SyntaxException sx) {
+ assertTrue(sx.getMessage(), sx.getMessage().matches("invalid indent of mapping."));
+ assertTrue("" + sx.getLineNumber(), sx.getLineNumber() == 28);
+ }
+ }
+
+ @Test
+ public void testParserSeqOfScalar() {
+ try {
+ assertTrue(
+ parse("parserSuccessSeqOfScalar.yml") instanceof List);
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ }
+
+ @Test
+ public void testParserSeqOfMap() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessSeqOfMap.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue(res instanceof List);
+ for (Object entry: (List)res)
+ assertTrue(entry instanceof Map);
+ }
+
+ //@Test
+ public void testParserSeqOfSeq() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessSeqOfSeq.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue(res instanceof List);
+ for (Object entry: (List)res)
+ assertTrue(entry instanceof List);
+ }
+
+ @Test
+ public void testParserMapScalarToScalar() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessMapScalarToScalar.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue(res instanceof Map);
+ }
+
+ @Test
+ public void testParserMapScalarToSeq() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessMapScalarToSeq.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue(res instanceof Map);
+ for (Object value: ((Map)res).values())
+ assertTrue(value instanceof List);
+ }
+
+ @Test
+ public void testParserMapOfMap() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessMapOfMap.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map);
+ for (Object value: ((Map)res).values())
+ assertTrue("value not a map, " + value.getClass() + ", " + value, value instanceof Map);
+ }
+
+ //@Test
+ //not supported
+ public void testParserMapOfSeqToSeq() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessMapOfSeqToSeq.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map);
+ for (Map.Entry entry: (Set<Map.Entry>)((Map)res).entrySet()) {
+ assertTrue(entry.getKey() instanceof List);
+ assertTrue(entry.getValue() instanceof List);
+ }
+ }
+
+ //@Test
+ //not supported
+ public void testParserUnorderedSet() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessUnorderedSet.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue("result not a set: " + res.getClass() + ", " + res, res instanceof Set);
+ }
+
+ @Test
+ public void testParserOrderedMap() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessOrderedMap.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue("result not a list: " + res.getClass() + ", " + res, res instanceof List);
+ }
+
+ @Test
+ public void testParserFloats() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessFloats.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map);
+
+ for (Object value: ((Map)res).values())
+ assertTrue("value not encoded as a Double: " + value.getClass() + ", " + value, value instanceof Double);
+ }
+
+ @Test
+ public void testParserInts() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessInts.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map);
+
+ for (Object value: ((Map)res).values())
+ assertTrue("value not encoded as a Integer: " + value.getClass() + ", " + value, value instanceof Integer);
+ }
+
+ @Test
+ public void testParserQuotedStrings() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessQuotedStrings.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map);
+
+ for (Object value: ((Map)res).values())
+ assertTrue("value not encoded as a String: " + value.getClass() + ", " + value, value instanceof String);
+ }
+
+ @Test
+ public void testParserTimestamps() {
+ Object res = null;
+ try {
+ res = parse("parserSuccessTimestamps.yml");
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx + " at line " + sx.getLineNumber());
+ }
+ assertTrue("result not a map: " + res.getClass() + ", " + res, res instanceof Map);
+
+ for (Object value: ((Map)res).values())
+ assertTrue("value not encoded as a Date: " + value.getClass() + ", " + value, value instanceof java.util.Date);
+ }
+
+ @Test
+ public void testMultipleDocs() throws SyntaxException {
+ Object[] output = null;
+ InputStream source = getClass().getClassLoader().getResourceAsStream("parserSuccessMultipleDocs.yml");
+ if (source == null) {
+ fail("Cannot find test resource parserSuccessMultipleDocs.yml");
+ }
+
+ try {
+ output = new PlainYamlParser(
+ Util.readInputStream(source))
+ .parseAll();
+ }
+ catch (IOException iox) {
+ fail("Failed to load test resource parserSuccessMultipleDocs.yml: " + iox);
+ }
+ assertTrue("Unexpected output " + output == null ? "null" : Arrays.toString(output), output != null && output.length == 2);
+ }
+}
diff --git a/javatoscachecker/kwalify/src/test/java/kwalify/test/ValidatorTest.java b/javatoscachecker/kwalify/src/test/java/kwalify/test/ValidatorTest.java
new file mode 100644
index 0000000..e5c2735
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/java/kwalify/test/ValidatorTest.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2017 <AT&T>. All rights reserved.
+ * ===================================================================
+ * 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.
+ */
+package kwalify.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.FixMethodOrder;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.util.Map;
+import java.util.List;
+import java.io.InputStream;
+import java.io.IOException;
+
+import kwalify.PlainYamlParser;
+import kwalify.SyntaxException;
+import kwalify.SchemaException;
+import kwalify.Util;
+import kwalify.Validator;
+
+
+/*
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ValidatorTest {
+
+ @BeforeClass
+ public static void initialize() throws Exception {
+ }
+
+ protected Object[] prepareValidateTest(String theName) {
+ Object[] res = new Object[3];
+ InputStream source = null;
+
+ source = getClass().getClassLoader().getResourceAsStream(theName + "Schema.yml");
+ if (source == null) {
+ fail("Cannot find test resource " + theName + "Schema.yml");
+ }
+
+ try {
+ res[0] = new PlainYamlParser(
+ Util.readInputStream(source))
+ .parse();
+ }
+ catch (IOException iox) {
+ fail("Failed to load test resource " + iox);
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx);
+ }
+
+ source = getClass().getClassLoader().getResourceAsStream(theName + ".yml");
+ if (source == null) {
+ fail("Cannot find test resource " + theName + ".yml");
+ }
+ try {
+ res[1] = new PlainYamlParser(
+ Util.readInputStream(source))
+ .parse();
+ }
+ catch (IOException iox) {
+ fail("Failed to load test resource " + iox);
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx);
+ }
+
+ source = getClass().getClassLoader().getResourceAsStream("in" + theName + ".yml");
+ if (source == null) {
+ fail("Cannot find test resource in" + theName + ".yml");
+ }
+ try {
+ res[2] = new PlainYamlParser(
+ Util.readInputStream(source))
+ .parse();
+ }
+ catch (IOException iox) {
+ fail("Failed to load test resource " + iox);
+ }
+ catch (SyntaxException sx) {
+ fail("Unexpected syntax error " + sx);
+ }
+
+ return res;
+ }
+
+ protected void runValidateTest(String theTestName) {
+ Object[] docs = prepareValidateTest(theTestName);
+ List errors = null;
+ try {
+ errors = new Validator(docs[0]).validate(docs[1]);
+ }
+ catch (SchemaException sx) {
+ fail("Invalid schema " + sx);
+ }
+
+ assertTrue(errors.toString(), errors != null && errors.size() == 0);
+
+ try {
+ errors = new Validator(docs[0]).validate(docs[2]);
+ }
+ catch (SchemaException sx) {
+ fail("Invalid schema " + sx);
+ }
+
+ assertTrue(errors.toString(), errors != null && errors.size() > 0);
+ }
+
+ @Test
+ public void testMap() {
+ runValidateTest("validateMap");
+ }
+
+ @Test
+ public void testSeq() {
+ runValidateTest("validateSeq");
+ }
+
+ @Test
+ public void testMapOfSeq() {
+ runValidateTest("validateMapOfSeq");
+ }
+
+ @Test
+ public void testSeqOfMap() {
+ runValidateTest("validateSeqOfMap");
+ }
+
+ @Test
+ public void testRule() {
+ runValidateTest("validateRule");
+ }
+}
diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateMap.yml b/javatoscachecker/kwalify/src/test/resources/invalidateMap.yml
new file mode 100644
index 0000000..4c26997
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/invalidateMap.yml
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+name: foo
+email: foo(at)mail.com
+age: twenty
+birth: Jun 01, 1985
diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateMapOfSeq.yml b/javatoscachecker/kwalify/src/test/resources/invalidateMapOfSeq.yml
new file mode 100644
index 0000000..b6b4345
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/invalidateMapOfSeq.yml
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+company: Kuwata Lab.
+email: webmaster@kuwata-lab.com
+employees:
+ - code: A101
+ name: foo
+ email: foo@kuwata-lab.com
+ - code: 102
+ name: bar
+ mail: bar@kuwata-lab.com
diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateRule.yml b/javatoscachecker/kwalify/src/test/resources/invalidateRule.yml
new file mode 100644
index 0000000..9b4ca17
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/invalidateRule.yml
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+- name: foo
+ email: foo(at)mail.com
+ password: xxx123
+ age: twenty
+ blood: a
+ birth: 1985-01-01
+- given-name: bar
+ family-name: Bar
+ email: bar@mail.net
+ age: 15
+ blood: AB
+ birth: 1980/01/01
diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateSeq.yml b/javatoscachecker/kwalify/src/test/resources/invalidateSeq.yml
new file mode 100644
index 0000000..f2dd1a5
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/invalidateSeq.yml
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+- foo
+- 123
+- baz
diff --git a/javatoscachecker/kwalify/src/test/resources/invalidateSeqOfMap.yml b/javatoscachecker/kwalify/src/test/resources/invalidateSeqOfMap.yml
new file mode 100644
index 0000000..c3c828a
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/invalidateSeqOfMap.yml
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+- name: foo
+ email: foo@mail.com
+- naem: bar
+ email: bar@mail.net
+- name: baz
+ mail: baz@mail.org
diff --git a/javatoscachecker/kwalify/src/test/resources/parserFailIndentation.yml b/javatoscachecker/kwalify/src/test/resources/parserFailIndentation.yml
new file mode 100644
index 0000000..949ef56
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserFailIndentation.yml
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+invoice: 34843
+date : 2001-01-23
+bill-to: &id001
+ given : Chris
+ family : Dumars
+ address:
+ lines: |
+ 458 Walkman Dr.
+ Suite #292
+ city : Royal Oak
+ state : MI
+ postal : 48046
+ship-to: *id001
+product:
+ - sku : BL394D
+ quantity : 4
+ description : Basketball
+ price : 450.00
+ - sku : BL4438H
+ quantity : 1
+ description : Super Hoop
+ price : 2392.00
+tax : 251.42
+total: 4443.52
+comments: >
+ Late afternoon is best.
+ Backup contact is Nancy
+ Billsmer @ 338-4338
diff --git a/javatoscachecker/kwalify/src/test/resources/parserFailInvalidAnchor.yml b/javatoscachecker/kwalify/src/test/resources/parserFailInvalidAnchor.yml
new file mode 100644
index 0000000..702bc65
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserFailInvalidAnchor.yml
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+invoice: 34843
+date : 2001-01-23
+bill-to: &id001
+ given : Chris
+ family : Dumars
+ address:
+ lines: |
+ 458 Walkman Dr.
+ Suite #292
+ city : Royal Oak
+ state : MI
+ postal : 48046
+ship-to: *id002
+product:
+ - sku : BL394D
+ quantity : 4
+ description : Basketball
+ price : 450.00
+ - sku : BL4438H
+ quantity : 1
+ description : Super Hoop
+ price : 2392.00
+tax : 251.42
+total: 4443.52
+comments: >
+ Late afternoon is best.
+ Backup contact is Nancy
+ Billsmer @ 338-4338
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccess.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccess.yml
new file mode 100644
index 0000000..35dbbb9
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccess.yml
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+invoice: 34843
+date : 2001-01-23
+bill-to: &id001
+ given : Chris
+ family : Dumars
+ address:
+ lines: |
+ 458 Walkman Dr.
+ Suite #292
+ city : Royal Oak
+ state : MI
+ postal : 48046
+ship-to: *id001
+product:
+ - sku : BL394D
+ quantity : 4
+ description : Basketball
+ price : 450.00
+ - sku : BL4438H
+ quantity : 1
+ description : Super Hoop
+ price : 2392.00
+tax : 251.42
+total: 4443.52
+comments: >
+ Late afternoon is best.
+ Backup contact is Nancy
+ Billsmer @ 338-4338
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessFloats.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessFloats.yml
new file mode 100644
index 0000000..b26e45b
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessFloats.yml
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+#canonical: 1.23015e+3
+#exponential: 12.3015e+02
+fixed: 1230.15
+#negative infinity: -.inf
+#not a number: .NaN
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessInts.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessInts.yml
new file mode 100644
index 0000000..18faa3c
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessInts.yml
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+canonical: 12345
+#decimal: +12345
+#octal: 0o14
+#hexadecimal: 0xC
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfMap.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfMap.yml
new file mode 100644
index 0000000..4695f11
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfMap.yml
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+'Mark McGwire':
+ hr: 65
+ avg: 0.278
+'Sammy Sosa':
+ hr: 63
+ avg: 0.288
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfSeqToSeq.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfSeqToSeq.yml
new file mode 100644
index 0000000..d2d70a1
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapOfSeqToSeq.yml
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+? - Detroit Tigers
+ - Chicago cubs
+:
+ - 2001-07-23
+
+? [ New York Yankees,
+ Atlanta Braves ]
+: [ 2001-07-02, 2001-08-12,
+ 2001-08-14 ]
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToScalar.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToScalar.yml
new file mode 100644
index 0000000..b875202
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToScalar.yml
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+hr: 65 # Home runs
+avg: 0.278 # Batting average
+rbi: 147 # Runs Batted In
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToSeq.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToSeq.yml
new file mode 100644
index 0000000..d1f85cb
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMapScalarToSeq.yml
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+american:
+ - Boston Red Sox
+ - Detroit Tigers
+ - New York Yankees
+national:
+ - New York Mets
+ - Chicago Cubs
+ - Atlanta Braves
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessMultipleDocs.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessMultipleDocs.yml
new file mode 100644
index 0000000..357cbc6
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessMultipleDocs.yml
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+time: 20:03:20
+player: Sammy Sosa
+action: strike (miss)
+
+---
+
+time: 20:03:47
+player: Sammy Sosa
+action: grand slam
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessOrderedMap.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessOrderedMap.yml
new file mode 100644
index 0000000..5f9e127
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessOrderedMap.yml
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+# Ordered maps are represented as
+# A sequence of mappings, with
+# each mapping having one key
+--- !!omap
+- Mark McGwire: 65
+- Sammy Sosa: 63
+- Ken Griffy: 58
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessQuotedStrings.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessQuotedStrings.yml
new file mode 100644
index 0000000..dff2570
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessQuotedStrings.yml
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+unicode: "Sosa did fine.\u263A"
+control: "\b1998\t1999\t2000\n"
+#hex esc: "\x0d\x0a is \r\n"
+single: '"Howdy!" he cried.'
+quoted: ' # Not a ''comment''.'
+tie-fighter: '|\-*-/|'
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfMap.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfMap.yml
new file mode 100644
index 0000000..b1d59b3
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfMap.yml
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+-
+ name: Mark McGwire
+ hr: 65
+ avg: 0.278
+-
+ name: Sammy Sosa
+ hr: 63
+ avg: 0.288
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfScalar.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfScalar.yml
new file mode 100644
index 0000000..a9a025a
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfScalar.yml
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+- Mark McGwire
+- Sammy Sosa
+- Ken Griffey
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfSeq.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfSeq.yml
new file mode 100644
index 0000000..7bfb6fe
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessSeqOfSeq.yml
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+- [name , hr, avg ]
+- [Mark McGwire, 65, 0.278]
+- [Sammy Sosa , 63, 0.288]
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessTimestamps.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessTimestamps.yml
new file mode 100644
index 0000000..3bea395
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessTimestamps.yml
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+canonical: 2001-12-15T02:59:43.1Z
+iso8601: 2001-12-14t21:59:43.10-05:00
+spaced: 2001-12-14 21:59:43.10 -5
+date: 2002-12-14
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessTypeTags.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessTypeTags.yml
new file mode 100644
index 0000000..b7aac5d
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessTypeTags.yml
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+---
+not-date: !!str 2002-04-28
+
+picture: !!binary |
+ R0lGODlhDAAMAIQAAP//9/X
+ 17unp5WZmZgAAAOfn515eXv
+ Pz7Y6OjuDg4J+fn5OTk6enp
+ 56enmleECcgggoBADs=
+
+application specific tag: !something |
+ The semantics of the tag
+ above may be different for
+ different documents.
diff --git a/javatoscachecker/kwalify/src/test/resources/parserSuccessUnorderedSet.yml b/javatoscachecker/kwalify/src/test/resources/parserSuccessUnorderedSet.yml
new file mode 100644
index 0000000..fcd2d47
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/parserSuccessUnorderedSet.yml
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+# Sets are represented as a
+# Mapping where each key is
+# associated with a null value
+--- !!set
+? Mark McGwire
+? Sammy Sosa
+? Ken Griff
diff --git a/javatoscachecker/kwalify/src/test/resources/validateMap.yml b/javatoscachecker/kwalify/src/test/resources/validateMap.yml
new file mode 100644
index 0000000..34363a7
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateMap.yml
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+name: foo
+email: foo@mail.com
+age: 20
+birth: 1985-01-01
diff --git a/javatoscachecker/kwalify/src/test/resources/validateMapOfSeq.yml b/javatoscachecker/kwalify/src/test/resources/validateMapOfSeq.yml
new file mode 100644
index 0000000..a3a7648
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateMapOfSeq.yml
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+company: Kuwata lab.
+email: webmaster@kuwata-lab.com
+employees:
+ - code: 101
+ name: foo
+ email: foo@kuwata-lab.com
+ - code: 102
+ name: bar
+ email: bar@kuwata-lab.com
diff --git a/javatoscachecker/kwalify/src/test/resources/validateMapOfSeqSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateMapOfSeqSchema.yml
new file mode 100644
index 0000000..7868fc2
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateMapOfSeqSchema.yml
@@ -0,0 +1,20 @@
+type: map
+mapping:
+ company:
+ type: str
+ required: yes
+ email:
+ type: str
+ employees:
+ type: seq
+ sequence:
+ - type: map
+ mapping:
+ code:
+ type: int
+ required: yes
+ name:
+ type: str
+ required: yes
+ email:
+ type: str
diff --git a/javatoscachecker/kwalify/src/test/resources/validateMapSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateMapSchema.yml
new file mode 100644
index 0000000..72361aa
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateMapSchema.yml
@@ -0,0 +1,12 @@
+type: map
+mapping:
+ name:
+ type: str
+ required: yes
+ email:
+ type: str
+ pattern: /@/
+ age:
+ type: int
+ birth:
+ type: date
diff --git a/javatoscachecker/kwalify/src/test/resources/validateRule.yml b/javatoscachecker/kwalify/src/test/resources/validateRule.yml
new file mode 100644
index 0000000..0e6ee06
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateRule.yml
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+- name: foo
+ email: foo@mail.com
+ password: xxx123456
+ age: 20
+ blood: A
+ birth: 1985-01-01
+- name: bar
+ email: bar@mail.net
+ age: 25
+ blood: AB
+ birth: 1980-01-01
diff --git a/javatoscachecker/kwalify/src/test/resources/validateRuleSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateRuleSchema.yml
new file mode 100644
index 0000000..7b1f1b6
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateRuleSchema.yml
@@ -0,0 +1,30 @@
+type: seq
+sequence:
+ -
+ type: map
+ mapping:
+ name:
+ type: str
+ required: yes
+ email:
+ type: str
+ required: yes
+ pattern: /@/
+ password:
+ type: text
+ length: { max: 16, min: 8 }
+ age:
+ type: int
+ range: { max: 30, min: 18 }
+ # or assert: 18 <= val && val <= 30
+ blood:
+ type: str
+ enum:
+ - A
+ - B
+ - O
+ - AB
+ birth:
+ type: date
+ memo:
+ type: any
diff --git a/javatoscachecker/kwalify/src/test/resources/validateSeq.yml b/javatoscachecker/kwalify/src/test/resources/validateSeq.yml
new file mode 100644
index 0000000..d75d58f
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateSeq.yml
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+- foo
+- bar
+- baz
diff --git a/javatoscachecker/kwalify/src/test/resources/validateSeqOfMap.yml b/javatoscachecker/kwalify/src/test/resources/validateSeqOfMap.yml
new file mode 100644
index 0000000..cd05584
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateSeqOfMap.yml
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2017 <AT&T>. All rights reserved.
+# ===================================================================
+# 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.
+#
+- name: foo
+ email: foo@mail.com
+- name: bar
+ email: bar@mail.net
+- name: baz
+ email: baz@mail.org
diff --git a/javatoscachecker/kwalify/src/test/resources/validateSeqOfMapSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateSeqOfMapSchema.yml
new file mode 100644
index 0000000..73af17a
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateSeqOfMapSchema.yml
@@ -0,0 +1,9 @@
+type: seq
+sequence:
+ - type: map
+ mapping:
+ name:
+ type: str
+ required: true
+ email:
+ type: str
diff --git a/javatoscachecker/kwalify/src/test/resources/validateSeqSchema.yml b/javatoscachecker/kwalify/src/test/resources/validateSeqSchema.yml
new file mode 100644
index 0000000..4e02606
--- /dev/null
+++ b/javatoscachecker/kwalify/src/test/resources/validateSeqSchema.yml
@@ -0,0 +1,3 @@
+type: seq
+sequence:
+ - type: str
diff --git a/javatoscachecker/pom.xml b/javatoscachecker/pom.xml
index 9a79429..a7df537 100644
--- a/javatoscachecker/pom.xml
+++ b/javatoscachecker/pom.xml
@@ -22,16 +22,23 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>0.1.1</version>
+ <version>1.1.0</version>
<relativePath/>
</parent>
<groupId>org.onap.modeling.toscaparsers</groupId>
<artifactId>checker</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>modeling-toscaparsers-javatoscachecker</name>
-
+<!--
+ <scm>
+ <connection>scm:git:ssh://gerrit.onap.org:29418/modeling/toscaparsers.git</connection>
+ <developerConnection>scm:git:ssh://gerrit.onap.org:29418/modeling/toscaparsers.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.onap.org/label/DW/modelling-project</url>
+ </scm>
+-->
<properties>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<sitePath>/content/sites/site/${project.groupId}/${project.artifactId}/${project.version}</sitePath>
@@ -121,7 +128,7 @@
<profiles>
<profile>
- <id>docker</id>
+ <id>docker</id>
</profile>
</profiles>
diff --git a/javatoscachecker/service/pom.xml b/javatoscachecker/service/pom.xml
index cb3bae8..20cbc38 100644
--- a/javatoscachecker/service/pom.xml
+++ b/javatoscachecker/service/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.onap.modeling.toscaparsers</groupId>
<artifactId>checker</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>Service</artifactId>
<packaging>jar</packaging>
@@ -27,7 +27,7 @@
<properties>
<java.version>1.8</java.version>
- <maven.build.timestamp.format>yyyy.MM.dd'T'hh.mm.ss'Z'</maven.build.timestamp.format>
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
<docker.push.registry>${onap.nexus.dockerregistry.daily}</docker.push.registry>
<docker.tag.version>${project.version}</docker.tag.version>
<docker.tag.timestamp>${maven.build.timestamp}</docker.tag.timestamp>
@@ -121,7 +121,7 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
- <version>1.3.3.RELEASE</version>
+ <version>2.0.0.RELEASE</version>
<configuration>
<mainClass>org.onap.tosca.checker.service.CheckerEngine</mainClass>
</configuration>
@@ -242,7 +242,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
- <version>1.5.3.RELEASE</version>
+ <version>2.0.0.RELEASE</version>
<scope>test</scope>
</dependency>
@@ -264,7 +264,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
- <version>[1.3.3.RELEASE,)</version>
+ <version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>