[ONOS-5962]YANG Runtime: ModelConverter's createModel implementation

Change-Id: I8377ad86d0b0b60f96c4d8d40517cede66c5fc27
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobAugmentTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobAugmentTest.java
new file mode 100644
index 0000000..3572f0c
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobAugmentTest.java
@@ -0,0 +1,225 @@
+/*
+ * 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;
+
+import org.junit.Test;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.rev20151208.yrtietfnetwork.DefaultNetworks;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.rev20151208.yrtietfnetwork.networks.DefaultNetwork;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.rev20151208.yrtietfnetwork.networks.Network;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.topology.rev20151208.yrtnetworktopology.networks.network.DefaultAugmentedNdNetwork;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.topology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.DefaultLink;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.topology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.Link;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.networks.network.link.DefaultAugmentedNtLink;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.telinkaugment.te.Config;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.telinkconfig.bundlestacklevel.Bundle;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.telinkconfig.bundlestacklevel.bundle.bundledlinks.BundledLink;
+import org.onosproject.yang.gen.v1.urn.ip.topo.rev20140101.ymsiptopology.node.DefaultAugmentedTopoNode;
+import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.DefaultNode;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.runtime.DefaultResourceData;
+
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+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.initializeDataNode;
+
+/**
+ * Tests the YANG object building for the YANG data nodes based on the non
+ * schema augmented nodes.
+ */
+public class YobAugmentTest {
+    private static final String TOPO_NAME_SPACE = "urn:topo";
+    private static final String IP_TOPO_NAME_SPACE = "urn:ip:topo";
+    private static final String NW_NAME_SPACE = "urn:ietf:params:xml:ns:yang:yrt-ietf-network";
+    private static final String NW_TOPO_NAME_SPACE = "urn:ietf:params:xml:ns:yang:yrt-ietf-network-topology";
+    private static final String TE_TOPO_NAME_SPACE =
+            "urn:ietf:params:xml:ns:yang:yrt-ietf-te-topology";
+    TestYangSerializerContext context = new TestYangSerializerContext();
+    DataNode.Builder dBlr;
+    String value;
+
+    public DataNode buildDataNodeForAugmentedLeaves() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "node", TOPO_NAME_SPACE, value, null);
+
+        value = "id";
+        dBlr = addDataNode(dBlr, "node-id", TOPO_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "str1";
+        dBlr = addDataNode(dBlr, "router-id", IP_TOPO_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "str2";
+        dBlr = addDataNode(dBlr, "router-ip", IP_TOPO_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        return dBlr.build();
+    }
+
+    public DataNode buildDnForAugmentedList() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "networks", NW_NAME_SPACE, value, null);
+        dBlr = addDataNode(dBlr, "network", NW_NAME_SPACE, value, null);
+        value = "network-id";
+        dBlr = addDataNode(dBlr, "network-id", NW_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = null;
+        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
+        dBlr = exitDataNode(dBlr); // exit network
+        dBlr = exitDataNode(dBlr); // exit networks
+        return dBlr.build();
+    }
+
+    public DataNode buildDnForAugmentedListWithResourceId() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "node", TOPO_NAME_SPACE, value, null);
+
+        value = "id";
+        dBlr = addDataNode(dBlr, "node-id", TOPO_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "str1";
+        dBlr = addDataNode(dBlr, "router-id", IP_TOPO_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "str2";
+        dBlr = addDataNode(dBlr, "router-ip", IP_TOPO_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        return dBlr.build();
+    }
+
+    public DataNode buildDnForChoiceCase() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "networks", NW_NAME_SPACE, value, null);
+        dBlr = addDataNode(dBlr, "network", NW_NAME_SPACE, value, null);
+        value = "network-id";
+        dBlr = addDataNode(dBlr, "network-id", NW_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = null;
+        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, "te", TE_TOPO_NAME_SPACE, value, null);
+        dBlr = addDataNode(dBlr, "config", TE_TOPO_NAME_SPACE, value, null);
+        dBlr = addDataNode(dBlr, "bundled-links", TE_TOPO_NAME_SPACE, value, null);
+        dBlr = addDataNode(dBlr, "bundled-link", TE_TOPO_NAME_SPACE, value, null);
+        value = "100";
+        dBlr = addDataNode(dBlr, "sequence", TE_TOPO_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr); // exit sequence
+        value = "101";
+        dBlr = addDataNode(dBlr, "src-tp-ref", TE_TOPO_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr); // exit src-tp-ref
+        dBlr = exitDataNode(dBlr); // exit list bundled-link
+        dBlr = exitDataNode(dBlr); // exit bundled-links
+        value = "abc";
+        dBlr = addDataNode(dBlr, "te-link-template", TE_TOPO_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr); // te-link-template
+        dBlr = exitDataNode(dBlr); // config
+        dBlr = exitDataNode(dBlr); // te
+        dBlr = exitDataNode(dBlr); // exit link
+        dBlr = exitDataNode(dBlr); // exit network
+        dBlr = exitDataNode(dBlr); // exit networks
+        return dBlr.build();
+    }
+
+    @Test
+    public void augmentedLeaf() {
+        DataNode dataNode = buildDataNodeForAugmentedLeaves();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode)
+                .build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        DefaultNode node = ((DefaultNode) modelObject);
+        assertThat(node.nodeId(), is("id"));
+        DefaultAugmentedTopoNode obj = node
+                .augmentation(DefaultAugmentedTopoNode.class);
+        assertThat(obj.routerId(), is("str1"));
+        assertThat(obj.routerIp(), is("str2"));
+    }
+
+    @Test
+    public void augmentedList() {
+        DataNode dataNode = buildDnForAugmentedList();
+        ResourceData data = DefaultResourceData.builder()
+                .addDataNode(dataNode).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        DefaultNetworks networks = ((DefaultNetworks) modelObject);
+        Network network = networks.network().get(0);
+        assertThat(network.networkId().toString(), is("network-id"));
+        DefaultAugmentedNdNetwork augNw = ((DefaultNetwork) network)
+                .augmentation(DefaultAugmentedNdNetwork.class);
+        Link link = augNw.link().get(0);
+        assertThat(link.linkId().toString(), is("link-id"));
+        assertThat(link.source().sourceNode().toString(), is("source-node"));
+    }
+
+    @Test
+    public void augmentedChoiceCase() {
+        DataNode dataNode = buildDnForChoiceCase();
+        ResourceData data = DefaultResourceData.builder()
+                .addDataNode(dataNode).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        DefaultNetworks networks = ((DefaultNetworks) modelObject);
+        Network network = networks.network().get(0);
+        assertThat(network.networkId().toString(), is("network-id"));
+        DefaultAugmentedNdNetwork augNw = ((DefaultNetwork) network)
+                .augmentation(DefaultAugmentedNdNetwork.class);
+        Link link = augNw.link().get(0);
+        assertThat(link.linkId().toString(), is("link-id"));
+        DefaultAugmentedNtLink augLink = ((DefaultLink) link)
+                .augmentation(DefaultAugmentedNtLink.class);
+        Config config = augLink.te().config();
+        assertThat(config.teLinkTemplate().get(0), is("abc"));
+        BundledLink bundledLink = ((Bundle) config.bundleStackLevel())
+                .bundledLinks().bundledLink().get(0);
+        assertThat(bundledLink.srcTpRef(), is("101"));
+        assertThat(bundledLink.sequence(), is(100L));
+    }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobBasicYangConstructTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobBasicYangConstructTest.java
new file mode 100644
index 0000000..be21b0c
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobBasicYangConstructTest.java
@@ -0,0 +1,260 @@
+/*
+ * 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;
+
+import org.junit.Test;
+import org.onosproject.yang.gen.v1.samplenamespace.sample.DefaultL1;
+import org.onosproject.yang.gen.v1.samplenamespace.sample.DefaultTop;
+import org.onosproject.yang.gen.v1.samplenamespace.sample.l1.C1;
+import org.onosproject.yang.gen.v1.samplenamespace.sample.top.DefaultYangAutoPrefixInterface;
+import org.onosproject.yang.gen.v1.samplenamespace.sample.top.YangAutoPrefixInterface;
+import org.onosproject.yang.gen.v1.samplenamespace.sample.top.yangautoprefixinterface.Address;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.LeafModelObject;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.runtime.DefaultResourceData;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.onosproject.yang.gen.v1.samplenamespace.Sample.LeafIdentifier.LEAF5;
+import static org.onosproject.yang.gen.v1.samplenamespace.Sample.LeafIdentifier.LEAF6;
+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.exitDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeResourceId;
+
+/**
+ * Tests the YANG object building for the YANG data nodes.
+ */
+public class YobBasicYangConstructTest {
+    private static final String NAME_SPACE = "samplenamespace";
+    TestYangSerializerContext context = new TestYangSerializerContext();
+    private DataNode.Builder dBlr;
+    private String value;
+    private ResourceId.Builder rIdBlr;
+
+    private DataNode buildDataNode() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "top", NAME_SPACE, value, null);
+        value = "100";
+        dBlr = addDataNode(dBlr, "mtu", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = "1123";
+        dBlr = addDataNode(dBlr, "color", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = null;
+        dBlr = addDataNode(dBlr, "interface", null, value, null);
+        value = "name";
+        dBlr = addDataNode(dBlr, "name", null, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = null;
+        dBlr = addDataNode(dBlr, "address", null, value, null);
+        value = "name";
+        dBlr = addDataNode(dBlr, "name", null, value, null);
+        dBlr = exitDataNode(dBlr);
+        dBlr = exitDataNode(dBlr); // exit address
+        dBlr = exitDataNode(dBlr); // exit interface
+        dBlr = exitDataNode(dBlr); // exit top
+
+        value = null;
+        dBlr = addDataNode(dBlr, "l1", NAME_SPACE, value, null);
+        dBlr = addDataNode(dBlr, "c1", NAME_SPACE, value, null);
+        value = "leaf1_value";
+        dBlr = addDataNode(dBlr, "leaf1", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = "leaf2_value";
+        dBlr = addDataNode(dBlr, "leaf2", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        dBlr = exitDataNode(dBlr); // exit container c1
+        value = "leaf3_value";
+        dBlr = addDataNode(dBlr, "leaf3", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = "leaf4_value";
+        dBlr = addDataNode(dBlr, "leaf4", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        dBlr = exitDataNode(dBlr); // exit list l1
+        return dBlr.build();
+    }
+
+    private DataNode buildDnForModuleLevelLeaf() {
+        dBlr = initializeDataNode(context);
+        value = "abc";
+        dBlr = addDataNode(dBlr, "leaf5", NAME_SPACE, value, null);
+        return dBlr.build();
+    }
+
+    private DataNode buildDnForModuleLevelLeafList() {
+        dBlr = initializeDataNode(context);
+        value = "def";
+        dBlr = addDataNode(dBlr, "leaf6", NAME_SPACE, value, null);
+        return dBlr.build();
+    }
+
+    private DataNode buildDataNodeWithResourceIdForL1() {
+        ResourceId.Builder builder = buildResourceId();
+        dBlr = initializeDataNode(builder);
+        dBlr = addDataNode(dBlr, "c1", NAME_SPACE, value, null);
+        value = "leaf1_value";
+        dBlr = addDataNode(dBlr, "leaf1", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = "leaf2_value";
+        dBlr = addDataNode(dBlr, "leaf2", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        return dBlr.build();
+    }
+
+    private ResourceId.Builder buildResourceIdForContainerTop() {
+        rIdBlr = initializeResourceId(context);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "top", NAME_SPACE, value);
+        return rIdBlr;
+    }
+
+    private DataNode buildDataNodeWithResourceIdForLeafL3() {
+        ResourceId.Builder builder = buildResourceId();
+        dBlr = initializeDataNode(builder);
+        value = "leaf3_value";
+        dBlr = addDataNode(dBlr, "leaf3", NAME_SPACE, value, null);
+        return dBlr.build();
+    }
+
+    private ResourceId.Builder buildResourceId() {
+        rIdBlr = initializeResourceId(context);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "l1", NAME_SPACE, value);
+        return rIdBlr;
+    }
+
+    @Test
+    public void testBasicYangConstruct() throws IOException {
+        DataNode dataNode = buildDataNode();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        DefaultTop top = ((DefaultTop) modelObject);
+        assertThat(top.mtu(), is("100"));
+        assertThat(top.color().get(0), is("1123"));
+
+        List<YangAutoPrefixInterface> intfList = top.yangAutoPrefixInterface();
+        YangAutoPrefixInterface intf = intfList.get(0);
+        assertThat(intf.name(), is("name"));
+
+        Address address = intf.address();
+        assertThat(address.name(), is("name"));
+
+        modelObject = modelObjectList.get(1);
+        DefaultL1 l1 = ((DefaultL1) modelObject);
+        C1 c1 = l1.c1();
+        assertThat(c1.leaf1(), is("leaf1_value"));
+        assertThat(c1.leaf2().get(0), is("leaf2_value"));
+        assertThat(l1.leaf3(), is("leaf3_value"));
+        assertThat(l1.leaf4().get(0), is("leaf4_value"));
+    }
+
+    @Test
+    public void testModuleLevelLeaf() throws IOException {
+        DataNode dataNode = buildDnForModuleLevelLeaf();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode)
+                .build();
+
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        LeafModelObject obj = ((LeafModelObject) modelObject);
+        assertThat(obj.leafIdentifier(), is(LEAF5));
+        assertThat(obj.values().get(0), is("abc"));
+    }
+
+    @Test
+    public void testModuleLevelLeafList() throws IOException {
+        DataNode dataNode = buildDnForModuleLevelLeafList();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode)
+                .build();
+
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        LeafModelObject obj = ((LeafModelObject) modelObject);
+        assertThat(obj.leafIdentifier(), is(LEAF6));
+        assertThat(obj.values().get(0), is("def"));
+    }
+
+    @Test
+    public void testWithResourceId() {
+        DataNode dataNode = buildDataNodeWithResourceIdForL1();
+        ResourceId.Builder rIdbuilder = buildResourceId();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode)
+                .addDataNode(buildDataNodeWithResourceIdForLeafL3())
+                .resourceId(rIdbuilder.build()).build();
+
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        C1 c1 = ((C1) modelObject);
+        assertThat(c1.leaf1(), is("leaf1_value"));
+        assertThat(c1.leaf2().get(0), is("leaf2_value"));
+    }
+
+    @Test
+    public void testWithRIdForContainerTop() {
+        ResourceId.Builder builder = buildResourceIdForContainerTop();
+        dBlr = initializeDataNode(builder);
+        value = "mtu";
+        dBlr = addDataNode(dBlr, "mtu", NAME_SPACE, value, null);
+        ResourceData.Builder dataBdlr = DefaultResourceData.builder()
+                .addDataNode(dBlr.build());
+        dBlr = initializeDataNode(builder);
+        value = "color";
+        dBlr = addDataNode(dBlr, "color", NAME_SPACE, value, null);
+        dataBdlr = dataBdlr.addDataNode(dBlr.build());
+        dBlr = initializeDataNode(builder);
+        value = null;
+        dBlr = addDataNode(dBlr, "interface", NAME_SPACE, value, null);
+        value = "name";
+        dBlr = addDataNode(dBlr, "name", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        dataBdlr = dataBdlr.addDataNode(dBlr.build()).resourceId(builder.build());
+        DefaultYobBuilder yobBuilder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = yobBuilder.getYangObject(dataBdlr.build());
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        LeafModelObject mtu = ((LeafModelObject) modelObject);
+        assertThat(mtu.values().get(0), is("mtu"));
+        LeafModelObject color = ((LeafModelObject) modelObjectList.get(1));
+        assertThat(color.values().get(0), is("color"));
+        DefaultYangAutoPrefixInterface intf = ((DefaultYangAutoPrefixInterface)
+                modelObjectList.get(2));
+        assertThat(intf.name(), is("name"));
+    }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobChoiceTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobChoiceTest.java
new file mode 100644
index 0000000..a063b8a
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobChoiceTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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;
+
+import org.junit.Test;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.telinkconfig.bundlestacklevel.bundle.DefaultBundledLinks;
+import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.DefaultNode;
+import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.Case1a;
+import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.Case1b;
+import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.case1b.choice1b.Case1Bi;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.runtime.DefaultResourceData;
+
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+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.exitDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeDataNode;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeResourceId;
+
+/**
+ * Tests the YANG object building for the YANG data nodes.
+ */
+public class YobChoiceTest {
+
+    private static final String NAME_SPACE = "urn:topo";
+    private static final String NW_NS = "urn:ietf:params:xml:ns:yang:yrt-ietf-network";
+    private static final String TE_NS = "urn:ietf:params:xml:ns:yang:yrt-ietf-te-topology";
+    private static final String NW_TOPO_NS =
+            "urn:ietf:params:xml:ns:yang:yrt-ietf-network-topology";
+    TestYangSerializerContext context = new TestYangSerializerContext();
+    private DataNode.Builder dBlr;
+    private String value;
+    private ResourceId.Builder rIdBlr;
+
+    public DataNode buildDataNodeForCaseInChoice() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "node", NAME_SPACE, value, null);
+
+        value = "id";
+        dBlr = addDataNode(dBlr, "node-id", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "str1";
+        dBlr = addDataNode(dBlr, "leaf1a1", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "str2";
+        dBlr = addDataNode(dBlr, "leaf1a2", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        return dBlr.build();
+    }
+
+    public DataNode buildDataNodeForRecursiveChoice() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "node", NAME_SPACE, value, null);
+
+        value = "id";
+        dBlr = addDataNode(dBlr, "node-id", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "str1";
+        dBlr = addDataNode(dBlr, "leaf1bia", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "str2";
+        dBlr = addDataNode(dBlr, "leaf1bib", NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        return dBlr.build();
+    }
+
+    private ResourceId.Builder buildRIdForNodeInsideChoiceCase() {
+        rIdBlr = initializeResourceId(context);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "networks", NW_NS, value);
+        rIdBlr = addToResourceId(rIdBlr, "network", NW_NS, value);
+        value = "network-id";
+        rIdBlr = addToResourceId(rIdBlr, "network-id", NW_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "link", NW_TOPO_NS, value);
+        value = "link-id";
+        rIdBlr = addToResourceId(rIdBlr, "link-id", NW_TOPO_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "te", TE_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "config", TE_NS, value);
+        return rIdBlr;
+    }
+
+    public DataNode buildDnForChoiceCaseWithRid() {
+        ResourceId.Builder rIdBdlr = buildRIdForNodeInsideChoiceCase();
+        dBlr = initializeDataNode(rIdBdlr);
+        value = null;
+        dBlr = addDataNode(dBlr, "bundled-links", TE_NS, value, null);
+        return dBlr.build();
+    }
+
+    @Test
+    public void caseInChoice() {
+        DataNode dataNode = buildDataNodeForCaseInChoice();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode)
+                .build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        DefaultNode node = ((DefaultNode) modelObject);
+        assertThat(node.nodeId(), is("id"));
+        assertThat(((Case1a) node.choice1()).leaf1A1(), is("str1"));
+        assertThat(((Case1a) node.choice1()).leaf1A2(), is("str2"));
+    }
+
+    @Test
+    public void recursiveChoice() {
+        DataNode dataNode = buildDataNodeForRecursiveChoice();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode)
+                .build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        DefaultNode node = ((DefaultNode) modelObject);
+        assertThat(node.nodeId(), is("id"));
+        assertThat(((Case1Bi) ((Case1b) node.choice1()).choice1b()).leaf1Bia(),
+                   is("str1"));
+        assertThat(((Case1Bi) ((Case1b) node.choice1()).choice1b()).leaf1Bib(),
+                   is("str2"));
+    }
+
+    @Test
+    public void testChoiceCaseWithResourceId() {
+        ResourceId.Builder rIdBdlr = buildRIdForNodeInsideChoiceCase();
+        DataNode dataNode = buildDnForChoiceCaseWithRid();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode)
+                .resourceId(rIdBdlr.build()).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        assertThat(modelObject instanceof DefaultBundledLinks, is(true));
+    }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobGroupingUsesTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobGroupingUsesTest.java
new file mode 100644
index 0000000..13dec1a
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobGroupingUsesTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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;
+
+import org.junit.Test;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.rev20151208.yrtietfnetwork.DefaultNetworks;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.schedule.rev20160301.yrtietfschedule.schedules.schedules.Schedule;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.networks.DefaultAugmentedNwNetworks;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.tetopologiesaugment.te.templates.LinkTemplate;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.runtime.DefaultResourceData;
+
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+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.initializeDataNode;
+
+/**
+ * Tests the YANG object building for the YANG data tree based on the non
+ * schema augmented nodes.
+ */
+public class YobGroupingUsesTest {
+    TestYangSerializerContext context = new TestYangSerializerContext();
+    private static final String NW_NS = "urn:ietf:params:xml:ns:yang:yrt-ietf-network";
+    private static final String TE_NS = "urn:ietf:params:xml:ns:yang:yrt-ietf-te-topology";
+    private DataNode.Builder dBlr;
+    private String value;
+
+
+    public DataNode buildDataNodeForInterFileGrouping() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "networks", NW_NS, value, null);
+        dBlr = addDataNode(dBlr, "te", TE_NS, value, null);
+        dBlr = addDataNode(dBlr, "templates", TE_NS, value, null);
+        dBlr = addDataNode(dBlr, "link-template", TE_NS, value, null);
+        value = "name";
+        dBlr = addDataNode(dBlr, "name", TE_NS, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = null;
+        dBlr = addDataNode(dBlr, "te-link-attributes", TE_NS, value, null);
+        dBlr = addDataNode(dBlr, "schedules", TE_NS, value, null);
+        dBlr = addDataNode(dBlr, "schedule", TE_NS, value, null);
+        value = "100";
+        dBlr = addDataNode(dBlr, "schedule-id", TE_NS, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = "start";
+        dBlr = addDataNode(dBlr, "start", TE_NS, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = "schedule-duration";
+        dBlr = addDataNode(dBlr, "schedule-duration", TE_NS, value, null);
+        dBlr = exitDataNode(dBlr);
+        value = "repeat-interval";
+        dBlr = addDataNode(dBlr, "repeat-interval", TE_NS, value, null);
+        dBlr = exitDataNode(dBlr);
+        dBlr = exitDataNode(dBlr); // schedule
+        dBlr = exitDataNode(dBlr); // schedules
+        dBlr = exitDataNode(dBlr); // te-link-attributes
+        dBlr = exitDataNode(dBlr); // link-template
+        dBlr = exitDataNode(dBlr); // templates
+        dBlr = exitDataNode(dBlr); // te
+        dBlr = exitDataNode(dBlr); // networks
+        return dBlr.build();
+    }
+
+    @Test
+    public void testInterFileGrouping() {
+        DataNode dataNode = buildDataNodeForInterFileGrouping();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        DefaultNetworks networks = ((DefaultNetworks) modelObject);
+        DefaultAugmentedNwNetworks augNws = networks
+                .augmentation(DefaultAugmentedNwNetworks.class);
+        LinkTemplate linkTmp = augNws.te().templates().linkTemplate().get(0);
+        assertThat(linkTmp.name().toString(), is("name"));
+        Schedule sh = linkTmp.teLinkAttributes().schedules().schedule().get(0);
+        assertThat(sh.scheduleId(), is(100L));
+        assertThat(sh.start().toString(), is("start"));
+        assertThat(sh.scheduleDuration(), is("schedule-duration"));
+        assertThat(sh.repeatInterval(), is("repeat-interval"));
+    }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobRIdToMoIdConverterTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobRIdToMoIdConverterTest.java
new file mode 100644
index 0000000..aa3938f
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobRIdToMoIdConverterTest.java
@@ -0,0 +1,287 @@
+/*
+ * 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;
+
+import org.junit.Test;
+import org.onosproject.yang.gen.v1.samplenamespace.Sample;
+import org.onosproject.yang.gen.v1.samplenamespace.sample.DefaultL2;
+import org.onosproject.yang.gen.v1.samplenamespace.sample.DefaultTop;
+import org.onosproject.yang.gen.v1.samplenamespace.sample.L2Keys;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.rev20151208.yrtietfnetwork.DefaultNetworks;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.rev20151208.yrtietfnetwork.networks.DefaultNetwork;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.topology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.DefaultLink;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.network.topology.rev20151208.yrtnetworktopology.networks.network.augmentedndnetwork.link.DefaultSource;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.telinkconfig.bundlestacklevel.bundle.DefaultBundledLinks;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.tetopologyaugment.DefaultTe;
+import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.yrt.ietf.te.topology.rev20160317.yrtietftetopology.tetopologyaugment.te.DefaultConfig;
+import org.onosproject.yang.model.AtomicPath;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ModelObjectId;
+import org.onosproject.yang.model.MultiInstanceLeaf;
+import org.onosproject.yang.model.MultiInstanceNode;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.SingleInstanceLeaf;
+import org.onosproject.yang.model.SingleInstanceNode;
+import org.onosproject.yang.runtime.DefaultResourceData;
+
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.addToResourceId;
+import static org.onosproject.yang.runtime.helperutils.SerializerHelper.initializeResourceId;
+
+/**
+ * Tests resource id to model object id convertion.
+ */
+public class YobRIdToMoIdConverterTest {
+    private static final String NAME_SPACE = "samplenamespace";
+    TestYangSerializerContext context = new TestYangSerializerContext();
+    private static final String NW_NS = "urn:ietf:params:xml:ns:yang:yrt-ietf-network";
+    private static final String TE_TOPO_NS =
+            "urn:ietf:params:xml:ns:yang:yrt-ietf-te-topology";
+    private static final String NW_TOPO_NS = "urn:ietf:params:xml:ns:yang:yrt-ietf-network-topology";
+    private String value;
+    private ResourceId.Builder rIdBlr;
+
+    private ResourceId.Builder buildRIdForTopLevelContainer() {
+        rIdBlr = initializeResourceId(context);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "top", NAME_SPACE, value);
+        return rIdBlr;
+    }
+
+    private ResourceId.Builder buildRIdForTopLevelLeaf() {
+        rIdBlr = initializeResourceId(context);
+        value = "null";
+        rIdBlr = addToResourceId(rIdBlr, "leaf5", NAME_SPACE, value);
+        return rIdBlr;
+    }
+
+    private ResourceId.Builder buildRIdForTopLevelLeafList() {
+        rIdBlr = initializeResourceId(context);
+        value = "abc";
+        rIdBlr = addToResourceId(rIdBlr, "leaf6", NAME_SPACE, value);
+        return rIdBlr;
+    }
+
+    private ResourceId.Builder buildRIdForTopLevelList() {
+        rIdBlr = initializeResourceId(context);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "l2", NAME_SPACE, value);
+        value = "abc";
+        rIdBlr = addToResourceId(rIdBlr, "k1", NAME_SPACE, value);
+        return rIdBlr;
+    }
+
+    private ResourceId.Builder buildRIdForGroupingUses() {
+        rIdBlr = initializeResourceId(context);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "networks", NW_NS, value);
+        rIdBlr = addToResourceId(rIdBlr, "network", NW_NS, value);
+        value = "network-id";
+        rIdBlr = addToResourceId(rIdBlr, "network-id", NW_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "te", TE_TOPO_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "config", TE_TOPO_NS, value);
+        return rIdBlr;
+    }
+
+    private ResourceId.Builder buildRIdForNodeInsideChoiceCase() {
+        rIdBlr = initializeResourceId(context);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "networks", NW_NS, value);
+        rIdBlr = addToResourceId(rIdBlr, "network", NW_NS, value);
+        value = "network-id";
+        rIdBlr = addToResourceId(rIdBlr, "network-id", NW_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "link", NW_TOPO_NS, value);
+        value = "link-id";
+        rIdBlr = addToResourceId(rIdBlr, "link-id", NW_TOPO_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "te", TE_TOPO_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "config", TE_TOPO_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "bundled-links", TE_TOPO_NS, value);
+        return rIdBlr;
+    }
+
+    private ResourceId.Builder buildRIdForTopListInsideList() {
+        rIdBlr = initializeResourceId(context);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "networks", NW_NS, value);
+        rIdBlr = addToResourceId(rIdBlr, "network", NW_NS, value);
+        value = "network-id";
+        rIdBlr = addToResourceId(rIdBlr, "network-id", NW_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "link", NW_TOPO_NS, value);
+        value = "link-id";
+        rIdBlr = addToResourceId(rIdBlr, "link-id", NW_TOPO_NS, value);
+        value = null;
+        rIdBlr = addToResourceId(rIdBlr, "source", NW_TOPO_NS, value);
+        return rIdBlr;
+    }
+
+    @Test
+    public void testTopLevelContainer() {
+        ResourceId id = buildRIdForTopLevelContainer().build();
+        ResourceData data = DefaultResourceData.builder()
+                .resourceId(id).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        ModelObjectId mId = modelObjectData.identifier();
+        List<AtomicPath> atomicPaths = mId.atomicPaths();
+        SingleInstanceNode l1 = (SingleInstanceNode) atomicPaths.get(0);
+        assertThat(l1.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(l1.container(), (DefaultTop.class));
+    }
+
+    @Test
+    public void testTopLevelLeaf() {
+        ResourceId id = buildRIdForTopLevelLeaf().build();
+        ResourceData data = DefaultResourceData.builder()
+                .resourceId(id).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        ModelObjectId mId = modelObjectData.identifier();
+        List<AtomicPath> atomicPaths = mId.atomicPaths();
+        SingleInstanceLeaf leaf5 = (SingleInstanceLeaf) atomicPaths.get(0);
+        assertThat(leaf5.type(), is(DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE));
+        assertEquals(leaf5.leafIdentifier(), Sample.LeafIdentifier.LEAF5);
+    }
+
+    @Test
+    public void testTopLevelLeafList() {
+        ResourceId id = buildRIdForTopLevelLeafList().build();
+        ResourceData data = DefaultResourceData.builder()
+                .resourceId(id).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        ModelObjectId mId = modelObjectData.identifier();
+        List<AtomicPath> atomicPaths = mId.atomicPaths();
+        MultiInstanceLeaf leaf6 = (MultiInstanceLeaf) atomicPaths.get(0);
+        assertThat(leaf6.type(), is(DataNode.Type.MULTI_INSTANCE_LEAF_VALUE_NODE));
+        assertEquals(leaf6.leafIdentifier(), Sample.LeafIdentifier.LEAF6);
+    }
+
+    @Test
+    public void testTopLevelList() {
+        ResourceId id = buildRIdForTopLevelList().build();
+        ResourceData data = DefaultResourceData.builder()
+                .resourceId(id).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        ModelObjectId mId = modelObjectData.identifier();
+        List<AtomicPath> atomicPaths = mId.atomicPaths();
+        MultiInstanceNode l2 = (MultiInstanceNode) atomicPaths.get(0);
+        assertThat(l2.type(), is(DataNode.Type.MULTI_INSTANCE_NODE));
+        assertEquals(l2.listClass(), DefaultL2.class);
+        assertThat(((L2Keys) l2.key()).k1(), is("abc"));
+    }
+
+    @Test
+    public void testMoIdForListInsideList() {
+        ResourceId id = buildRIdForTopListInsideList().build();
+        ResourceData data = DefaultResourceData.builder()
+                .resourceId(id).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        ModelObjectId mId = modelObjectData.identifier();
+        List<AtomicPath> atomicPaths = mId.atomicPaths();
+        SingleInstanceNode network = (SingleInstanceNode) atomicPaths.get(0);
+        assertThat(network.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(network.container(), DefaultNetworks.class);
+        MultiInstanceNode networks = (MultiInstanceNode) atomicPaths.get(1);
+        assertThat(networks.type(), is(DataNode.Type.MULTI_INSTANCE_NODE));
+        assertEquals(networks.listClass(), DefaultNetwork.class);
+        MultiInstanceNode lId = (MultiInstanceNode) atomicPaths.get(2);
+        assertThat(lId.type(), is(DataNode.Type.MULTI_INSTANCE_NODE));
+        assertEquals(lId.listClass(), DefaultLink.class);
+        SingleInstanceNode src = (SingleInstanceNode) atomicPaths.get(3);
+        assertThat(src.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(src.container(), DefaultSource.class);
+    }
+
+    @Test
+    public void testMoIdForGroupingUses() {
+        ResourceId id = buildRIdForGroupingUses().build();
+        ResourceData data = DefaultResourceData.builder()
+                .resourceId(id).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        ModelObjectId mId = modelObjectData.identifier();
+        List<AtomicPath> atomicPaths = mId.atomicPaths();
+        SingleInstanceNode network = (SingleInstanceNode) atomicPaths.get(0);
+        assertThat(network.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(network.container(), DefaultNetworks.class);
+        MultiInstanceNode networks = (MultiInstanceNode) atomicPaths.get(1);
+        assertThat(networks.type(), is(DataNode.Type.MULTI_INSTANCE_NODE));
+        assertEquals(networks.listClass(), DefaultNetwork.class);
+        SingleInstanceNode te = (SingleInstanceNode) atomicPaths.get(2);
+        assertThat(te.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(te.container(), DefaultTe.class);
+        SingleInstanceNode config = (SingleInstanceNode) atomicPaths.get(3);
+        assertThat(config.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(config.container(), DefaultConfig.class);
+    }
+
+    @Test
+    public void testMoIdForNodeInsideChoiceCase() {
+        ResourceId id = buildRIdForNodeInsideChoiceCase().build();
+        ResourceData data = DefaultResourceData.builder()
+                .resourceId(id).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        ModelObjectId mId = modelObjectData.identifier();
+        List<AtomicPath> atomicPaths = mId.atomicPaths();
+        SingleInstanceNode network = (SingleInstanceNode) atomicPaths.get(0);
+        assertThat(network.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(network.container(), DefaultNetworks.class);
+        MultiInstanceNode networks = (MultiInstanceNode) atomicPaths.get(1);
+        assertThat(networks.type(), is(DataNode.Type.MULTI_INSTANCE_NODE));
+        assertEquals(networks.listClass(), DefaultNetwork.class);
+        MultiInstanceNode link = (MultiInstanceNode) atomicPaths.get(2);
+        assertThat(link.type(), is(DataNode.Type.MULTI_INSTANCE_NODE));
+        assertEquals(link.listClass(), DefaultLink.class);
+        SingleInstanceNode te = (SingleInstanceNode) atomicPaths.get(3);
+        assertThat(te.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(te.container(), org.onosproject.yang.gen.v1.urn.ietf
+                .params.xml.ns.yang.yrt.ietf.te.topology.rev20160317
+                .yrtietftetopology.telinkaugment.DefaultTe.class);
+        SingleInstanceNode config = (SingleInstanceNode) atomicPaths.get(4);
+        assertThat(config.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(config.container(), org.onosproject.yang.gen.v1.urn.ietf
+                .params.xml.ns.yang.yrt.ietf.te.topology.rev20160317
+                .yrtietftetopology.telinkaugment.te.DefaultConfig.class);
+        SingleInstanceNode bundledlinks = (SingleInstanceNode) atomicPaths
+                .get(5);
+        assertThat(bundledlinks.type(), is(DataNode.Type.SINGLE_INSTANCE_NODE));
+        assertEquals(bundledlinks.container(), DefaultBundledLinks.class);
+    }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobSimpleDataTypeTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobSimpleDataTypeTest.java
new file mode 100644
index 0000000..3c2ba15
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobSimpleDataTypeTest.java
@@ -0,0 +1,534 @@
+/*
+ * 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;
+
+import org.junit.Test;
+import org.onosproject.yang.gen.v1.simple.data.types.ll.rev20131112.simpledatatypesll.DefaultCont1;
+import org.onosproject.yang.gen.v1.simple.data.types.rev20131112.simpledatatypes.DefaultCont;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.runtime.DefaultResourceData;
+
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+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.initializeDataNode;
+
+/**
+ * Tests the YANG object building for different data types.
+ */
+public class YobSimpleDataTypeTest {
+
+    TestYangSerializerContext context = new TestYangSerializerContext();
+    private static final String DATA_TYPE_NAME_SPACE = "simple:data:types";
+    private static final String DATA_TYPE_NAME_SPACE_LL =
+            "simple:data:types:ll";
+    private DataNode.Builder dBlr;
+    private String value;
+
+    public DataNode buildDataNodeForSimpleDataTypes() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "cont", DATA_TYPE_NAME_SPACE, value, null);
+
+        value = "-128";
+        dBlr = addDataNode(dBlr, "lfnint8Min", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "127";
+        dBlr = addDataNode(dBlr, "lfnint8Max", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-32768";
+        dBlr = addDataNode(dBlr, "lfnint16Min", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "32767";
+        dBlr = addDataNode(dBlr, "lfnint16Max", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-2147483648";
+        dBlr = addDataNode(dBlr, "lfnint32Min", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "2147483647";
+        dBlr = addDataNode(dBlr, "lfnint32Max", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "10090";
+        dBlr = addDataNode(dBlr, "lfnint64Min", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "100700";
+        dBlr = addDataNode(dBlr, "lfnint64Max", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "32767";
+        dBlr = addDataNode(dBlr, "lfnuint8Max", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "2147483647";
+        dBlr = addDataNode(dBlr, "lfnuint16Max", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "10000";
+        dBlr = addDataNode(dBlr, "lfnuint32Max", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "32656256558";
+        dBlr = addDataNode(dBlr, "lfuint64Max", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "string1";
+        dBlr = addDataNode(dBlr, "lfstr", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "string2";
+        dBlr = addDataNode(dBlr, "lfstr1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "true";
+        dBlr = addDataNode(dBlr, "lfbool1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "false";
+        dBlr = addDataNode(dBlr, "lfbool2", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "false";
+        dBlr = addDataNode(dBlr, "lfbool3", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-922337203685477580.8";
+        dBlr = addDataNode(dBlr, "lfdecimal1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-92233720368547758.08";
+        dBlr = addDataNode(dBlr, "lfdecimal2", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-9223372036854775.808";
+        dBlr = addDataNode(dBlr, "lfdecimal3", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-922337203685477.5808";
+        dBlr = addDataNode(dBlr, "lfdecimal4", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-9223372036854.775808";
+        dBlr = addDataNode(dBlr, "lfdecimal6", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "enum1";
+        dBlr = addDataNode(dBlr, "lfenum", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "bit1";
+        dBlr = addDataNode(dBlr, "lfbits", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "aGV5";
+        dBlr = addDataNode(dBlr, "lfbinary", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "path";
+        dBlr = addDataNode(dBlr, "lfref1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "100";
+        dBlr = addDataNode(dBlr, "lfref2", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "";
+        dBlr = addDataNode(dBlr, "lfempty", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "cost";
+        dBlr = addDataNode(dBlr, "lfunion1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-92233720368547758.08";
+        dBlr = addDataNode(dBlr, "lfunion2", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "true";
+        dBlr = addDataNode(dBlr, "lfunion4", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "color";
+        dBlr = addDataNode(dBlr, "lfunion5", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b1";
+        dBlr = addDataNode(dBlr, "lfunion7", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "bandwidth";
+        dBlr = addDataNode(dBlr, "lfunion8", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "200";
+        dBlr = addDataNode(dBlr, "lfunion9", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "true";
+        dBlr = addDataNode(dBlr, "lfunion10", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b1";
+        dBlr = addDataNode(dBlr, "lfunion11", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "true";
+        dBlr = addDataNode(dBlr, "lfunion12", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b2";
+        dBlr = addDataNode(dBlr, "lfunion13", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "one";
+        dBlr = addDataNode(dBlr, "lfunion14", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "iden";
+        dBlr = addDataNode(dBlr, "identityref1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+        dBlr = exitDataNode(dBlr);
+        return dBlr.build();
+    }
+
+
+    public DataNode buildDnForLeafListSimpleDataTypes() {
+        dBlr = initializeDataNode(context);
+        value = null;
+        dBlr = addDataNode(dBlr, "cont1", DATA_TYPE_NAME_SPACE_LL, value, null);
+
+        value = "-128";
+        dBlr = addDataNode(dBlr, "lfnint8Min", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "127";
+        dBlr = addDataNode(dBlr, "lfnint8Max", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-32768";
+        dBlr = addDataNode(dBlr, "lfnint16Min", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "32767";
+        dBlr = addDataNode(dBlr, "lfnint16Max", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-2147483648";
+        dBlr = addDataNode(dBlr, "lfnint32Min", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "2147483647";
+        dBlr = addDataNode(dBlr, "lfnint32Max", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "10090";
+        dBlr = addDataNode(dBlr, "lfnint64Min", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "100700";
+        dBlr = addDataNode(dBlr, "lfnint64Max", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "32767";
+        dBlr = addDataNode(dBlr, "lfnuint8Max", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "2147483647";
+        dBlr = addDataNode(dBlr, "lfnuint16Max", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "10000";
+        dBlr = addDataNode(dBlr, "lfnuint32Max", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "32656256558";
+        dBlr = addDataNode(dBlr, "lfuint64Max", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "string1";
+        dBlr = addDataNode(dBlr, "lfstr", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "string2";
+        dBlr = addDataNode(dBlr, "lfstr1", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "true";
+        dBlr = addDataNode(dBlr, "lfbool1", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "false";
+        dBlr = addDataNode(dBlr, "lfbool2", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "false";
+        dBlr = addDataNode(dBlr, "lfbool3", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-922337203685477580.8";
+        dBlr = addDataNode(dBlr, "lfdecimal1", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-92233720368547758.08";
+        dBlr = addDataNode(dBlr, "lfdecimal2", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-9223372036854775.808";
+        dBlr = addDataNode(dBlr, "lfdecimal3", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-922337203685477.5808";
+        dBlr = addDataNode(dBlr, "lfdecimal4", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-9223372036854.775808";
+        dBlr = addDataNode(dBlr, "lfdecimal6", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "enum1";
+        dBlr = addDataNode(dBlr, "lfenum", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "bit1";
+        dBlr = addDataNode(dBlr, "lfbits", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "aGVsbG8=";
+        dBlr = addDataNode(dBlr, "lfbinary", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "path";
+        dBlr = addDataNode(dBlr, "lfref1", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "100";
+        dBlr = addDataNode(dBlr, "lfref2", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "";
+        dBlr = addDataNode(dBlr, "lfempty", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "cost";
+        dBlr = addDataNode(dBlr, "lfunion1", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-92233720368547758.08";
+        dBlr = addDataNode(dBlr, "lfunion2", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "true";
+        dBlr = addDataNode(dBlr, "lfunion4", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "color";
+        dBlr = addDataNode(dBlr, "lfunion5", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b1";
+        dBlr = addDataNode(dBlr, "lfunion7", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "bandwidth";
+        dBlr = addDataNode(dBlr, "lfunion8", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "200";
+        dBlr = addDataNode(dBlr, "lfunion9", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "true";
+        dBlr = addDataNode(dBlr, "lfunion10", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b1";
+        dBlr = addDataNode(dBlr, "lfunion11", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "true";
+        dBlr = addDataNode(dBlr, "lfunion12", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b2";
+        dBlr = addDataNode(dBlr, "lfunion13", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "one";
+        dBlr = addDataNode(dBlr, "lfunion14", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "iden";
+        dBlr = addDataNode(dBlr, "identityref1", null, value, null);
+        dBlr = exitDataNode(dBlr);
+        dBlr = exitDataNode(dBlr);
+        return dBlr.build();
+    }
+
+    @Test
+    public void allDataTypesTest() {
+        DataNode dataNode = buildDataNodeForSimpleDataTypes();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        DefaultCont cont = ((DefaultCont) modelObject);
+        byte value = -128;
+        assertThat(cont.lfnint8Min(), is(value));
+
+        value = 127;
+        assertThat(cont.lfnint8Max(), is(value));
+
+        short val = -32768;
+        assertThat(cont.lfnint16Min(), is(val));
+
+        val = 32767;
+        assertThat(cont.lfnint16Max(), is(val));
+
+        assertThat(cont.lfnint32Min(), is(-2147483648));
+        assertThat(cont.lfnint32Max(), is(2147483647));
+        assertThat(cont.lfnint64Min(), is(10090L));
+        assertThat(cont.lfnint64Max(), is(100700L));
+
+        val = 32767;
+        assertThat(cont.lfnuint8Max(), is(val));
+        assertThat(cont.lfnuint16Max(), is(2147483647));
+        assertThat(cont.lfnuint32Max(), is(10000L));
+        assertThat(cont.lfuint64Max().toString(), is("32656256558"));
+        assertThat(cont.lfstr(), is("string1"));
+        assertThat(cont.lfstr1(), is("string2"));
+        assertThat(cont.lfbool1(), is(true));
+        assertThat(cont.lfbool2(), is(false));
+        assertThat(cont.lfbool3(), is(false));
+        assertThat(cont.lfdecimal1().toString(),
+                   is("-922337203685477580.8"));
+        assertThat(cont.lfdecimal2().toString(),
+                   is("-92233720368547758.08"));
+        assertThat(cont.lfdecimal3().toString(),
+                   is("-9223372036854775.808"));
+        assertThat(cont.lfdecimal4().toString(),
+                   is("-922337203685477.5808"));
+        assertThat(cont.lfdecimal6().toString(),
+                   is("-9223372036854.775808"));
+        assertThat(cont.lfenum().toString(), is("enum1"));
+        assertThat(cont.lfbits().toString(), is("{0}"));
+        String str = new String(cont.lfbinary());
+        assertThat(str, is("hey"));
+        assertThat(cont.lfref1(), is("path"));
+        value = 100;
+        assertThat(cont.lfref2(), is(value));
+        assertThat(cont.lfempty(), is(true));
+        assertThat(cont.lfunion1().toString(), is("cost"));
+        assertThat(cont.lfunion2().toString(), is("-92233720368547758.08"));
+        assertThat(cont.lfunion4().toString(), is("true"));
+        assertThat(cont.lfunion5().toString(), is("color"));
+        assertThat(cont.lfunion7().toString(), is("b1 "));
+        assertThat(cont.lfunion8().toString(), is("bandwidth"));
+        assertThat(cont.lfunion9().toString(), is("200"));
+        assertThat(cont.lfunion10().toString(), is("true"));
+        assertThat(cont.lfunion11().toString(), is("b1 "));
+        assertThat(cont.lfunion12().toString(), is("true"));
+        assertThat(cont.lfunion13().toString(), is("b2 "));
+        assertThat(cont.lfunion14().toString(), is("one"));
+        assertThat(cont.identityref1().getSimpleName(), is("Iden"));
+    }
+
+
+    @Test
+    public void allDataTypesTestForLeafList() {
+        DataNode dataNode = buildDnForLeafListSimpleDataTypes();
+        ResourceData data = DefaultResourceData.builder().addDataNode(dataNode).build();
+        DefaultYobBuilder builder = new DefaultYobBuilder(
+                (DefaultYangModelRegistry) context.getContext());
+        ModelObjectData modelObjectData = builder.getYangObject(data);
+        List<ModelObject> modelObjectList = modelObjectData.modelObjects();
+        ModelObject modelObject = modelObjectList.get(0);
+        DefaultCont1 cont = ((DefaultCont1) modelObject);
+        byte value = -128;
+        assertThat(cont.lfnint8Min().get(0), is(value));
+
+        value = 127;
+        assertThat(cont.lfnint8Max().get(0), is(value));
+
+        short val = -32768;
+        assertThat(cont.lfnint16Min().get(0), is(val));
+
+        val = 32767;
+        assertThat(cont.lfnint16Max().get(0), is(val));
+
+        assertThat(cont.lfnint32Min().get(0), is(-2147483648));
+        assertThat(cont.lfnint32Max().get(0), is(2147483647));
+        assertThat(cont.lfnint64Min().get(0), is(10090L));
+        assertThat(cont.lfnint64Max().get(0), is(100700L));
+
+        val = 32767;
+        assertThat(cont.lfnuint8Max().get(0), is(val));
+        assertThat(cont.lfnuint16Max().get(0), is(2147483647));
+        assertThat(cont.lfnuint32Max().get(0), is(10000L));
+        assertThat(cont.lfuint64Max().get(0).toString(), is("32656256558"));
+        assertThat(cont.lfstr().get(0), is("string1"));
+        assertThat(cont.lfstr1().get(0), is("string2"));
+        assertThat(cont.lfbool1().get(0), is(true));
+        assertThat(cont.lfbool2().get(0), is(false));
+        assertThat(cont.lfbool3().get(0), is(false));
+        assertThat(cont.lfdecimal1().get(0).toString(),
+                   is("-922337203685477580.8"));
+        assertThat(cont.lfdecimal2().get(0).toString(),
+                   is("-92233720368547758.08"));
+        assertThat(cont.lfdecimal3().get(0).toString(),
+                   is("-9223372036854775.808"));
+        assertThat(cont.lfdecimal4().get(0).toString(),
+                   is("-922337203685477.5808"));
+        assertThat(cont.lfdecimal6().get(0).toString(),
+                   is("-9223372036854.775808"));
+        assertThat(cont.lfenum().get(0).toString(), is("enum1"));
+        assertThat(cont.lfbits().get(0).toString(), is("{0}"));
+        String str = new String(cont.lfbinary().get(0));
+        assertThat(str, is("hello"));
+        assertThat(cont.lfref1().get(0), is("path"));
+        value = 100;
+        assertThat(cont.lfref2().get(0), is(value));
+        assertThat(cont.lfempty().get(0), is(true));
+        assertThat(cont.lfunion1().get(0).toString(), is("cost"));
+        assertThat(cont.lfunion2().get(0).toString(), is("-92233720368547758.08"));
+        assertThat(cont.lfunion4().get(0).toString(), is("true"));
+        assertThat(cont.lfunion5().get(0).toString(), is("color"));
+        assertThat(cont.lfunion7().get(0).toString(), is("b1 "));
+        assertThat(cont.lfunion8().get(0).toString(), is("bandwidth"));
+        assertThat(cont.lfunion9().get(0).toString(), is("200"));
+        assertThat(cont.lfunion10().get(0).toString(), is("true"));
+        assertThat(cont.lfunion11().get(0).toString(), is("b1 "));
+        assertThat(cont.lfunion12().get(0).toString(), is("true"));
+        assertThat(cont.lfunion13().get(0).toString(), is("b2 "));
+        assertThat(cont.lfunion14().get(0).toString(), is("one"));
+        assertThat(cont.identityref1().get(0).getSimpleName().toString(),
+                   is("Iden"));
+    }
+}
diff --git a/runtime/src/test/resources/yobTestYangFiles/SampleTest.yang b/runtime/src/test/resources/yobTestYangFiles/SampleTest.yang
new file mode 100644
index 0000000..c59ed74
--- /dev/null
+++ b/runtime/src/test/resources/yobTestYangFiles/SampleTest.yang
@@ -0,0 +1,53 @@
+module sample {
+    yang-version 1;
+    namespace "samplenamespace";
+    prefix "attr";
+    container top {
+        leaf mtu {
+           type string;
+        }
+        leaf-list color {
+           type string;
+        }
+        list interface {
+            key name;
+            leaf name {
+                type string;
+            }
+            container address {
+                leaf name {
+                    type string;
+                }
+            }
+        }
+    }
+    list l1 {
+        config false;
+        container c1 {
+            leaf leaf1 {
+               type string;
+            }
+            leaf-list leaf2 {
+               type string;
+            }
+        }
+        leaf leaf3 {
+            type string;
+        }
+        leaf-list leaf4 {
+            type string;
+        }
+    }
+    list l2 {
+        key k1;
+        leaf k1 {
+            type string;
+        }
+    }
+    leaf leaf5 {
+        type string;
+    }
+    leaf-list leaf6 {
+        type string;
+    }
+}
\ No newline at end of file
diff --git a/runtime/src/test/resources/yobTestYangFiles/ip-topology.yang b/runtime/src/test/resources/yobTestYangFiles/ip-topology.yang
new file mode 100644
index 0000000..cb56c41
--- /dev/null
+++ b/runtime/src/test/resources/yobTestYangFiles/ip-topology.yang
@@ -0,0 +1,28 @@
+module yms-ip-topology {
+    yang-version 1;
+    namespace urn:ip:topo;
+    prefix ip-topo;
+    import yms-topology {
+       prefix topo;
+       revision-date "2014-01-01";
+    }
+    revision 2014-01-01 {
+        description "desc";
+        reference "ref";
+    }
+
+    augment /topo:node{
+        leaf router-id {
+            type string;
+        }
+        leaf router-ip {
+            type string;
+        }
+    }
+
+    augment /topo:node/topo:termination-points/topo:termination-point {
+        leaf ip-address {
+            type string;
+        }
+    }
+}
diff --git a/runtime/src/test/resources/yobTestYangFiles/leafreftest.yang b/runtime/src/test/resources/yobTestYangFiles/leafreftest.yang
new file mode 100644
index 0000000..0905c86
--- /dev/null
+++ b/runtime/src/test/resources/yobTestYangFiles/leafreftest.yang
@@ -0,0 +1,71 @@
+module leafreftest {
+
+    yang-version 1;
+
+    namespace "yob.leafreftest";
+
+    prefix "uniontest";
+
+    organization "ON-LAB";
+
+    description "This module defines for union classifier.";
+
+    revision "2016-05-24" {
+        description "Initial revision.";
+    }
+
+    leaf middlename  {
+        type string;
+    }
+
+    list leafrefList {
+        config false;
+        leaf id {
+            type leafref {
+                path "/middlename";
+            }
+        }
+    }
+
+    typedef percent {
+        type leafref {
+            path "/middlename";
+        }
+    }
+
+    leaf name {
+        type percent;
+    }
+
+    grouping greeting {
+        leaf surname {
+            type leafref {
+                path "/middlename";
+            }
+        }
+    }
+
+    container cont1 {
+        uses greeting;
+    }
+
+    augment "/cont1" {
+        leaf lastname {
+            type leafref {
+                path "/middlename";
+            }
+        }
+    }
+
+    container food {
+        choice snack {
+            case sportsarena {
+                leaf pretzel {
+                    type leafref {
+                        path "/middlename";
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/runtime/src/test/resources/yobTestYangFiles/simple-data-types-leaf-list.yang b/runtime/src/test/resources/yobTestYangFiles/simple-data-types-leaf-list.yang
new file mode 100644
index 0000000..401cdaa
--- /dev/null
+++ b/runtime/src/test/resources/yobTestYangFiles/simple-data-types-leaf-list.yang
@@ -0,0 +1,256 @@
+module simple-data-types-ll {
+  namespace "simple:data:types:ll";
+
+  prefix "smpdtp";
+  revision 2013-11-12 {
+  }
+
+  identity iden {
+  }
+
+  typedef tpdfempty {
+    type empty;
+  }
+
+  typedef tpdfbit {
+     type bits {
+        bit b1;
+        bit b2;
+        bit b3;
+    }
+  }
+
+  typedef tpdfun4 {
+    type boolean;
+  }
+
+  typedef tpdfun3 {
+    type union {
+        type tpdfbit;
+        type tpdfempty;
+    }
+  }
+
+  typedef tpdfun2 {
+    type union {
+        type tpdfun3;
+        type tpdfun4;
+    }
+  }
+
+  typedef tpdfun1 {
+    type union {
+        type uint8;
+        type decimal64 {
+            fraction-digits 2;
+        }
+    }
+  }
+
+  container cont1 {
+     leaf-list lfnint8Min {
+        type int8;
+      }
+      leaf-list lfnint8Max {
+        type int8;
+      }
+      leaf-list lfnint16Min {
+        type int16;
+      }
+      leaf-list lfnint16Max {
+        type int16;
+      }
+      leaf-list lfnint32Min {
+        type int32;
+      }
+      leaf-list lfnint32Max {
+        type int32;
+      }
+      leaf-list lfnint64Min {
+        type int64;
+      }
+      leaf-list lfnint64Max {
+        type int64;
+      }
+      leaf-list lfnuint8Max {
+        type uint8;
+      }
+      leaf-list lfnuint16Max {
+        type uint16;
+      }
+      leaf-list lfnuint32Max {
+        type uint32;
+      }
+      leaf-list lfuint64Max {
+        type uint64;
+      }
+      leaf-list lfstr {
+        type string;
+      }
+      leaf-list lfstr1 {
+        type string;
+      }
+      leaf-list lfbool1 {
+        type boolean;
+      }
+      leaf-list lfbool2 {
+        type boolean;
+      }
+      leaf-list lfbool3 {
+        type boolean;
+      }
+      leaf-list lfdecimal1 {
+        type decimal64 {
+            fraction-digits 1;
+        }
+      }
+      leaf-list lfdecimal2 {
+        type decimal64 {
+            fraction-digits 2;
+        }
+      }
+      leaf-list lfdecimal3 {
+        type decimal64 {
+            fraction-digits 3;
+        }
+      }
+
+      leaf-list lfdecimal4 {
+        type decimal64 {
+            fraction-digits 4;
+        }
+      }
+
+      leaf-list lfdecimal6 {
+        type decimal64 {
+            fraction-digits 6;
+        }
+      }
+
+    leaf-list lfenum {
+      type enumeration {
+        enum enum1;
+        enum enum2;
+        enum enum3;
+        enum enum4;
+      }
+    }
+
+    leaf-list lfbits {
+      type bits {
+        bit bit1;
+        bit bit2;
+        bit bit3;
+        bit bit4;
+      }
+    }
+
+    leaf-list lfbinary {
+        type binary;
+    }  
+
+    leaf-list lfref1 {                  //reference to string type
+        type leafref {
+            path "../lfstr";
+        }
+    }
+
+    leaf-list lfref2 {                  //reference to number type
+        type leafref {
+            path "../lfnint8Max";
+        }
+    }
+
+    leaf-list lfempty {
+        type empty;
+    }
+
+    leaf-list lfunion1 {
+        type union {
+            type uint16;
+            type string;
+        }
+    }
+    leaf-list lfunion2 {
+        type union {
+            type decimal64 {
+                fraction-digits 2;
+            }
+            type string;
+        }
+    }
+
+    leaf-list lfunion4 {
+        type union {
+            type boolean;
+            type string;
+        }
+    }
+
+    leaf-list lfunion5 {
+        type union {
+            type uint16;
+            type string;
+        }
+    }
+
+    leaf-list lfunion7 {
+        type tpdfun3;
+    }
+
+    leaf-list lfunion8 {
+        type union {
+            type uint16;
+            type string;
+        }
+    }
+
+    leaf-list lfunion9 {
+        type union {
+            type uint16;
+            type boolean;
+        }
+    }
+
+    leaf-list lfunion10 {
+        type union {
+            type bits {
+                bit bt1;
+                bit bt2;
+            }
+            type boolean;
+        }
+    }
+
+    leaf-list lfunion11 {
+        type union {
+            type tpdfun1;
+            type tpdfun2;
+        }
+    }
+
+    leaf-list lfunion12 {
+        type tpdfun2;
+    }
+
+    leaf-list lfunion13 {
+        type tpdfbit;    
+    }
+
+    leaf-list lfunion14 {
+        type union {
+            type enumeration {
+                enum zero;
+                enum one;
+            }
+            type uint16;
+        }
+    }
+
+    leaf-list identityref1 {
+        type identityref {
+            base iden;
+        }
+    }
+  }
+}
diff --git a/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang b/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang
new file mode 100644
index 0000000..602c37b
--- /dev/null
+++ b/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang
@@ -0,0 +1,256 @@
+module simple-data-types {
+  namespace "simple:data:types";  
+
+  prefix "smpdtp";
+  revision 2013-11-12 {
+  }
+
+  identity iden {
+  }
+
+  typedef tpdfempty {
+    type empty;
+  }
+
+  typedef tpdfbit {
+     type bits {
+        bit b1;
+        bit b2;
+        bit b3;
+    }
+  }
+
+  typedef tpdfun4 {
+    type boolean;
+  }
+
+  typedef tpdfun3 {
+    type union {
+        type tpdfbit;
+        type tpdfempty;
+    }
+  }
+
+  typedef tpdfun2 {
+    type union {
+        type tpdfun3;
+        type tpdfun4;
+    }
+  }
+
+  typedef tpdfun1 {
+    type union {
+        type uint8;
+        type decimal64 {
+            fraction-digits 2;
+        }
+    }
+  }
+
+  container cont {
+     leaf lfnint8Min {
+        type int8;
+      }
+      leaf lfnint8Max {
+        type int8;
+      }
+      leaf lfnint16Min {
+        type int16;
+      }
+      leaf lfnint16Max {
+        type int16;
+      }
+      leaf lfnint32Min {
+        type int32;
+      }
+      leaf lfnint32Max {
+        type int32;
+      }
+      leaf lfnint64Min {
+        type int64;
+      }
+      leaf lfnint64Max {
+        type int64;
+      }
+      leaf lfnuint8Max {
+        type uint8;
+      }
+      leaf lfnuint16Max {
+        type uint16;
+      }
+      leaf lfnuint32Max {
+        type uint32;
+      }
+      leaf lfuint64Max {
+        type uint64;
+      }
+      leaf lfstr {
+        type string;
+      }
+      leaf lfstr1 {
+        type string;
+      }
+      leaf lfbool1 {
+        type boolean;
+      }
+      leaf lfbool2 {
+        type boolean;
+      }
+      leaf lfbool3 {
+        type boolean;
+      }
+      leaf lfdecimal1 {
+        type decimal64 {
+            fraction-digits 1;
+        }
+      }
+      leaf lfdecimal2 {
+        type decimal64 {
+            fraction-digits 2;
+        }
+      }
+      leaf lfdecimal3 {
+        type decimal64 {
+            fraction-digits 3;
+        }
+      }
+
+      leaf lfdecimal4 {
+        type decimal64 {
+            fraction-digits 4;
+        }
+      }
+
+      leaf lfdecimal6 {
+        type decimal64 {
+            fraction-digits 6;
+        }
+      }
+
+    leaf lfenum {
+      type enumeration {
+        enum enum1;
+        enum enum2;
+        enum enum3;
+        enum enum4;
+      }
+    }
+
+    leaf lfbits {
+      type bits {
+        bit bit1;
+        bit bit2;
+        bit bit3;
+        bit bit4;
+      }
+    }
+
+    leaf lfbinary {
+        type binary;
+    }  
+
+    leaf lfref1 {                  //reference to string type
+        type leafref {
+            path "../lfstr";
+        }
+    }
+
+    leaf lfref2 {                  //reference to number type
+        type leafref {
+            path "../lfnint8Max";
+        }
+    }
+
+    leaf lfempty {
+        type empty;
+    }
+
+    leaf lfunion1 {
+        type union {
+            type uint16;
+            type string;
+        }
+    }
+    leaf lfunion2 {
+        type union {
+            type decimal64 {
+                fraction-digits 2;
+            }
+            type string;
+        }
+    }
+
+    leaf lfunion4 {
+        type union {
+            type boolean;
+            type string;
+        }
+    }
+
+    leaf lfunion5 {
+        type union {
+            type uint16;
+            type string;
+        }
+    }
+
+    leaf lfunion7 {
+        type tpdfun3;
+    }
+
+    leaf lfunion8 {
+        type union {
+            type uint16;
+            type string;
+        }
+    }
+
+    leaf lfunion9 {
+        type union {
+            type uint16;
+            type boolean;
+        }
+    }
+
+    leaf lfunion10 {
+        type union {
+            type bits {
+                bit bt1;
+                bit bt2;
+            }
+            type boolean;
+        }
+    }
+
+    leaf lfunion11 {
+        type union {
+            type tpdfun1;
+            type tpdfun2;
+        }
+    }
+
+    leaf lfunion12 {
+        type tpdfun2;
+    }
+
+    leaf lfunion13 {
+        type tpdfbit;    
+    }
+
+    leaf lfunion14 {
+        type union {
+            type enumeration {
+                enum zero;
+                enum one;
+            }
+            type uint16;
+        }
+    }
+
+    leaf identityref1 {
+        type identityref {
+            base iden;
+        }
+    }
+  }
+}
diff --git a/runtime/src/test/resources/yobTestYangFiles/topology.yang b/runtime/src/test/resources/yobTestYangFiles/topology.yang
new file mode 100644
index 0000000..9837851
--- /dev/null
+++ b/runtime/src/test/resources/yobTestYangFiles/topology.yang
@@ -0,0 +1,90 @@
+
+module yms-topology {
+    yang-version 1;
+    namespace urn:topo;
+    prefix topo;
+    revision 2014-01-01 {
+        description "desc";
+        reference "ref";
+    }
+    list node {
+        key "node-id";
+        leaf node-id{
+           type string;
+        }
+        leaf-list node-prop{
+           type string;
+        }
+        container termination-points{
+            leaf number-of-tp {
+                type int16;
+            }
+            list termination-point {
+                key "tp-id";
+                leaf tp-id {
+                    type string;
+                }
+            }
+        }
+        choice choice1{
+           case case1a{
+               leaf leaf1a1{
+                   type string;
+               }
+               leaf leaf1a2{
+                   type string;
+               }
+           }
+           case case1b{
+               choice choice1b{
+                   case case1bi{
+                       leaf leaf1bia{
+                           type string;
+                       }
+                       leaf leaf1bib{
+                           type string;
+                       }
+                   }
+                   case case1bii{
+                       leaf leaf1biia{
+                           type string;
+                       }
+                       leaf leaf1biib{
+                           type string;
+                       }
+                   }
+               }
+           }
+        }
+    }
+    choice choice2 {
+        case case2a {
+            leaf leaf2a1 {
+                type string;
+            }
+            leaf leaf2a2 {
+                type string;
+            }
+        }
+        case case2b {
+            choice choice3b {
+                case case2bi {
+                    leaf leaf2bia {
+                       type string;
+                    }
+                    leaf leaf2bib {
+                       type string;
+                    }
+                }
+                case case3bii {
+                   leaf leaf3biia {
+                       type string;
+                   }
+                   leaf leaf3biib {
+                      type string;
+                   }
+                }
+            }
+        }
+    }
+}