[ONOS-7064] Yang Runtime support for Anydata code base
Change-Id: I6e3cde428e730b553b9b73700519bc749760148d
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/AnydataHandler.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/AnydataHandler.java
new file mode 100644
index 0000000..6541e3e
--- /dev/null
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/AnydataHandler.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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;
+
+import org.onosproject.yang.compiler.datamodel.AugmentedSchemaInfo;
+import org.onosproject.yang.compiler.datamodel.SchemaDataNode;
+import org.onosproject.yang.compiler.datamodel.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNodeContextInfo;
+
+import java.util.Iterator;
+
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.DOT_REGEX;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.INVAL_ANYDATA;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.QNAME_PRE;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.errorMsg;
+import static org.onosproject.yang.runtime.RuntimeHelper.PERIOD;
+import static org.onosproject.yang.runtime.impl.UtilsConstants.REV_REGEX;
+
+public final class AnydataHandler {
+
+ /**
+ * Prevent creation of anydataHandler.
+ */
+ private AnydataHandler() {
+ }
+
+ /**
+ * Returns schema node corresponding to a given class.
+ *
+ * @param c generated class
+ * @param reg YANG model registry
+ * @return module schema node
+ * @throws IllegalArgumentException when provided identifier is not
+ * not valid
+ */
+ public static YangSchemaNode getSchemaNode(Class c,
+ DefaultYangModelRegistry reg) {
+ String cn = c.getCanonicalName();
+ String[] paths = cn.split(DOT_REGEX);
+ // index 6 always we the revision in the given class path if path
+ // contains the revision
+ int index = 6;
+ if (paths[index].matches(REV_REGEX)) {
+ index++;
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append(QNAME_PRE);
+ for (int i = 4; i <= index; i++) {
+ sb.append(PERIOD);
+ sb.append(paths[i]);
+ }
+ YangSchemaNode module = reg.getForRegClassQualifiedName(sb.toString(),
+ false);
+
+ if (module == null) {
+ throw new IllegalArgumentException(errorMsg(INVAL_ANYDATA, c));
+ }
+
+ YangSchemaNode targetNode = getTargetNode(cn, paths, module, index + 1);
+ return targetNode;
+ }
+
+ /**
+ * Returns the targeted child node YANG schema from the given schema node.
+ *
+ * @param paths canonical name of class
+ * @param s top level schema node
+ * @param index index of child in module
+ * @return targeted child node YANG schema
+ * @throws IllegalArgumentException when provided identifier is not
+ * not valid
+ */
+ private static YangSchemaNode getTargetNode(
+ String cn, String[] paths, YangSchemaNode s,
+ int index) throws IllegalArgumentException {
+ int i = index;
+ YangSchemaNodeContextInfo info;
+ YangSchemaNode schema = s;
+
+ while (i < paths.length) {
+ Iterator<YangSchemaNodeContextInfo> it = schema.getYsnContextInfoMap()
+ .values().iterator();
+ boolean isSuccess = false;
+ while (it.hasNext()) {
+ info = it.next();
+ schema = info.getSchemaNode();
+ if (schema instanceof SchemaDataNode) {
+ if (schema.getJavaAttributeName().equalsIgnoreCase(paths[i])) {
+ isSuccess = true;
+ break;
+ }
+ }
+ }
+ if (!isSuccess) {
+ // In case of augment the top level node will not be found in
+ // above iteration.
+ if (i == index && i < paths.length - 1) {
+ AugmentedSchemaInfo in = ((YangModule) s).getAugmentedSchemaInfo(cn);
+ i = in.getPosition();
+ schema = in.getSchemaNode();
+ } else {
+ throw new IllegalArgumentException(errorMsg(INVAL_ANYDATA, cn));
+ }
+ }
+ i++;
+ }
+ return schema;
+ }
+}
\ No newline at end of file
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DataTreeBuilderHelper.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DataTreeBuilderHelper.java
index 8f7a11b..0f56b4b 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DataTreeBuilderHelper.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DataTreeBuilderHelper.java
@@ -28,6 +28,7 @@
import org.onosproject.yang.compiler.datamodel.YangList;
import org.onosproject.yang.compiler.datamodel.YangNode;
import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.model.Anydata;
import org.onosproject.yang.model.DataNode;
import org.onosproject.yang.model.InnerNode;
import org.onosproject.yang.model.LeafNode;
@@ -43,6 +44,7 @@
import static org.onosproject.yang.compiler.datamodel.TraversalType.PARENT;
import static org.onosproject.yang.compiler.datamodel.TraversalType.ROOT;
import static org.onosproject.yang.compiler.datamodel.TraversalType.SIBLING;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.ANYDATA_NODE;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.nonEmpty;
import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_LEAF_VALUE_NODE;
import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_NODE;
@@ -64,6 +66,7 @@
import static org.onosproject.yang.runtime.impl.ModelConverterUtil.isNodeProcessCompleted;
import static org.onosproject.yang.runtime.impl.ModelConverterUtil.isNonProcessableNode;
import static org.onosproject.yang.runtime.impl.ModelConverterUtil.isTypeEmpty;
+import static org.onosproject.yang.runtime.impl.YobConstants.E_FAIL_TO_LOAD_CLASS;
/**
@@ -438,6 +441,7 @@
}
switch (curNode.getYangSchemaNodeType()) {
+ case YANG_ANYDATA_NODE:
case YANG_SINGLE_INSTANCE_NODE:
curNodeInfo.type(SINGLE_INSTANCE_NODE);
nodeObj = processSingleInstanceNode(curNode, curNodeInfo,
@@ -696,6 +700,11 @@
*/
Object getChildObject(YangNode curNode,
DataTreeNodeInfo parentNodeInfo) {
+ // check current node parent linking status if current node
+ if (curNode.getParent() != null && curNode.getParent()
+ .getNodeType() == ANYDATA_NODE) {
+ return getAnydataChildObject(curNode, parentNodeInfo);
+ }
String nodeJavaName = curNode.getJavaAttributeName();
Object parentObj = getParentObjectOfNode(parentNodeInfo,
curNode.getParent());
@@ -707,6 +716,42 @@
}
/**
+ * Returns the child object from the parent object for anydatad. Uses java
+ * name of the current node to search the attribute in the parent object.
+ *
+ * @param curNode current YANG node
+ * @param info parent data tree node info
+ * @return object of the child node
+ */
+ private Object getAnydataChildObject(YangNode curNode,
+ DataTreeNodeInfo info) {
+ // Getting the curNode anydata parent object
+ Anydata parentObj = (Anydata) getParentObjectOfNode(
+ info, curNode.getParent());
+ List<Object> objs = new ArrayList<>();
+ YangSchemaNode node = reg.getForNameSpace(
+ curNode.getNameSpace().getModuleNamespace(), false);
+ // Getting the module class
+ Class<?> moduleClass = reg.getRegisteredClass(node);
+ if (moduleClass == null) {
+ throw new ModelConverterException(E_FAIL_TO_LOAD_CLASS + node
+ .getJavaClassNameOrBuiltInType());
+ }
+
+ // Forming the default class name for the curNode object creation.
+ String className = curNode.getJavaPackage() + PERIOD + DEFAULT_CAPS +
+ getCapitalCase(curNode.getJavaAttributeName());
+ Class childClass;
+ try {
+ childClass = moduleClass.getClassLoader().loadClass(className);
+ } catch (ClassNotFoundException e) {
+ throw new ModelConverterException(E_FAIL_TO_LOAD_CLASS + className);
+ }
+ objs.add(parentObj.anydata(childClass));
+ return objs;
+ }
+
+ /**
* Adds the child node to the data tree by taking operation type from the
* object. Also, binds the object to the data node through data tree node
* info.
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYangModelRegistry.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYangModelRegistry.java
index c20fc12..7e95130 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYangModelRegistry.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYangModelRegistry.java
@@ -48,14 +48,24 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Collections.sort;
import static java.util.Collections.unmodifiableSet;
+import static org.onosproject.yang.compiler.datamodel.YangSchemaNodeType.YANG_ANYDATA_NODE;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getDateInStringFormat;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getNodeIdFromSchemaId;
+import static org.onosproject.yang.compiler.translator.tojava.JavaCodeGeneratorUtil.updateTreeContext;
import static org.onosproject.yang.compiler.utils.UtilConstants.REGEX;
import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_NODE;
import static org.onosproject.yang.runtime.RuntimeHelper.getInterfaceClassName;
import static org.onosproject.yang.runtime.RuntimeHelper.getNodes;
import static org.onosproject.yang.runtime.RuntimeHelper.getSelfNodes;
import static org.onosproject.yang.runtime.RuntimeHelper.getServiceName;
+import static org.onosproject.yang.runtime.impl.AnydataHandler.getSchemaNode;
+import static org.onosproject.yang.runtime.impl.UtilsConstants.AT;
+import static org.onosproject.yang.runtime.impl.UtilsConstants.E_MEXIST;
+import static org.onosproject.yang.runtime.impl.UtilsConstants.E_NEXIST;
+import static org.onosproject.yang.runtime.impl.UtilsConstants.E_NOT_VAL;
+import static org.onosproject.yang.runtime.impl.UtilsConstants.E_NULL;
+import static org.onosproject.yang.runtime.impl.UtilsConstants.FMT_INV;
+import static org.onosproject.yang.runtime.impl.UtilsConstants.errorMsg;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -63,14 +73,8 @@
*/
public class DefaultYangModelRegistry implements YangModelRegistry,
SingleInstanceNodeContext {
-
- private static final String AT = "@";
- private static final String E_NEXIST = "node with {} namespace not found.";
- private static final String E_MEXIST =
- "Model with given modelId already exist";
- private static final String E_NULL = "Model must not be null";
- private static final String E_NOT_VAL = "Model id is invalid";
private final Logger log = getLogger(getClass());
+
/*
* Map for storing YANG schema nodes. Key will be the schema name of
* module node defined in YANG file.
@@ -165,9 +169,20 @@
}
@Override
- public void registerAnydataSchema(Class id, Class id1) throws
- IllegalArgumentException{
- //TODO implemention
+ public void registerAnydataSchema(Class ac, Class cc) throws
+ IllegalArgumentException {
+ YangSchemaNode anySchema = getSchemaNode(ac, this);
+ if (anySchema != null && anySchema.getYangSchemaNodeType() == YANG_ANYDATA_NODE) {
+ YangSchemaNode cSchema = getSchemaNode(cc, this);
+ if (cSchema != null) {
+ YangSchemaNode clonedNode = anySchema.addSchema(cSchema);
+ updateTreeContext(clonedNode, null, false, false);
+ } else {
+ throw new IllegalArgumentException(errorMsg(FMT_INV, cc));
+ }
+ } else {
+ throw new IllegalArgumentException(errorMsg(FMT_INV, ac));
+ }
}
@Override
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/UtilsConstants.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/UtilsConstants.java
new file mode 100644
index 0000000..13a67b2
--- /dev/null
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/UtilsConstants.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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;
+
+public final class UtilsConstants {
+
+ static final String AT = "@";
+ static final String E_NEXIST = "node with {} namespace not found.";
+ static final String E_MEXIST =
+ "Model with given modelId already exist";
+ static final String E_NULL = "Model must not be null";
+ static final String E_NOT_VAL = "Model id is invalid";
+ static final String REV_REGEX =
+ "rev([12]\\d{3}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01]))";
+ private static final String FMT_NOT_EXIST =
+ "Schema node with name %s doesn't exist.";
+ public static final String FMT_NREG =
+ "Node with requested %s identifier is not registered.";
+ public static final String FMT_INV =
+ "Requested %s identifier is invalid.";
+ public static final String E_NCLONE =
+ "Unenable to clone node with given identifer %s .";
+
+ // No instantiation.
+ private UtilsConstants() {
+ }
+
+ /**
+ * Returns the error string by filling the parameters in the given
+ * formatted error string.
+ *
+ * @param fmt error format string
+ * @param params parameters to be filled in formatted string
+ * @return error string
+ */
+ public static String errorMsg(String fmt, Object... params) {
+ return String.format(fmt, params);
+ }
+}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobHandler.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobHandler.java
index f772742..bcdebf0 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobHandler.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobHandler.java
@@ -16,10 +16,13 @@
package org.onosproject.yang.runtime.impl;
+import org.onosproject.yang.compiler.datamodel.YangNode;
import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
import org.onosproject.yang.model.DataNode;
import org.onosproject.yang.runtime.YangModelRegistry;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.ANYDATA_NODE;
+import static org.onosproject.yang.runtime.impl.YobUtils.ANYDATA_SETTER;
import static org.onosproject.yang.runtime.impl.YobUtils.getClassLoader;
import static org.onosproject.yang.runtime.impl.YobUtils.getInstanceOfClass;
import static org.onosproject.yang.runtime.impl.YobUtils.getQualifiedDefaultClass;
@@ -40,13 +43,25 @@
YobWorkBench createObject(YangSchemaNode schemaNode,
DefaultYangModelRegistry reg) {
YangSchemaNode node = schemaNode;
+ String setterName;
+ YangNode n = (YangNode) node;
+ /**
+ * if current node parent is anydata then it need to be added into
+ * anydata map, so in setter for same in parent will be addAnydata
+ */
+ if (n.getParent() != null && (n.getParent().getNodeType() ==
+ ANYDATA_NODE)) {
+ setterName = ANYDATA_SETTER;
+ } else {
+ setterName = schemaNode.getJavaAttributeName();
+ }
+
while (node.getReferredSchema() != null) {
node = node.getReferredSchema();
}
String qualName = getQualifiedDefaultClass(node);
ClassLoader classLoader = getClassLoader(node, reg);
- String setterName = schemaNode.getJavaAttributeName();
Object builtObject = getInstanceOfClass(classLoader, qualName);
return new YobWorkBench(classLoader, builtObject, setterName,
schemaNode);
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
index 63505ad..3f10d34 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
@@ -83,6 +83,7 @@
public static final String FORWARD_SLASH = "/";
private static final Logger log = LoggerFactory.getLogger(YobUtils.class);
private static final String ENUM_LEAF_IDENTIFIER = "$LeafIdentifier";
+ static final String ANYDATA_SETTER = "addAnydata";
// no instantiation
private YobUtils() {
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobWorkBench.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobWorkBench.java
index ddef955..63875e5 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobWorkBench.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobWorkBench.java
@@ -46,6 +46,7 @@
import static org.onosproject.yang.runtime.impl.YobConstants.L_FAIL_TO_GET_FIELD;
import static org.onosproject.yang.runtime.impl.YobConstants.L_FAIL_TO_GET_METHOD;
import static org.onosproject.yang.runtime.impl.YobConstants.L_FAIL_TO_INVOKE_METHOD;
+import static org.onosproject.yang.runtime.impl.YobUtils.ANYDATA_SETTER;
import static org.onosproject.yang.runtime.impl.YobUtils.getCapitalCase;
import static org.onosproject.yang.runtime.impl.YobUtils.getInstanceOfClass;
import static org.onosproject.yang.runtime.impl.YobUtils.getQualifiedDefaultClass;
@@ -221,6 +222,12 @@
String parentClassName = parentClass.getName();
try {
Class<?> classType = null;
+ if (setter.equals(ANYDATA_SETTER)) {
+ Method method = parentClass.getSuperclass()
+ .getDeclaredMethod(setter, InnerModelObject.class);
+ method.invoke(parentObj, curObj);
+ return;
+ }
Field fieldName = parentClass.getDeclaredField(setter);
if (fieldName != null) {
classType = fieldName.getType();
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 50acec5..f059e1f 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
@@ -60,7 +60,7 @@
public static final String L_NAME = "list";
public static final String LMNG = "yrt.Logistics-manager";
public static final String LMNG_N = "Logistics-manager";
-
+ public static final String TANY_NS = "yrt:list.test.anydata";
// Logger list is used for walker testing.
private static final List<String> LOGGER = new ArrayList<>();
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/TestYangSerializerContext.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/TestYangSerializerContext.java
index c2f8f0e..ef73cc1 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/TestYangSerializerContext.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/TestYangSerializerContext.java
@@ -30,10 +30,23 @@
*/
public class TestYangSerializerContext implements YangSerializerContext {
+ // Reference for YANG model registry
+ private DefaultYangModelRegistry reg;
+
+ /**
+ * Returns the YANG model registry.
+ *
+ * @return YANG model registry
+ */
+ public DefaultYangModelRegistry getRegistry() {
+ return reg;
+ }
+
@Override
public SchemaContext getContext() {
processSchemaRegistry();
- return registry();
+ reg = registry();
+ return reg;
}
@Override
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobAnydataTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobAnydataTest.java
new file mode 100644
index 0000000..75b1544
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobAnydataTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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;
+
+import org.junit.Test;
+import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.network.DefaultNode;
+import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.network.Node;
+import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.network.node.SupportingNode;
+import org.onosproject.yang.gen.v1.yrtnetworktopology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.DefaultLink;
+import org.onosproject.yang.gen.v1.yrtnetworktopology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.Link;
+import org.onosproject.yang.gen.v1.ytbaugmentfromanotherfile.rev20160826.ytbaugmentfromanotherfile.networks.network.node.augmentedndnode.terminationpoint.SupportingTerminationPoint;
+import org.onosproject.yang.gen.v11.anytest.rev20160624.anytest.DefaultC1;
+import org.onosproject.yang.gen.v11.anytest.rev20160624.anytest.c1.DefaultMydata2;
+import org.onosproject.yang.gen.v11.anytest.rev20160624.anytest.c1.Mydata2;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.DefaultResourceData;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ResourceData;
+
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yang.runtime.SerializerHelper.addDataNode;
+import static org.onosproject.yang.runtime.SerializerHelper.exitDataNode;
+import static org.onosproject.yang.runtime.SerializerHelper.initializeDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.IETFNS;
+import static org.onosproject.yang.runtime.impl.TestUtils.TANY_NS;
+
+/**
+ * Tests the YANG object building for the YANG data nodes based on the non
+ * schema augmented nodes.
+ */
+public class YobAnydataTest {
+ private static final String NW_TOPO_NAME_SPACE = "urn:ietf:params:xml:ns:yang:yrt-ietf-network-topology";
+ TestYangSerializerContext context = new TestYangSerializerContext();
+ DataNode.Builder dBlr;
+ String value;
+
+ public DataNode buildDnForAnydata() {
+ dBlr = initializeDataNode(context);
+ value = null;
+ // Adding container c1
+ dBlr = addDataNode(dBlr, "c1", TANY_NS, value, null);
+ // Adding anydata container
+ dBlr = addDataNode(dBlr, "mydata2", TANY_NS, value, null);
+ context.getRegistry().registerAnydataSchema(Mydata2.class, Node.class);
+ context.getRegistry().registerAnydataSchema(Mydata2.class, DefaultLink.class);
+ context.getRegistry().registerAnydataSchema(Mydata2.class, SupportingTerminationPoint.class);
+
+ // Adding list inside anydata container
+ dBlr = addDataNode(dBlr, "link", NW_TOPO_NAME_SPACE, value, null);
+ value = "link-id";
+ dBlr = addDataNode(dBlr, "link-id", NW_TOPO_NAME_SPACE, value, null);
+ dBlr = exitDataNode(dBlr);
+ value = null;
+ dBlr = addDataNode(dBlr, "source", NW_TOPO_NAME_SPACE, value, null);
+ value = "source-node";
+ dBlr = addDataNode(dBlr, "source-node", NW_TOPO_NAME_SPACE, value, null);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr); // exit source
+ dBlr = exitDataNode(dBlr); // exit link
+
+ // Adding list inside anydata container
+ value = null;
+ dBlr = addDataNode(dBlr, "node", IETFNS, value, null);
+ // Adding key element node-id
+ value = "node1";
+ dBlr = addDataNode(dBlr, "node-id", null, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = null;
+ // Adding list inside list
+ dBlr = addDataNode(dBlr, "supporting-node", null, value, null);
+ // Adding key element network-ref
+ value = "network3";
+ dBlr = addDataNode(dBlr, "network-ref", null, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "network4";
+ // Adding key element node-ref
+ dBlr = addDataNode(dBlr, "node-ref", null, value, null);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+ return dBlr.build();
+ }
+
+
+ @Test
+ public void anydataTest() {
+ DataNode dataNode = buildDnForAnydata();
+ ResourceData data = DefaultResourceData.builder()
+ .addDataNode(dataNode).build();
+ DefaultYobBuilder builder = new DefaultYobBuilder(context.getRegistry());
+ ModelObjectData modelObjectData = builder.getYangObject(data);
+ List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+ ModelObject modelObject = modelObjectList.get(0);
+ DefaultC1 c1 = ((DefaultC1) modelObject);
+ DefaultMydata2 mydata2 = ((DefaultMydata2) c1.mydata2());
+
+ Link link = mydata2.anydata(DefaultLink.class);
+ assertThat(link.linkId().toString(), is("link-id"));
+ assertThat(link.source().sourceNode().toString(), is("source-node"));
+
+ Node node = mydata2.anydata(DefaultNode.class);
+ assertThat(node.nodeId().toString(), is("node1"));
+ SupportingNode snode = (SupportingNode) node.supportingNode().get(0);
+ assertThat(snode.networkRef().toString(), is("network3"));
+ assertThat(snode.nodeRef().toString(), is("network4"));
+ }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YtbAnydataTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YtbAnydataTest.java
new file mode 100644
index 0000000..eef9de7
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YtbAnydataTest.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.gen.v1.yrtietfinettypes.rev20130715.yrtietfinettypes.Uri;
+import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.NetworkId;
+import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.NodeId;
+import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.network.DefaultNode;
+import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.network.Node;
+import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.network.node.DefaultSupportingNode;
+import org.onosproject.yang.gen.v1.yrtnetworktopology.rev20151208.yrtnetworktopology.LinkId;
+import org.onosproject.yang.gen.v1.yrtnetworktopology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.DefaultLink;
+import org.onosproject.yang.gen.v1.yrtnetworktopology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.Link;
+import org.onosproject.yang.gen.v1.yrtnetworktopology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.link.DefaultSource;
+import org.onosproject.yang.gen.v11.anytest.rev20160624.anytest.DefaultC1;
+import org.onosproject.yang.gen.v11.anytest.rev20160624.anytest.c1.DefaultMydata2;
+import org.onosproject.yang.gen.v11.anytest.rev20160624.anytest.c1.Mydata2;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.DefaultModelObjectData.Builder;
+import org.onosproject.yang.model.InnerNode;
+import org.onosproject.yang.model.ModelObjectId;
+import org.onosproject.yang.model.NodeKey;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.SchemaId;
+
+import java.util.Iterator;
+import java.util.List;
+
+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.impl.MockYangSchemaNodeProvider.processSchemaRegistry;
+import static org.onosproject.yang.runtime.impl.MockYangSchemaNodeProvider.registry;
+import static org.onosproject.yang.runtime.impl.TestUtils.IETFNS;
+import static org.onosproject.yang.runtime.impl.TestUtils.TANY_NS;
+import static org.onosproject.yang.runtime.impl.TestUtils.TOPONS;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateDataNode;
+
+/**
+ * Unit test cases for resource id conversion from model object id.
+ */
+public class YtbAnydataTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+ private ResourceData rscData;
+ private DefaultDataTreeBuilder treeBuilder;
+ private ResourceId id;
+ private List<NodeKey> keys;
+ private SchemaId sid;
+ private ModelObjectId mid;
+ private Builder data;
+ DefaultYangModelRegistry reg;
+
+ /**
+ * Prior setup for each UT.
+ */
+ @Before
+ public void setUp() {
+ processSchemaRegistry();
+ reg = registry();
+ treeBuilder = new DefaultDataTreeBuilder(reg);
+ }
+
+
+ /**
+ * Processes anydata with augmented node as child.
+ */
+ @Test
+ public void processAnydataTest() {
+
+ reg.registerAnydataSchema(Mydata2.class, Node.class);
+ reg.registerAnydataSchema(Mydata2.class, Link.class);
+ DefaultC1 c1 = new DefaultC1();
+ DefaultMydata2 mydata2 = new DefaultMydata2();
+
+ // link
+ DefaultLink link = new DefaultLink();
+ link.linkId(new LinkId(new Uri("link-id")));
+ DefaultSource source = new DefaultSource();
+ source.sourceNode(new NodeId(new Uri("source-node")));
+ link.source(source);
+
+ //node
+ DefaultNode node = new DefaultNode();
+ node.nodeId(new NodeId(new Uri("node1")));
+ DefaultSupportingNode sn = new DefaultSupportingNode();
+ sn.networkRef(new NetworkId(new Uri("network3")));
+ sn.nodeRef(new NodeId(new Uri("network4")));
+ node.addToSupportingNode(sn);
+ mydata2.addAnydata(link);
+ mydata2.addAnydata(node);
+
+ c1.mydata2(mydata2);
+ data = new Builder();
+ data.addModelObject(c1);
+ rscData = treeBuilder.getResourceData(data.build());
+
+ List<DataNode> nodes = rscData.dataNodes();
+ DataNode n = nodes.get(0);
+ validateDataNode(n, "c1", TANY_NS, SINGLE_INSTANCE_NODE,
+ true, null);
+ n = ((InnerNode) n).childNodes().values().iterator().next();
+ validateDataNode(n, "mydata2", TANY_NS, SINGLE_INSTANCE_NODE,
+ true, null);
+ Iterator<DataNode> it = ((InnerNode) n).childNodes().values().iterator();
+
+ // node validation
+ n = it.next();
+ validateDataNode(n, "node", IETFNS, MULTI_INSTANCE_NODE,
+ true, null);
+
+ Iterator<DataNode> it1 = ((InnerNode) n).childNodes().values().iterator();
+ n = it1.next();
+ validateDataNode(n, "node-id", IETFNS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "node1");
+ n = it1.next();
+ validateDataNode(n, "supporting-node", IETFNS, MULTI_INSTANCE_NODE,
+ true, null);
+
+ Iterator<DataNode> it2 = ((InnerNode) n).childNodes().values()
+ .iterator();
+ n = it2.next();
+ validateDataNode(n, "network-ref", IETFNS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "network3");
+ n = it2.next();
+ validateDataNode(n, "node-ref", IETFNS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "network4");
+
+ //link validation
+ n = it.next();
+ validateDataNode(n, "link", TOPONS, MULTI_INSTANCE_NODE,
+ true, null);
+
+ it1 = ((InnerNode) n).childNodes().values().iterator();
+ n = it1.next();
+ validateDataNode(n, "link-id", TOPONS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "link-id");
+ n = it1.next();
+ validateDataNode(n, "source", TOPONS, SINGLE_INSTANCE_NODE,
+ true, null);
+
+ it2 = ((InnerNode) n).childNodes().values().iterator();
+ n = it2.next();
+ validateDataNode(n, "source-node", TOPONS,
+ SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "source-node");
+ }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AnydataNegativeScenarioTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AnydataNegativeScenarioTest.java
new file mode 100644
index 0000000..5ffbb8e
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/AnydataNegativeScenarioTest.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.gen.v1.check.check.List52Keys;
+import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.network.Node;
+import org.onosproject.yang.gen.v11.listanydata.rev20160624.ListAnydata;
+import org.onosproject.yang.gen.v11.listanydata.rev20160624.ListAnydataOpParam;
+import org.onosproject.yang.gen.v11.listanydata.rev20160624.listanydata.Mydata;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.runtime.impl.TestYangSerializerContext;
+
+import static org.junit.Assert.assertEquals;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.INVAL_ANYDATA;
+import static org.onosproject.yang.runtime.impl.UtilsConstants.FMT_INV;
+
+/**
+ * Tests the serializer helper methods.
+ */
+public class AnydataNegativeScenarioTest {
+
+ TestYangSerializerContext context = new TestYangSerializerContext();
+
+ /*
+ * Reference for data node builder.
+ */
+ DataNode.Builder dBlr;
+
+ /**
+ * Test anydata add to data node negative test scenario when given
+ * referenced node is not of type anydata.
+ */
+ @Test
+ public void addToDataTest() {
+ boolean isExpOccurred = false;
+ context.getContext();
+ try {
+ context.getRegistry().registerAnydataSchema(Node.class, Node.class);
+ } catch (IllegalArgumentException e) {
+ isExpOccurred = true;
+ assertEquals(e.getMessage(), String.format(FMT_INV, Node.class));
+ }
+ assertEquals(isExpOccurred, true);
+ }
+
+ /**
+ * Test anydata add to data node negative test scenario when given
+ * referenced node module is not registered.
+ */
+ @Test
+ public void addToData2Test() {
+ boolean isExpOccurred = false;
+ context.getContext();
+ try {
+ context.getRegistry().registerAnydataSchema(Mydata.class,
+ ListAnydataOpParam.class);
+ } catch (IllegalArgumentException e) {
+ isExpOccurred = true;
+ assertEquals(e.getMessage(), String.format(
+ INVAL_ANYDATA, ListAnydataOpParam.class));
+ }
+ assertEquals(isExpOccurred, true);
+ }
+
+
+ /**
+ * Test anydata add to data node negative test scenario when given
+ * referenced node is not of type list/container.
+ */
+ @Test
+ public void addToData3Test() {
+ boolean isExpOccurred = false;
+ context.getContext();
+ try {
+ context.getRegistry().registerAnydataSchema(Mydata.class,
+ ListAnydata.class);
+ } catch (IllegalArgumentException e) {
+ isExpOccurred = true;
+ assertEquals(e.getMessage(), String.format(
+ INVAL_ANYDATA, ListAnydata.class));
+ }
+ assertEquals(isExpOccurred, true);
+ }
+
+ /**
+ * Test anydata add to data node negative test scenario when given
+ * referenced node is not of type list/container.
+ */
+ @Test
+ public void addToData4Test() {
+ boolean isExpOccurred = false;
+ context.getContext();
+ try {
+ context.getRegistry().registerAnydataSchema(Mydata.class,
+ List52Keys.class);
+ } catch (IllegalArgumentException e) {
+ isExpOccurred = true;
+ assertEquals(e.getMessage(), String.format(
+ INVAL_ANYDATA, List52Keys.class.getCanonicalName()));
+ }
+ assertEquals(isExpOccurred, true);
+ }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/IetfNetAnydataTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/IetfNetAnydataTest.java
new file mode 100644
index 0000000..8b9a9cd
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/serializerhelper/IetfNetAnydataTest.java
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.network.Node;
+import org.onosproject.yang.gen.v1.yrtnetworktopology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.Link;
+import org.onosproject.yang.gen.v11.anytest.rev20160624.anytest.c1.Mydata2;
+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.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_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.SerializerHelper.addDataNode;
+import static org.onosproject.yang.runtime.SerializerHelper.exitDataNode;
+import static org.onosproject.yang.runtime.SerializerHelper.initializeDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.IETFNS;
+import static org.onosproject.yang.runtime.impl.TestUtils.TANY_NS;
+import static org.onosproject.yang.runtime.impl.TestUtils.TOPONS;
+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.walkINTree;
+
+/**
+ * Tests the serializer helper methods.
+ */
+public class IetfNetAnydataTest {
+
+ 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 c1.",
+ "Entry Node is mydata2.",
+ "Entry Node is link.",
+ "Entry Node is link-id.",
+ "Exit Node is link-id.",
+ "Entry Node is source.",
+ "Entry Node is source-node.",
+ "Exit Node is source-node.",
+ "Exit Node is source.",
+ "Exit Node is link.",
+ "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 mydata2.",
+ "Exit Node is c1.",
+ "Exit Node is /."
+ };
+
+ /**
+ * Test anydata add to data node builder.
+ */
+ @Test
+ public void addToDataTest() {
+
+ dBlr = initializeDataNode(context);
+ value = null;
+ // Adding container c1
+ dBlr = addDataNode(dBlr, "c1", TANY_NS, value, null);
+ // Adding anydata container
+ dBlr = addDataNode(dBlr, "mydata2", TANY_NS, value, null);
+ context.getRegistry().registerAnydataSchema(Mydata2.class, Node.class);
+ context.getRegistry().registerAnydataSchema(Mydata2.class, Link.class);
+ // Adding list inside anydata container
+ dBlr = addDataNode(dBlr, "link", TOPONS, value, null);
+ value = "link-id";
+ dBlr = addDataNode(dBlr, "link-id", TOPONS, value, null);
+ dBlr = exitDataNode(dBlr);
+ value = null;
+ dBlr = addDataNode(dBlr, "source", TOPONS, value, null);
+ value = "source-node";
+ dBlr = addDataNode(dBlr, "source-node", TOPONS, value, null);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr); // exit source
+ dBlr = exitDataNode(dBlr); // exit link
+
+ // Adding list inside anydata container
+ value = null;
+ dBlr = addDataNode(dBlr, "node", IETFNS, value, null);
+ // Adding key element node-id
+ value = "node1";
+ dBlr = addDataNode(dBlr, "node-id", null, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = null;
+ // Adding list inside list
+ dBlr = addDataNode(dBlr, "supporting-node", null, value, null);
+ // Adding key element network-ref
+ value = "network3";
+ dBlr = addDataNode(dBlr, "network-ref", null, value, null);
+ dBlr = exitDataNode(dBlr);
+
+ value = "network4";
+ // Adding key element node-ref
+ dBlr = addDataNode(dBlr, "node-ref", null, value, null);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+ dBlr = exitDataNode(dBlr);
+
+ // 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>> iter = childMap.entrySet()
+ .iterator();
+ DataNode n = iter.next().getValue();
+ validateDataNode(n, "c1", TANY_NS, SINGLE_INSTANCE_NODE,
+ true, null);
+ n = ((InnerNode) n).childNodes().values().iterator().next();
+ validateDataNode(n, "mydata2", TANY_NS, SINGLE_INSTANCE_NODE,
+ true, null);
+ Iterator<DataNode> it = ((InnerNode) n).childNodes().values().iterator();
+
+ //link validation
+ n = it.next();
+ validateDataNode(n, "link", TOPONS, MULTI_INSTANCE_NODE,
+ true, null);
+ Iterator<KeyLeaf> keyIt = ((ListKey) n.key()).keyLeafs().iterator();
+
+ validateLeafDataNode(keyIt.next(), "link-id", TOPONS, "link-id");
+ Iterator<DataNode> it1 = ((InnerNode) n).childNodes().values().iterator();
+ n = it1.next();
+ validateDataNode(n, "link-id", TOPONS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "link-id");
+ n = it1.next();
+ validateDataNode(n, "source", TOPONS, SINGLE_INSTANCE_NODE,
+ true, null);
+
+ Iterator<DataNode> it2 = ((InnerNode) n).childNodes().values().iterator();
+ n = it2.next();
+ validateDataNode(n, "source-node", TOPONS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "source-node");
+
+ // node validation
+ n = it.next();
+ validateDataNode(n, "node", IETFNS, MULTI_INSTANCE_NODE,
+ true, null);
+ keyIt = ((ListKey) n.key()).keyLeafs().iterator();
+
+ validateLeafDataNode(keyIt.next(), "node-id", IETFNS, "node1");
+
+ it1 = ((InnerNode) n).childNodes().values().iterator();
+ n = it1.next();
+ validateDataNode(n, "node-id", IETFNS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "node1");
+ n = it1.next();
+ validateDataNode(n, "supporting-node", IETFNS, MULTI_INSTANCE_NODE,
+ true, null);
+
+ keyIt = ((ListKey) n.key()).keyLeafs().iterator();
+
+ validateLeafDataNode(keyIt.next(), "network-ref", IETFNS, "network3");
+
+ it2 = ((InnerNode) n).childNodes().values().iterator();
+ n = it2.next();
+ validateDataNode(n, "network-ref", IETFNS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "network3");
+ n = it2.next();
+ validateDataNode(n, "node-ref", IETFNS, SINGLE_INSTANCE_LEAF_VALUE_NODE,
+ false, "network4");
+
+ walkINTree(dBlr.build(), EXPECTED);
+ }
+}
diff --git a/runtime/src/test/resources/schemaProviderTestYangFiles/anyTest.yang b/runtime/src/test/resources/schemaProviderTestYangFiles/anyTest.yang
new file mode 100644
index 0000000..d125541
--- /dev/null
+++ b/runtime/src/test/resources/schemaProviderTestYangFiles/anyTest.yang
@@ -0,0 +1,24 @@
+module anyTest {
+
+ yang-version 1.1;
+
+ namespace "yrt:list.test.anydata";
+
+ prefix "l";
+
+ organization "ON-LAB";
+
+ description "This module defines for list.";
+
+ revision "2016-06-24" {
+ description "Initial revision.";
+ }
+
+ anydata mydata {
+
+ }
+ container c1 {
+ anydata mydata2 {
+ }
+ }
+}
\ No newline at end of file