serializer helper fix and data node walker
Change-Id: I46c0b0228370044b2f56c4fe5fafeb6cd11bfff2
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/TestUtils.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/TestUtils.java
index 8b8c058..b17981a 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/TestUtils.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/TestUtils.java
@@ -29,7 +29,9 @@
import org.onosproject.yang.model.ResourceId;
import org.onosproject.yang.model.SchemaContext;
import org.onosproject.yang.model.SchemaId;
+import org.onosproject.yang.runtime.helperutils.DataNodeListener;
+import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
@@ -38,8 +40,9 @@
import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_LEAF_VALUE_NODE;
import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE;
import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_NODE;
+import static org.onosproject.yang.runtime.helperutils.DefaultDataNodeWalker.walk;
-public final class TestUtils {
+public final class TestUtils implements DataNodeListener {
/**
* Restricts creation of test utils instance.
@@ -47,6 +50,37 @@
private TestUtils() {
}
+ public static final String PERIOD = ".";
+
+ // Logger list is used for walker testing.
+ private static final List<String> LOGGER = new ArrayList<>();
+
+ @Override
+ public void enterDataNode(DataNode node) {
+ LOGGER.add("Entry Node is " + node.key().schemaId().name() + PERIOD);
+ }
+
+ @Override
+ public void exitDataNode(DataNode node) {
+ LOGGER.add("Exit Node is " + node.key().schemaId().name() + PERIOD);
+ }
+
+ /**
+ * Returns the LOGGER with log for testing the YDT walker.
+ *
+ * @return list of logs
+ */
+ public static List<String> getLogger() {
+ return LOGGER;
+ }
+
+ /**
+ * Clear the LOGGER array.
+ */
+ public static void resetLogger() {
+ LOGGER.clear();
+ }
+
/**
* Checks the schema context values of given leaf node.
*/
@@ -135,7 +169,12 @@
j++;
}
} else if (k instanceof LeafListKey) {
- val = ((LeafListKey) k).value().toString();
+ if (((LeafListKey) k).value() == null) {
+ assertNull(valA[j]);
+ val = null;
+ } else {
+ val = ((LeafListKey) k).value().toString();
+ }
}
if (val != null) {
assertEquals(val, valA[j]);
@@ -162,15 +201,19 @@
assertEquals(id.name(), n);
assertEquals(id.namespace(), ns);
if (node instanceof InnerNode) {
- assertEquals(((InnerNode) node).type(), type);
+ assertEquals(node.type(), type);
if (isChild) {
assertNotNull(((InnerNode) node).childNodes());
} else {
assertNull(((InnerNode) node).childNodes());
}
} else {
- assertEquals(((LeafNode) node).type(), type);
- assertEquals(((LeafNode) node).value().toString(), value);
+ assertEquals(node.type(), type);
+ if (((LeafNode) node).value() == null) {
+ assertNull(value);
+ } else {
+ assertEquals(((LeafNode) node).value().toString(), value);
+ }
}
}
@@ -189,4 +232,22 @@
assertEquals(id.namespace(), ns);
assertEquals(key.leafValue().toString(), v);
}
+
+ /**
+ * Walks in the given built data tree and validates it.
+ */
+ public static void walkINTree(DataNode node,
+ String[] expected) {
+ resetLogger();
+
+ TestUtils utils = new TestUtils();
+ // Assign root node as starting node to walk the whole tree.
+ walk(utils, node);
+ // Logger list is used for walker testing.
+ List<String> logger = getLogger();
+
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals(expected[i], logger.get(i));
+ }
+ }
}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeIetfNetTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeIetfNetTest.java
index df125bc..43b75b2 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeIetfNetTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeIetfNetTest.java
@@ -26,6 +26,7 @@
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.exitDataNode;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.getResourceId;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.walkINTree;
import static org.onosproject.yang.runtime.impl.schemacontext.SchemaContextTest.IETFNS;
import static org.onosproject.yang.runtime.impl.TestUtils.validateResourceId;
@@ -63,6 +64,38 @@
String[] nsA;
String[] valA;
+ private static final String[] EXPECTED = {
+ "Entry Node is /.",
+ "Entry Node is networks.",
+ "Entry Node is network.",
+ "Entry Node is network-id.",
+ "Exit Node is network-id.",
+ "Entry Node is supporting-network.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Exit Node is supporting-network.",
+ "Entry Node is node.",
+ "Entry Node is node-id.",
+ "Exit Node is node-id.",
+ "Entry Node is supporting-node.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is node-ref.",
+ "Exit Node is node-ref.",
+ "Exit Node is supporting-node.",
+ "Exit Node is node.",
+ "Exit Node is network.",
+ "Exit Node is networks.",
+ "Entry Node is networks-state.",
+ "Entry Node is network.",
+ "Entry Node is network-ref.",
+ "Exit Node is network-ref.",
+ "Entry Node is server-provided.",
+ "Exit Node is server-provided.",
+ "Exit Node is network.",
+ "Exit Node is networks-state.",
+ "Exit Node is /.",
+ };
/**
* Test add to data node builder.
*/
@@ -129,15 +162,19 @@
value = "network5";
dBlr = addDataNode(dBlr, "network-ref", null, value, null);
dBlr = exitDataNode(dBlr);
-
// Adding leaf server-provided
value = "true";
dBlr = addDataNode(dBlr, "server-provided", null, value, null);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
//Tree validation
nA = new String[]{"/", "networks", "network", "network-id", ""};
nsA = new String[]{null, IETFNS, IETFNS, IETFNS, ""};
valA = new String[]{"network1", ""};
validateResourceId(nA, nsA, valA, id);
+ DataNode node = dBlr.build();
+ walkINTree(dBlr.build(), EXPECTED);
}
}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeLeafListTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeLeafListTest.java
new file mode 100644
index 0000000..57618b9
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeLeafListTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yang.runtime.impl.serializerhelper;
+
+import org.junit.Test;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.runtime.helperutils.HelperContext;
+import org.onosproject.yang.runtime.impl.TestYangSerializerContext;
+
+import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_LEAF_VALUE_NODE;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.addDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.getResourceId;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeResourceId;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateResourceId;
+import static org.onosproject.yang.runtime.impl.TestUtils.walkINTree;
+
+/**
+ * Tests the serializer helper methods.
+ */
+public class AddToDataNodeLeafListTest {
+
+ public static final String LNS = "yrt:list";
+
+ TestYangSerializerContext context = new TestYangSerializerContext();
+
+ /*
+ * Reference for data node info.
+ */
+ HelperContext info;
+
+ /*
+ * Reference for data node builder.
+ */
+ DataNode.Builder dBlr;
+
+ /*
+ * Reference for resource id.
+ */
+ ResourceId id;
+
+ /*
+ * Reference for the value.
+ */
+ String value;
+
+ /*
+ * Reference for string array to used for resource id testing.
+ */
+ String[] nA;
+ String[] nsA;
+ String[] valA;
+
+ private static final String[] EXPECTED = {
+ "Entry Node is leaf1.",
+ "Exit Node is leaf1."
+ };
+
+ /**
+ * Test add to data node after initializing it with resource builder.
+ */
+ @Test
+ public void addToDataLeafListTest() {
+
+ ResourceId.Builder rIdBlr = initializeResourceId(context);
+ dBlr = initializeDataNode(rIdBlr);
+ value = "0";
+ dBlr = addDataNode(dBlr, "leaf1", LNS, value, null);
+ info = (HelperContext) dBlr.appInfo();
+ id = getResourceId(dBlr);
+
+ //Tree validation
+ nA = new String[]{"/", "leaf1"};
+ nsA = new String[]{null, LNS};
+ valA = new String[]{"0"};
+ validateResourceId(nA, nsA, valA, id);
+
+ DataNode node = dBlr.build();
+ validateDataNode(node, "leaf1", LNS, MULTI_INSTANCE_LEAF_VALUE_NODE,
+ false, "0");
+ walkINTree(node, EXPECTED);
+ }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeList1Test.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeList1Test.java
new file mode 100644
index 0000000..3ce0be0
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeList1Test.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yang.runtime.impl.serializerhelper;
+
+import org.junit.Test;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.InnerNode;
+import org.onosproject.yang.model.KeyLeaf;
+import org.onosproject.yang.model.ListKey;
+import org.onosproject.yang.model.NodeKey;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.runtime.helperutils.HelperContext;
+import org.onosproject.yang.runtime.impl.TestYangSerializerContext;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_NODE;
+import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE;
+import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_NODE;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.addDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.exitDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.getResourceId;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeResourceId;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateLeafDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateResourceId;
+import static org.onosproject.yang.runtime.impl.TestUtils.walkINTree;
+
+/**
+ * Tests the serializer helper methods.
+ */
+public class AddToDataNodeList1Test {
+
+
+ public static final String LNS = "yrt:list";
+
+ TestYangSerializerContext context = new TestYangSerializerContext();
+
+ /*
+ * Reference for data node info.
+ */
+ HelperContext info;
+
+ /*
+ * Reference for data node builder.
+ */
+ DataNode.Builder dBlr;
+
+ /*
+ * Reference for resource id.
+ */
+ ResourceId id;
+
+ /*
+ * Reference for the value.
+ */
+ String value;
+
+ /*
+ * Reference for string array to used for resource id testing.
+ */
+ String[] nA;
+ String[] nsA;
+ String[] valA;
+
+ private static final String[] EXPECTED = {
+ "Entry Node is l1.",
+ "Entry Node is k1.",
+ "Exit Node is k1.",
+ "Entry Node is k2.",
+ "Exit Node is k2.",
+ "Entry Node is c1.",
+ "Entry Node is leaf_c1.",
+ "Exit Node is leaf_c1.",
+ "Exit Node is c1.",
+ "Entry Node is k3.",
+ "Exit Node is k3.",
+ "Exit Node is l1.",
+ };
+
+ /**
+ * Test add to data node builder.
+ */
+ @Test
+ public void addToDataListTest() throws IOException {
+ ResourceId.Builder rIdBlr = initializeResourceId(context);
+ dBlr = initializeDataNode(rIdBlr);
+
+ dBlr = addDataNode(dBlr, "l1", LNS, value, null);
+ value = "1";
+ dBlr = addDataNode(dBlr, "k1", null, value, null);
+ dBlr = exitDataNode(dBlr);
+ value = "2";
+ dBlr = addDataNode(dBlr, "k2", null, value, null);
+ dBlr = exitDataNode(dBlr);
+ value = null;
+ dBlr = addDataNode(dBlr, "c1", null, value, null);
+ value = "0";
+ dBlr = addDataNode(dBlr, "leaf_c1", null, value, null);
+
+ info = (HelperContext) dBlr.appInfo();
+ id = getResourceId(dBlr);
+ dBlr = exitDataNode(dBlr);
+
+ ResourceId id1 = getResourceId(dBlr);
+ dBlr = exitDataNode(dBlr);
+
+ value = "3";
+ dBlr = addDataNode(dBlr, "k3", null, value, null);
+
+ info = (HelperContext) dBlr.appInfo();
+ ResourceId id2 = getResourceId(dBlr);
+
+ dBlr = exitDataNode(dBlr);
+
+ //Tree validation
+ nA = new String[]{"/", "l1", "k1", "k2", "k3", "c1", "leaf_c1"};
+ nsA = new String[]{null, LNS, LNS, LNS, LNS, LNS, LNS};
+ valA = new String[]{"1", "2", "3", "0"};
+ validateResourceId(nA, nsA, valA, id);
+
+ nA = new String[]{"/", "l1", "k1", "k2", "k3", "c1"};
+ nsA = new String[]{null, LNS, LNS, LNS, LNS, LNS};
+ valA = new String[]{"1", "2", "3"};
+ validateResourceId(nA, nsA, valA, id1);
+
+ nA = new String[]{"/", "l1", "k1", "k2", "k3"};
+ nsA = new String[]{null, LNS, LNS, LNS, LNS};
+ valA = new String[]{"1", "2", "3"};
+ validateResourceId(nA, nsA, valA, id2);
+
+ // Validating the data node.
+ DataNode node = dBlr.build();
+
+ validateDataNode(node, "l1", LNS, MULTI_INSTANCE_NODE,
+ true, null);
+ Iterator<KeyLeaf> keyIt = ((ListKey) node.key())
+ .keyLeafs().iterator();
+
+ validateLeafDataNode(keyIt.next(), "k1", LNS, "1");
+ validateLeafDataNode(keyIt.next(), "k2", LNS, "2");
+ validateLeafDataNode(keyIt.next(), "k3", LNS, "3");
+
+ Iterator<Map.Entry<NodeKey, DataNode>> it1;
+ it1 = ((InnerNode) node).childNodes().entrySet().iterator();
+ validateDataNode(it1.next().getValue(), "k1", LNS,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "1");
+ validateDataNode(it1.next().getValue(), "k2", LNS,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "2");
+ DataNode n1 = it1.next().getValue();
+ validateDataNode(n1, "c1", LNS,
+ SINGLE_INSTANCE_NODE, true, null);
+ validateDataNode(it1.next().getValue(), "k3", LNS,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "3");
+
+ Iterator<Map.Entry<NodeKey, DataNode>> it2;
+ it2 = ((InnerNode) n1).childNodes().entrySet().iterator();
+ validateDataNode(it2.next().getValue(), "leaf_c1", LNS,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "0");
+ walkINTree(node, EXPECTED);
+ }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeListTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeListTest.java
index e5e6579..510ca2e 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeListTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeListTest.java
@@ -41,6 +41,7 @@
import static org.onosproject.yang.runtime.impl.TestUtils.validateDataNode;
import static org.onosproject.yang.runtime.impl.TestUtils.validateLeafDataNode;
import static org.onosproject.yang.runtime.impl.TestUtils.validateResourceId;
+import static org.onosproject.yang.runtime.impl.TestUtils.walkINTree;
/**
* Tests the serializer helper methods.
@@ -78,15 +79,38 @@
String[] nsA;
String[] valA;
+ private static final String[] EXPECTED = {
+ "Entry Node is /.",
+ "Entry Node is l1.",
+ "Entry Node is k1.",
+ "Exit Node is k1.",
+ "Entry Node is k2.",
+ "Exit Node is k2.",
+ "Entry Node is c1.",
+ "Entry Node is leaf_c1.",
+ "Exit Node is leaf_c1.",
+ "Exit Node is c1.",
+ "Entry Node is k3.",
+ "Exit Node is k3.",
+ "Exit Node is l1.",
+ "Entry Node is leaf1.",
+ "Exit Node is leaf1.",
+ "Entry Node is leaf1.",
+ "Exit Node is leaf1.",
+ "Entry Node is leaf1.",
+ "Exit Node is leaf1.",
+ "Entry Node is leaf1.",
+ "Exit Node is leaf1.",
+ "Exit Node is /."
+ };
+
/**
* Test add to data node builder.
*/
@Test
public void addToDataListTest() throws IOException {
-
- Object ob;
+ ResourceId id;
dBlr = initializeDataNode(context);
-
dBlr = addDataNode(dBlr, "l1", LNS, value, null);
value = "1";
dBlr = addDataNode(dBlr, "k1", null, value, null);
@@ -97,7 +121,7 @@
value = null;
dBlr = addDataNode(dBlr, "c1", null, value, null);
value = "0";
- dBlr = addDataNode(dBlr, "l1", null, value, null);
+ dBlr = addDataNode(dBlr, "leaf_c1", null, value, null);
info = (HelperContext) dBlr.appInfo();
id = getResourceId(dBlr);
@@ -125,32 +149,33 @@
value = "3";
dBlr = addDataNode(dBlr, "leaf1", LNS, value, null);
dBlr = exitDataNode(dBlr);
- value = "4";
+ value = null;
dBlr = addDataNode(dBlr, "leaf1", LNS, value, null);
ResourceId id3 = getResourceId(dBlr);
dBlr = exitDataNode(dBlr);
//Tree validation
- nA = new String[]{"/", "l1", "k1", "k2", "k3", "c1", "l1", ""};
- nsA = new String[]{null, LNS, LNS, LNS, LNS, LNS, LNS, ""};
- valA = new String[]{"1", "2", "3", "0", ""};
+ nA = new String[]{"/", "l1", "k1", "k2", "k3", "c1", "leaf_c1"};
+ nsA = new String[]{null, LNS, LNS, LNS, LNS, LNS, LNS};
+ valA = new String[]{"1", "2", "3", "0"};
validateResourceId(nA, nsA, valA, id);
- nA = new String[]{"/", "l1", "k1", "k2", "k3", "c1", ""};
- nsA = new String[]{null, LNS, LNS, LNS, LNS, LNS, ""};
- valA = new String[]{"1", "2", "3", ""};
+ nA = new String[]{"/", "l1", "k1", "k2", "k3", "c1"};
+ nsA = new String[]{null, LNS, LNS, LNS, LNS, LNS};
+ valA = new String[]{"1", "2", "3"};
validateResourceId(nA, nsA, valA, id1);
- nA = new String[]{"/", "l1", "k1", "k2", "k3", ""};
- nsA = new String[]{null, LNS, LNS, LNS, LNS, ""};
- valA = new String[]{"1", "2", "3", ""};
+ nA = new String[]{"/", "l1", "k1", "k2", "k3"};
+ nsA = new String[]{null, LNS, LNS, LNS, LNS};
+ valA = new String[]{"1", "2", "3"};
validateResourceId(nA, nsA, valA, id2);
- nA = new String[]{"/", "leaf1", ""};
- nsA = new String[]{null, LNS, ""};
- valA = new String[]{"4", "2", "3", "0", ""};
+ nA = new String[]{"/", "leaf1"};
+ nsA = new String[]{null, LNS};
+ valA = new String[]{null};
validateResourceId(nA, nsA, valA, id3);
+ // Validating the data node.
DataNode node = dBlr.build();
validateDataNode(node, "/", null, SINGLE_INSTANCE_NODE, true, null);
@@ -180,7 +205,7 @@
Iterator<Map.Entry<NodeKey, DataNode>> it2;
it2 = ((InnerNode) n1).childNodes().entrySet().iterator();
- validateDataNode(it2.next().getValue(), "l1", LNS,
+ validateDataNode(it2.next().getValue(), "leaf_c1", LNS,
SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "0");
validateDataNode(it.next().getValue(), "leaf1", LNS,
MULTI_INSTANCE_LEAF_VALUE_NODE, false, "1");
@@ -189,6 +214,7 @@
validateDataNode(it.next().getValue(), "leaf1", LNS,
MULTI_INSTANCE_LEAF_VALUE_NODE, false, "3");
validateDataNode(it.next().getValue(), "leaf1", LNS,
- MULTI_INSTANCE_LEAF_VALUE_NODE, false, "4");
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, null);
+ walkINTree(dBlr.build(), EXPECTED);
}
}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeLogisticTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeLogisticTest.java
new file mode 100644
index 0000000..fc088d5
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeLogisticTest.java
@@ -0,0 +1,423 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yang.runtime.impl.serializerhelper;
+
+import org.junit.Test;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.InnerNode;
+import org.onosproject.yang.model.KeyLeaf;
+import org.onosproject.yang.model.ListKey;
+import org.onosproject.yang.model.NodeKey;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.runtime.helperutils.HelperContext;
+import org.onosproject.yang.runtime.impl.TestYangSerializerContext;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_LEAF_VALUE_NODE;
+import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_NODE;
+import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE;
+import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_NODE;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.addDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.exitDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.getResourceId;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateLeafDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateResourceId;
+import static org.onosproject.yang.runtime.impl.TestUtils.walkINTree;
+
+/**
+ * Tests the serializer helper methods.
+ */
+public class AddToDataNodeLogisticTest {
+
+ public static final String LMNG = "yrt.Logistics-manager";
+
+ TestYangSerializerContext context = new TestYangSerializerContext();
+
+ /*
+ * Reference for data node info.
+ */
+ HelperContext info;
+
+ /*
+ * Reference for data node builder.
+ */
+ DataNode.Builder dBlr;
+
+ /*
+ * Reference for resource id.
+ */
+ ResourceId id;
+
+ /*
+ * Reference for the value.
+ */
+ String value;
+
+ /*
+ * Reference for string array to used for resource id testing.
+ */
+ String[] nA;
+ String[] nsA;
+ String[] valA;
+
+ private static final String[] EXPECTED = {
+ "Entry Node is /.",
+
+ "Entry Node is Customs-supervisor.",
+ "Exit Node is Customs-supervisor.",
+
+ "Entry Node is Merchandiser-supervisor.",
+ "Exit Node is Merchandiser-supervisor.",
+
+ "Entry Node is Material-supervisor.",
+ "Entry Node is name.",
+ "Exit Node is name.",
+ "Entry Node is departmentId.",
+ "Exit Node is departmentId.",
+ "Exit Node is Material-supervisor.",
+
+ "Entry Node is Material-supervisor.",
+ "Entry Node is name.",
+ "Exit Node is name.",
+ "Entry Node is departmentId.",
+ "Exit Node is departmentId.",
+ "Exit Node is Material-supervisor.",
+
+ "Entry Node is Material-supervisor.",
+ "Entry Node is name.",
+ "Exit Node is name.",
+ "Entry Node is departmentId.",
+ "Exit Node is departmentId.",
+ "Exit Node is Material-supervisor.",
+
+ "Entry Node is Purchasing-supervisor.",
+
+ "Entry Node is purchasing-specialist.",
+ "Exit Node is purchasing-specialist.",
+
+ "Entry Node is support.",
+ "Exit Node is support.",
+
+ "Entry Node is support.",
+ "Exit Node is support.",
+
+ "Entry Node is support.",
+ "Exit Node is support.",
+
+ "Exit Node is Purchasing-supervisor.",
+
+ "Entry Node is Warehouse-supervisor.",
+ "Exit Node is Warehouse-supervisor.",
+
+ "Entry Node is Warehouse-supervisor.",
+ "Exit Node is Warehouse-supervisor.",
+
+ "Entry Node is Warehouse-supervisor.",
+ "Exit Node is Warehouse-supervisor.",
+
+ "Entry Node is Warehouse-supervisor.",
+ "Exit Node is Warehouse-supervisor.",
+
+ "Entry Node is Trading-supervisor.",
+ "Exit Node is Trading-supervisor.",
+
+ "Entry Node is Employee-id.",
+ "Exit Node is Employee-id.",
+
+ "Entry Node is Employee-id.",
+ "Exit Node is Employee-id.",
+
+ "Entry Node is Employee-id.",
+ "Exit Node is Employee-id.",
+
+ "Entry Node is Employee-id.",
+ "Exit Node is Employee-id.",
+ "Exit Node is /."
+ };
+
+ /**
+ * Test add to data node builder logistic manager module.
+ */
+ @Test
+ public void addToDataTest() {
+
+ dBlr = getLogisticModuleDataNode();
+
+ walkINTree(dBlr.build(), EXPECTED);
+ // Validating the data node.
+ DataNode node = dBlr.build();
+ validateDataNode(node, "/", null, SINGLE_INSTANCE_NODE, true, null);
+
+ Map<NodeKey, DataNode> childMap = ((InnerNode) node).childNodes();
+ Iterator<Map.Entry<NodeKey, DataNode>> it = childMap.entrySet().iterator();
+ Map.Entry<NodeKey, DataNode> n = it.next();
+ value = "1";
+ validateDataNode(n.getValue(), "Customs-supervisor", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = "1";
+ validateDataNode(n.getValue(), "Merchandiser-supervisor", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = null;
+ validateDataNode(n.getValue(), "Material-supervisor", LMNG,
+ MULTI_INSTANCE_NODE, true, value);
+
+ Iterator<KeyLeaf> keyIt = ((ListKey) n.getKey()).keyLeafs().iterator();
+ validateLeafDataNode(keyIt.next(), "name", LMNG, "abc");
+
+ Iterator<Map.Entry<NodeKey, DataNode>> it1;
+ it1 = ((InnerNode) n.getValue()).childNodes().entrySet().iterator();
+ validateDataNode(it1.next().getValue(), "name", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "abc");
+ validateDataNode(it1.next().getValue(), "departmentId", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "dep-1");
+
+ n = it.next();
+ value = null;
+ validateDataNode(n.getValue(), "Material-supervisor", LMNG,
+ MULTI_INSTANCE_NODE, true, value);
+
+ keyIt = ((ListKey) n.getKey()).keyLeafs().iterator();
+ validateLeafDataNode(keyIt.next(), "name", LMNG, "abc1");
+ it1 = ((InnerNode) n.getValue()).childNodes().entrySet().iterator();
+ validateDataNode(it1.next().getValue(), "name", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "abc1");
+ validateDataNode(it1.next().getValue(), "departmentId", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "dep-1");
+
+ n = it.next();
+ value = null;
+ validateDataNode(n.getValue(), "Material-supervisor", LMNG,
+ MULTI_INSTANCE_NODE, true, value);
+
+ keyIt = ((ListKey) n.getKey()).keyLeafs().iterator();
+ validateLeafDataNode(keyIt.next(), "name", LMNG, "abc2");
+ it1 = ((InnerNode) n.getValue()).childNodes().entrySet().iterator();
+ validateDataNode(it1.next().getValue(), "name", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "abc2");
+ validateDataNode(it1.next().getValue(), "departmentId", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "dep-1");
+
+ n = it.next();
+ value = null;
+ validateDataNode(n.getValue(), "Purchasing-supervisor", LMNG,
+ SINGLE_INSTANCE_NODE, true, value);
+
+ it1 = ((InnerNode) n.getValue()).childNodes().entrySet().iterator();
+ validateDataNode(it1.next().getValue(), "purchasing-specialist", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, "xyz");
+ validateDataNode(it1.next().getValue(), "support", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, "helpdesk");
+ validateDataNode(it1.next().getValue(), "support", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, "helpdesk1");
+ validateDataNode(it1.next().getValue(), "support", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, "helpdesk2");
+
+ n = it.next();
+ value = "1";
+ validateDataNode(n.getValue(), "Warehouse-supervisor", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = "2";
+ validateDataNode(n.getValue(), "Warehouse-supervisor", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = "3";
+ validateDataNode(n.getValue(), "Warehouse-supervisor", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = "4";
+ validateDataNode(n.getValue(), "Warehouse-supervisor", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = "1";
+ validateDataNode(n.getValue(), "Trading-supervisor", LMNG,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = "1";
+ validateDataNode(n.getValue(), "Employee-id", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = "2";
+ validateDataNode(n.getValue(), "Employee-id", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = "3";
+ validateDataNode(n.getValue(), "Employee-id", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, value);
+
+ n = it.next();
+ value = "4";
+ validateDataNode(n.getValue(), "Employee-id", LMNG,
+ MULTI_INSTANCE_LEAF_VALUE_NODE, false, value);
+ }
+
+ /**
+ * Returns the logistic module data tree.
+ */
+ public DataNode.Builder getLogisticModuleDataNode() {
+ dBlr = initializeDataNode(context);
+
+ value = "1";
+ dBlr = addDataNode(dBlr, "Customs-supervisor", LMNG, value, null);
+ id = getResourceId(dBlr);
+ nA = new String[]{"/", "Customs-supervisor"};
+ nsA = new String[]{null, LMNG};
+ valA = new String[]{"1"};
+ validateResourceId(nA, nsA, valA, id);
+ dBlr = exitDataNode(dBlr);
+
+ dBlr = addDataNode(dBlr, "Merchandiser-supervisor", LMNG, value, null);
+ info = (HelperContext) dBlr.appInfo();
+ id = getResourceId(dBlr);
+ nA = new String[]{"/", "Merchandiser-supervisor"};
+ nsA = new String[]{null, LMNG};
+ valA = new String[]{"1"};
+ validateResourceId(nA, nsA, valA, id);
+
+ dBlr = exitDataNode(dBlr);
+
+ value = null;
+ dBlr = addDataNode(dBlr, "Material-supervisor", LMNG, value, null);
+
+ value = "abc";
+ dBlr = addDataNode(dBlr, "name", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "dep-1";
+ dBlr = addDataNode(dBlr, "departmentId", null, value, null);
+ info = (HelperContext) dBlr.appInfo();
+ id = getResourceId(dBlr);
+ nA = new String[]{"/", "Material-supervisor", "name", "departmentId"};
+ nsA = new String[]{null, LMNG, LMNG, LMNG};
+ valA = new String[]{"abc", "dep-1"};
+ validateResourceId(nA, nsA, valA, id);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+
+ id = getResourceId(dBlr);
+ nA = new String[]{"/"};
+ nsA = new String[]{null};
+ valA = new String[]{};
+ validateResourceId(nA, nsA, valA, id);
+
+ value = null;
+ dBlr = addDataNode(dBlr, "Material-supervisor", LMNG, value, null);
+
+ value = "abc1";
+ dBlr = addDataNode(dBlr, "name", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "dep-1";
+ dBlr = addDataNode(dBlr, "departmentId", null, value, null);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+
+ value = null;
+ dBlr = addDataNode(dBlr, "Material-supervisor", LMNG, value, null);
+
+ value = "abc2";
+ dBlr = addDataNode(dBlr, "name", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "dep-1";
+ dBlr = addDataNode(dBlr, "departmentId", null, value, null);
+ id = getResourceId(dBlr);
+ nA = new String[]{"/", "Material-supervisor", "name", "departmentId"};
+ nsA = new String[]{null, LMNG, LMNG, LMNG};
+ valA = new String[]{"abc2", "dep-1"};
+ validateResourceId(nA, nsA, valA, id);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+
+ value = null;
+ dBlr = addDataNode(dBlr, "Purchasing-supervisor", LMNG, value, null);
+
+ value = "xyz";
+ dBlr = addDataNode(dBlr, "purchasing-specialist", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "helpdesk";
+ dBlr = addDataNode(dBlr, "support", null, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "helpdesk1";
+ dBlr = addDataNode(dBlr, "support", null, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "helpdesk2";
+ dBlr = addDataNode(dBlr, "support", null, value, null);
+ id = getResourceId(dBlr);
+ nA = new String[]{"/", "Purchasing-supervisor", "support"};
+ nsA = new String[]{null, LMNG, LMNG};
+ valA = new String[]{"helpdesk2"};
+ validateResourceId(nA, nsA, valA, id);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+
+ value = "1";
+ dBlr = addDataNode(dBlr, "Warehouse-supervisor", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "2";
+ dBlr = addDataNode(dBlr, "Warehouse-supervisor", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "3";
+ dBlr = addDataNode(dBlr, "Warehouse-supervisor", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "4";
+ dBlr = addDataNode(dBlr, "Warehouse-supervisor", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "1";
+ dBlr = addDataNode(dBlr, "Trading-supervisor", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "1";
+ dBlr = addDataNode(dBlr, "Employee-id", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "2";
+ dBlr = addDataNode(dBlr, "Employee-id", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "3";
+ dBlr = addDataNode(dBlr, "Employee-id", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "4";
+ dBlr = addDataNode(dBlr, "Employee-id", LMNG, value, null);
+ dBlr = exitDataNode(dBlr);
+ return dBlr;
+ }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeRidTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeRidTest.java
index f2a38ad..e578cdf 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeRidTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToDataNodeRidTest.java
@@ -22,11 +22,13 @@
import org.onosproject.yang.runtime.helperutils.HelperContext;
import org.onosproject.yang.runtime.impl.TestYangSerializerContext;
+import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.addDataNode;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.addToResourceId;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.getResourceId;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeDataNode;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeResourceId;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateDataNode;
import static org.onosproject.yang.runtime.impl.TestUtils.validateResourceId;
/**
@@ -75,15 +77,19 @@
rIdBlr = addToResourceId(rIdBlr, "l1", LNS, value);
rIdBlr = addToResourceId(rIdBlr, "c1", LNS, value);
dBlr = initializeDataNode(rIdBlr);
- value = "0";
- dBlr = addDataNode(dBlr, "l1", null, value, null);
+ value = null;
+ dBlr = addDataNode(dBlr, "leaf_c1", null, value, null);
info = (HelperContext) dBlr.appInfo();
id = getResourceId(dBlr);
//Tree validation
- nA = new String[]{"/", "l1", "c1", "l1", ""};
- nsA = new String[]{null, LNS, LNS, LNS, ""};
- valA = new String[]{"0", ""};
+ nA = new String[]{"/", "l1", "c1", "leaf_c1"};
+ nsA = new String[]{null, LNS, LNS, LNS};
+ valA = new String[]{null};
validateResourceId(nA, nsA, valA, id);
+
+ DataNode node = dBlr.build();
+ validateDataNode(node, "leaf_c1", LNS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, null);
}
}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToResourceIdTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToResourceIdTest.java
index 271a649..bb13fd2 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToResourceIdTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AddToResourceIdTest.java
@@ -66,7 +66,7 @@
String[] valA;
/**
- * Test add to data node builder.
+ * Test add to resource id with all list key.
*/
@Test
public void addToDataListTest() {
@@ -80,9 +80,27 @@
ResourceId id = rIdBlr.build();
//Tree validation
- nA = new String[]{"/", "l1", "k1", "k2", "k3", ""};
- nsA = new String[]{null, LNS, LNS, LNS, LNS, ""};
- valA = new String[]{"1", "2", "3", ""};
+ nA = new String[]{"/", "l1", "k1", "k2", "k3"};
+ nsA = new String[]{null, LNS, LNS, LNS, LNS};
+ valA = new String[]{"1", "2", "3"};
+ validateResourceId(nA, nsA, valA, id);
+ }
+
+ /**
+ * Test add to resource id without any key.
+ */
+ @Test
+ public void addToDataList1Test() {
+
+ ResourceId.Builder rIdBlr = initializeResourceId(context);
+ List<String> valueSet = null;
+ rIdBlr = addToResourceId(rIdBlr, "l1", LNS, valueSet);
+ ResourceId id = rIdBlr.build();
+
+ //Tree validation
+ nA = new String[]{"/", "l1"};
+ nsA = new String[]{null, LNS};
+ valA = new String[]{};
validateResourceId(nA, nsA, valA, id);
}
}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/DataNodeInitializationTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/DataNodeInitializationTest.java
index 4c95a74..b5edb5f 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/DataNodeInitializationTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/DataNodeInitializationTest.java
@@ -23,9 +23,13 @@
import org.onosproject.yang.runtime.helperutils.HelperContext;
import org.onosproject.yang.runtime.impl.TestYangSerializerContext;
+import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_NODE;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.getResourceId;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeDataNode;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeResourceId;
import static org.onosproject.yang.runtime.impl.TestUtils.checkRootLevelContext;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateResourceId;
/**
* Tests the initialize data node methods in serializer helper.
@@ -49,6 +53,19 @@
*/
DataNode.Builder dBlr;
+ /*
+ * Reference for resource id.
+ */
+ ResourceId id;
+
+
+ /*
+ * Reference for string array to used for resource id testing.
+ */
+ String[] nA;
+ String[] nsA;
+ String[] valA;
+
/**
* Checks initialize data node using context.
*/
@@ -59,6 +76,13 @@
info = (HelperContext) dBlr.appInfo();
checkRootLevelContext((SchemaContext) info.getResourceIdBuilder()
.appInfo());
+ id = getResourceId(dBlr);
+ nA = new String[]{"/"};
+ nsA = new String[]{null};
+ valA = new String[]{};
+ validateResourceId(nA, nsA, valA, id);
+ validateDataNode(dBlr.build(), "/", null,
+ SINGLE_INSTANCE_NODE, true, null);
}
/**
@@ -72,5 +96,12 @@
info = (HelperContext) dBlr.appInfo();
checkRootLevelContext((SchemaContext) info.getParentResourceIdBldr()
.appInfo());
+ id = getResourceId(dBlr);
+ nA = new String[]{"/"};
+ nsA = new String[]{null};
+ valA = new String[]{};
+ validateResourceId(nA, nsA, valA, id);
+ validateDataNode(dBlr.build(), "/", null,
+ SINGLE_INSTANCE_NODE, true, null);
}
}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/ResourceIdInitializationTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/ResourceIdInitializationTest.java
index 2ef2864..66e8f31 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/ResourceIdInitializationTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/ResourceIdInitializationTest.java
@@ -23,9 +23,9 @@
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.addToResourceId;
import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeResourceId;
-import static org.onosproject.yang.runtime.impl.schemacontext.SchemaContextTest.IETFNS;
import static org.onosproject.yang.runtime.impl.TestUtils.checkRootLevelContext;
import static org.onosproject.yang.runtime.impl.TestUtils.validateResourceId;
+import static org.onosproject.yang.runtime.impl.schemacontext.SchemaContextTest.IETFNS;
/**
* Tests the initialize resource id methods in serializer helper.
@@ -71,9 +71,9 @@
rIdBlr = addToResourceId(rIdBlr, "network-id", null, value);
ResourceId id = rIdBlr.build();
- nA = new String[]{"/", "networks", "network", "network-id", ""};
- nsA = new String[]{null, IETFNS, IETFNS, IETFNS, ""};
- valA = new String[]{"network1", ""};
+ nA = new String[]{"/", "networks", "network", "network-id"};
+ nsA = new String[]{null, IETFNS, IETFNS, IETFNS};
+ valA = new String[]{"network1"};
validateResourceId(nA, nsA, valA, id);
}
}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/ResourceIdNegative3Test.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/ResourceIdNegative3Test.java
index a7e39ca..175364a 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/ResourceIdNegative3Test.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/ResourceIdNegative3Test.java
@@ -52,7 +52,7 @@
valueSet.add("2");
boolean isExpOccurred = false;
try {
- rIdBlr = addToResourceId(rIdBlr, "l1", LNS, valueSet);
+ addToResourceId(rIdBlr, "l1", LNS, valueSet);
} catch (IllegalArgumentException e) {
isExpOccurred = true;
assertEquals(e.getMessage(), E_TOO_FEW);
diff --git a/runtime/src/test/resources/schemaProviderTestYangFiles/Logistics-manager.yang b/runtime/src/test/resources/schemaProviderTestYangFiles/Logistics-manager.yang
new file mode 100644
index 0000000..87c5db6
--- /dev/null
+++ b/runtime/src/test/resources/schemaProviderTestYangFiles/Logistics-manager.yang
@@ -0,0 +1,66 @@
+module Logistics-manager {
+
+ yang-version 1;
+
+ namespace "yrt.Logistics-manager";
+
+ prefix "root";
+
+ organization "ON-LAB";
+
+ description "This module defines for organisation.";
+
+ revision "2016-05-24" {
+ description "Initial revision.";
+ }
+
+ leaf Customs-supervisor {
+ type string;
+ description "name of the customs-supervisor.";
+ }
+
+ leaf Merchandiser-supervisor {
+ type string;
+ description "name of merchandiser-supervisor";
+ }
+
+ list Material-supervisor {
+ key "name";
+ leaf name {
+ type string;
+ description "name of logistics-supervisor";
+ }
+
+ leaf departmentId {
+ type string;
+ description "name of department";
+ }
+ }
+
+ container Purchasing-supervisor {
+ leaf purchasing-specialist {
+ type string;
+ description "name of the purchasing-specialist person";
+ }
+
+ leaf-list support {
+ type string;
+ description "name of the support person";
+ }
+ }
+
+ leaf-list Warehouse-supervisor {
+ type string;
+ description "name of the warehouse-supervisor's";
+ }
+
+ leaf Trading-supervisor {
+ type string;
+ description "name of the trading-supervisor";
+ }
+
+ leaf-list Employee-id {
+ type string;
+ description "list of the employee id";
+ }
+}
\ No newline at end of file
diff --git a/runtime/src/test/resources/schemaProviderTestYangFiles/list.yang b/runtime/src/test/resources/schemaProviderTestYangFiles/list.yang
index 122ce11..2ff07dc 100644
--- a/runtime/src/test/resources/schemaProviderTestYangFiles/list.yang
+++ b/runtime/src/test/resources/schemaProviderTestYangFiles/list.yang
@@ -29,7 +29,7 @@
}
container c1 {
- leaf l1 {
+ leaf leaf_c1 {
type string;
}
}