[ONOS-6784] Leafref and identity ref under grouping.

Change-Id: Ic2d950efc6da25ed83fe4b709e2800f45f01edfa
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
index 4c5ed88..ab29e12 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobAugmentTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobAugmentTest.java
@@ -17,24 +17,24 @@
 package org.onosproject.yang.runtime.impl;
 
 import org.junit.Test;
-
 import org.onosproject.yang.gen.v1.ymsiptopology.rev20140101.ymsiptopology.node.DefaultAugmentedTopoNode;
 import org.onosproject.yang.gen.v1.ymstopology.rev20140101.ymstopology.DefaultNode;
 import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.DefaultNetworks;
 import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.DefaultNetwork;
 import org.onosproject.yang.gen.v1.yrtietfnetwork.rev20151208.yrtietfnetwork.networks.Network;
+import org.onosproject.yang.gen.v1.yrtietftetopology.rev20160317.yrtietftetopology.TeTemplateName;
 import org.onosproject.yang.gen.v1.yrtietftetopology.rev20160317.yrtietftetopology.networks.network.link.DefaultAugmentedNtLink;
 import org.onosproject.yang.gen.v1.yrtietftetopology.rev20160317.yrtietftetopology.telinkaugment.te.Config;
 import org.onosproject.yang.gen.v1.yrtietftetopology.rev20160317.yrtietftetopology.telinkconfig.bundlestacklevel.Bundle;
 import org.onosproject.yang.gen.v1.yrtietftetopology.rev20160317.yrtietftetopology.telinkconfig.bundlestacklevel.bundle.bundledlinks.BundledLink;
+import org.onosproject.yang.gen.v1.yrtnetworktopology.rev20151208.yrtnetworktopology.TpId;
 import org.onosproject.yang.gen.v1.yrtnetworktopology.rev20151208.yrtnetworktopology.networks.network.DefaultAugmentedNdNetwork;
-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.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 org.onosproject.yang.model.DefaultResourceData;
 
 import java.util.List;
 
@@ -210,17 +210,19 @@
         DefaultNetworks networks = ((DefaultNetworks) modelObject);
         Network network = networks.network().get(0);
         assertThat(network.networkId().toString(), is("network-id"));
-        DefaultAugmentedNdNetwork augNw = ((DefaultNetwork) network)
-                .augmentation(DefaultAugmentedNdNetwork.class);
+        DefaultAugmentedNdNetwork augNw = network.augmentation(
+                DefaultAugmentedNdNetwork.class);
         Link link = augNw.link().get(0);
         assertThat(link.linkId().toString(), is("link-id"));
-        DefaultAugmentedNtLink augLink = ((DefaultLink) link)
-                .augmentation(DefaultAugmentedNtLink.class);
+        DefaultAugmentedNtLink augLink = link.augmentation(
+                DefaultAugmentedNtLink.class);
         Config config = augLink.te().config();
-        assertThat(config.teLinkTemplate().get(0), is("abc"));
+        TeTemplateName tName = (TeTemplateName) config.teLinkTemplate().get(0);
+        assertThat(tName.string(), is("abc"));
         BundledLink bundledLink = ((Bundle) config.bundleStackLevel())
                 .bundledLinks().bundledLink().get(0);
-        assertThat(bundledLink.srcTpRef(), is("101"));
+        TpId id = (TpId) bundledLink.srcTpRef();
+        assertThat(id.uri().string(), is("101"));
         assertThat(bundledLink.sequence(), is(100L));
     }
 }
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobL3VpnSvcTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobL3VpnSvcTest.java
index 478855c..191b40e 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobL3VpnSvcTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobL3VpnSvcTest.java
@@ -17,8 +17,8 @@
 package org.onosproject.yang.runtime.impl;
 
 import org.junit.Test;
-
 import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.DefaultL3VpnSvc;
+import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.SvcId;
 import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.accessvpnpolicy.vpnattachment.attachmentflavor.VpnId;
 import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.DefaultSites;
 import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.DefaultVpnServices;
@@ -304,8 +304,9 @@
         assertThat(ipConnection.ipv6().addresses().mask(), is(mask));
         assertThat(sna.routingProtocols().routingProtocol().get(0).type()
                            .getSimpleName(), is("Ospf"));
-        assertThat(((VpnId) sna.vpnAttachment().attachmentFlavor()).vpnId(),
-                   is("10"));
+        SvcId sId = (SvcId) ((VpnId) sna.vpnAttachment().attachmentFlavor())
+                .vpnId();
+        assertThat(sId.string(), is("10"));
         assertThat(((VpnId) sna.vpnAttachment().attachmentFlavor()).siteRole()
                            .getSimpleName(), is("HubRole"));
     }
@@ -410,8 +411,9 @@
         assertThat(ipConnection.ipv6().addresses().mask(), is(mask));
         assertThat(sna.routingProtocols().routingProtocol().get(0).type()
                            .getSimpleName(), is("Ospf"));
-        assertThat(((VpnId) sna.vpnAttachment().attachmentFlavor()).vpnId(),
-                   is("10"));
+        SvcId sId = (SvcId) ((VpnId) sna.vpnAttachment().attachmentFlavor())
+                .vpnId();
+        assertThat(sId.string(), is("10"));
         assertThat(((VpnId) sna.vpnAttachment().attachmentFlavor()).siteRole()
                            .getSimpleName(), is("HubRole"));
         DefaultSite site2 = ((DefaultSite) modelObjectList.get(1));
@@ -432,8 +434,9 @@
         assertThat(ipConnection.ipv6().addresses().mask(), is(mask));
         assertThat(sna.routingProtocols().routingProtocol().get(0).type()
                            .getSimpleName(), is("Ospf"));
-        assertThat(((VpnId) sna.vpnAttachment().attachmentFlavor()).vpnId(),
-                   is("10"));
+        sId = (SvcId) ((VpnId) sna.vpnAttachment().attachmentFlavor())
+                .vpnId();
+        assertThat(sId.string(), is("10"));
         assertThat(((VpnId) sna.vpnAttachment().attachmentFlavor()).siteRole()
                            .getSimpleName(), is("HubRole"));
     }
@@ -513,8 +516,9 @@
         assertThat(ipConnection.ipv6().addresses().mask(), is(mask));
         assertThat(sna1.routingProtocols().routingProtocol().get(0).type()
                            .getSimpleName(), is("Ospf"));
-        assertThat(((VpnId) sna1.vpnAttachment().attachmentFlavor()).vpnId(),
-                   is("10"));
+        SvcId sId = (SvcId) ((VpnId) sna1.vpnAttachment().attachmentFlavor())
+                .vpnId();
+        assertThat(sId.string(), is("10"));
         assertThat(((VpnId) sna1.vpnAttachment().attachmentFlavor()).siteRole()
                            .getSimpleName(), is("HubRole"));
 
@@ -525,8 +529,8 @@
         bearerAttach = bearer.augmentation(DefaultAugmentedL3VpnBearer.class);
         assertThat(bearerAttach.bearerAttachment().peMgmtIp().string(), is("192.1.1.1"));
         assertThat(bearerAttach.bearerAttachment().peName(), is("pe-name"));
-        reqType = ((DefaultRequestedType) bearer.requestedType())
-                .augmentation(DefaultAugmentedL3VpnRequestedType.class);
+        reqType = bearer.requestedType().augmentation(
+                DefaultAugmentedL3VpnRequestedType.class);
         py = ((PhysicalCase) reqType.requestedTypeProfile()
                 .requestedTypeChoice()).physical();
         assertThat(py.physicalIf(), is("eth0/0/0"));
@@ -542,8 +546,9 @@
         assertThat(ipConnection.ipv6().addresses().mask(), is(mask));
         assertThat(sna2.routingProtocols().routingProtocol().get(0).type()
                            .getSimpleName(), is("Ospf"));
-        assertThat(((VpnId) sna2.vpnAttachment().attachmentFlavor()).vpnId(),
-                   is("10"));
+        sId = (SvcId) ((VpnId) sna2.vpnAttachment().attachmentFlavor())
+                .vpnId();
+        assertThat(sId.string(), is("10"));
         assertThat(((VpnId) sna2.vpnAttachment().attachmentFlavor()).siteRole()
                            .getSimpleName(), is("HubRole"));
     }
@@ -608,8 +613,9 @@
         assertThat(ipConnection.ipv6().addresses().mask(), is(mask));
         assertThat(sna.routingProtocols().routingProtocol().get(0).type()
                            .getSimpleName(), is("Ospf"));
-        assertThat(((VpnId) sna.vpnAttachment().attachmentFlavor()).vpnId(),
-                   is("10"));
+        SvcId sId = (SvcId) ((VpnId) sna.vpnAttachment().attachmentFlavor())
+                .vpnId();
+        assertThat(sId.string(), is("10"));
         assertThat(((VpnId) sna.vpnAttachment().attachmentFlavor()).siteRole()
                            .getSimpleName(), is("HubRole"));
     }
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
index ceffa46..31e2c9d 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobSimpleDataTypeTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobSimpleDataTypeTest.java
@@ -18,13 +18,18 @@
 
 import org.junit.Test;
 import org.onosproject.yang.gen.v1.simpledatatypes.rev20131112.simpledatatypes.DefaultCont;
+import org.onosproject.yang.gen.v1.simpledatatypes.rev20131112.simpledatatypes.gr.Cont3;
 import org.onosproject.yang.gen.v1.simpledatatypesll.rev20131112.simpledatatypesll.DefaultCont1;
+import org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.ytbdatatypes.Leaf7;
 import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.DataNode.Builder;
 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.Base64;
+import java.util.BitSet;
 import java.util.List;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -44,10 +49,10 @@
     private static final String DATA_TYPE_NAME_SPACE_LL =
             "simple:data:types:ll";
     TestYangSerializerContext context = new TestYangSerializerContext();
-    private DataNode.Builder dBlr;
+    private Builder dBlr;
     private String value;
 
-    public DataNode buildDataNodeForSimpleDataTypes() {
+    private DataNode buildDataNodeForSimpleDataTypes() {
         dBlr = initializeDataNode(context);
         value = null;
         dBlr = addDataNode(dBlr, "cont", DATA_TYPE_NAME_SPACE, value, null);
@@ -221,15 +226,215 @@
         dBlr = exitDataNode(dBlr);
 
         value = "/cont";
-        dBlr = addDataNode(dBlr, "inst-iden", null, value, null);
+        dBlr = addDataNode(dBlr, "inst-iden", DATA_TYPE_NAME_SPACE, value, null);
         dBlr = exitDataNode(dBlr);
 
+        dBlr = getLeafRefData(dBlr);
         dBlr = exitDataNode(dBlr);
         return dBlr.build();
     }
 
+    private Builder getLeafRefData(Builder dBlr) {
+        value = "8";
+        dBlr = addDataNode(dBlr, "lref1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
 
-    public DataNode buildDnForLeafListSimpleDataTypes() {
+        value = "val";
+        dBlr = addDataNode(dBlr, "lref2", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "zero";
+        dBlr = addDataNode(dBlr, "lref3", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b2 b3";
+        dBlr = addDataNode(dBlr, "lref4", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-92233720368547758.08";
+        dBlr = addDataNode(dBlr, "lref5", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "10";
+        dBlr = addDataNode(dBlr, "lref6", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "enum4";
+        dBlr = addDataNode(dBlr, "lref7", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-9223372036854.775808";
+        dBlr = addDataNode(dBlr, "lref8", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "MTAxMDEwMTAx";
+        dBlr = addDataNode(dBlr, "lref9", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "";
+        dBlr = addDataNode(dBlr, "lref10", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "";
+        dBlr = addDataNode(dBlr, "lref11", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b3";
+        dBlr = addDataNode(dBlr, "lref12", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "";
+        dBlr = addDataNode(dBlr, "lref13", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b1 b2 b3";
+        dBlr = addDataNode(dBlr, "lref14", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "/cont";
+        dBlr = addDataNode(dBlr, "lref15", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "physical";
+        dBlr = addDataNode(dBlr, "lref16", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "784985";
+        dBlr = addDataNode(dBlr, "lref17", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "MTExMTExMTE=";
+        dBlr = addDataNode(dBlr, "lref18", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "hundred";
+        dBlr = addDataNode(dBlr, "lref19", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "leafref";
+        dBlr = addDataNode(dBlr, "lref20", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "val";
+        dBlr = addDataNode(dBlr, "iref1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "pro";
+        dBlr = addDataNode(dBlr, "iref2", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "physical";
+        dBlr = addDataNode(dBlr, "iref3", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "virtual";
+        dBlr = addDataNode(dBlr, "iref4", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        dBlr = addDataNode(dBlr, "cont3", DATA_TYPE_NAME_SPACE, null, null);
+
+        value = "108";
+        dBlr = addDataNode(dBlr, "llref1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "val";
+        dBlr = addDataNode(dBlr, "llref2", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "one";
+        dBlr = addDataNode(dBlr, "llref3", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b1 b3";
+        dBlr = addDataNode(dBlr, "llref4", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-922337203685470058.08";
+        dBlr = addDataNode(dBlr, "llref5", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "121";
+        dBlr = addDataNode(dBlr, "llref6", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "enum1";
+        dBlr = addDataNode(dBlr, "llref7", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "-9223372036000.775808";
+        dBlr = addDataNode(dBlr, "llref8", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "MTExMTExMTE=";
+        dBlr = addDataNode(dBlr, "llref9", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "";
+        dBlr = addDataNode(dBlr, "llref11", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b2";
+        dBlr = addDataNode(dBlr, "llref12", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "";
+        dBlr = addDataNode(dBlr, "llref13", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "b1";
+        dBlr = addDataNode(dBlr, "llref14", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "/cont/con2";
+        dBlr = addDataNode(dBlr, "llref15", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "virtual";
+        dBlr = addDataNode(dBlr, "llref16", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "78498522";
+        dBlr = addDataNode(dBlr, "llref17", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "MDEwMTAxMDEw";
+        dBlr = addDataNode(dBlr, "llref18", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "ten";
+        dBlr = addDataNode(dBlr, "llref19", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "leaflistref";
+        dBlr = addDataNode(dBlr, "llref20", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "check";
+        dBlr = addDataNode(dBlr, "lref21", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "val";
+        dBlr = addDataNode(dBlr, "iref1", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "pro";
+        dBlr = addDataNode(dBlr, "iref2", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "physical";
+        dBlr = addDataNode(dBlr, "iref3", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        value = "virtual";
+        dBlr = addDataNode(dBlr, "iref4", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
+        dBlr = exitDataNode(dBlr);
+        return dBlr;
+    }
+
+
+    private DataNode buildDnForLeafListSimpleDataTypes() {
         dBlr = initializeDataNode(context);
         value = null;
         dBlr = addDataNode(dBlr, "cont1", DATA_TYPE_NAME_SPACE_LL, value, null);
@@ -402,6 +607,7 @@
         dBlr = addDataNode(dBlr, "lfenum1", null, value, null);
         dBlr = exitDataNode(dBlr);
         dBlr = exitDataNode(dBlr);
+
         return dBlr.build();
     }
 
@@ -475,6 +681,89 @@
         assertThat(cont.identityref1().getSimpleName(), is("Iden"));
         assertThat(cont.lfenum1().enumeration(), is(SUCCESSFUL_EXIT));
         assertThat(cont.instIden(), is("/cont"));
+        value = 8;
+        assertThat(cont.lref1(), is(value));
+        assertThat(cont.lref2().toString(), is(
+                "class org.onosproject.yang.gen.v1.simpledatatypes" +
+                        ".rev20131112.simpledatatypes.Val"));
+        assertThat(cont.lref3().toString(), is("zero"));
+        assertThat(cont.lref4().toString(), is("b2 b3 "));
+        assertThat(cont.lref5().toString(), is("-92233720368547758.08"));
+        value = 10;
+        assertThat(cont.lref6(), is(value));
+        assertThat(cont.lref7().toString(), is("enum4"));
+        assertThat(cont.lref8().toString(), is("-9223372036854.775808"));
+        byte[] arr = Base64.getDecoder().decode("MTAxMDEwMTAx");
+        assertThat(cont.lref9(), is(arr));
+        assertThat(cont.lref10(), is(true));
+        assertThat(cont.lref11().toString(), is("true"));
+        assertThat(cont.lref12().toString(), is("b3 "));
+        assertThat(cont.lref13(), is(true));
+        String bit = Leaf7.toString(cont.lref14());
+        assertThat(bit, is("b1 b2 b3 "));
+        assertThat(cont.lref15(), is("/cont"));
+        assertThat(cont.lref16().toString(), is(
+                "class org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826." +
+                        "ytbdatatypes.Physical"));
+        assertThat(cont.lref17().toString(), is("784985"));
+        arr = Base64.getDecoder().decode("MTExMTExMTE=");
+        assertThat(cont.lref18(), is(arr));
+        assertThat(cont.lref19().toString(), is("hundred"));
+        assertThat(cont.lref20(), is("leafref"));
+        assertThat(cont.iref1().toString(), is(
+                "class org.onosproject.yang.gen.v1.simpledatatypes.rev201311" +
+                        "12.simpledatatypes.Val"));
+        assertThat(cont.iref2().get(0).toString(), is(
+                "class org.onosproject.yang.gen.v1.simpledatatypes.rev201311" +
+                        "12.simpledatatypes.Pro"));
+        assertThat(cont.iref3().toString(), is(
+                "class org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826." +
+                        "ytbdatatypes.Physical"));
+        assertThat(cont.iref4().get(0).toString(), is(
+                "class org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826." +
+                        "ytbdatatypes.Virtual"));
+        Cont3 cont3 = cont.cont3();
+        value = 108;
+        assertThat(cont3.llref1().get(0), is(value));
+        assertThat(cont3.llref2().get(0).toString(), is(
+                "class org.onosproject.yang.gen.v1.simpledatatypes" +
+                        ".rev20131112.simpledatatypes.Val"));
+        assertThat(cont3.llref3().get(0).toString(), is("one"));
+        assertThat(cont3.llref4().get(0).toString(), is("b1 b3 "));
+        assertThat(cont3.llref5().get(0).toString(), is("-922337203685470058.08"));
+        value = 121;
+        assertThat(cont3.llref6().get(0), is(value));
+        assertThat(cont3.llref7().get(0).toString(), is("enum1"));
+        assertThat(cont3.llref8().get(0).toString(), is("-9223372036000.775808"));
+        arr = Base64.getDecoder().decode("MTExMTExMTE=");
+        assertThat(cont3.llref9().get(0), is(arr));
+        assertThat(cont3.llref11().get(0).toString(), is("true"));
+        assertThat(cont3.llref12().get(0).toString(), is("b2 "));
+        assertThat(cont3.llref13().get(0), is(true));
+        bit = Leaf7.toString((BitSet) cont3.llref14().get(0));
+        assertThat(bit, is("b1 "));
+        assertThat(cont3.llref15().get(0), is("/cont/con2"));
+        assertThat(cont3.llref16().get(0).toString(), is(
+                "class org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826." +
+                        "ytbdatatypes.Virtual"));
+        assertThat(cont3.llref17().get(0).toString(), is("78498522"));
+        arr = Base64.getDecoder().decode("MDEwMTAxMDEw");
+        assertThat(cont3.llref18().get(0), is(arr));
+        assertThat(cont3.llref19().get(0).toString(), is("ten"));
+        assertThat(cont3.llref20().get(0), is("leaflistref"));
+        assertThat(cont3.lref21(), is("check"));
+        assertThat(cont3.iref1().toString(), is(
+                "class org.onosproject.yang.gen.v1.simpledatatypes.rev201311" +
+                        "12.simpledatatypes.Val"));
+        assertThat(cont3.iref2().get(0).toString(), is(
+                "class org.onosproject.yang.gen.v1.simpledatatypes.rev201311" +
+                        "12.simpledatatypes.Pro"));
+        assertThat(cont3.iref3().toString(), is(
+                "class org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826." +
+                        "ytbdatatypes.Physical"));
+        assertThat(cont3.iref4().get(0).toString(), is(
+                "class org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826." +
+                        "ytbdatatypes.Virtual"));
     }
 
 
diff --git a/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang b/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang
index 599649f..1267a0a 100644
--- a/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang
+++ b/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang
@@ -1,275 +1,606 @@
 module simple-data-types {
-  namespace "simple:data:types";  
+    namespace "simple:data:types";
 
-  prefix "smpdtp";
-  revision 2013-11-12 {
-  }
+    prefix "smpdtp";
 
-  identity iden {
-  }
-
-  typedef tpdfempty {
-    type empty;
-  }
-
-  typedef tpdfbit {
-     type bits {
-        bit b1;
-        bit b2;
-        bit b3;
+    import YtbDataTypes {
+        prefix ytb;
     }
-  }
-
-  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;
-        }
-    }
-  }
-
-  typedef tpdfun0 {
-     type enumeration {
-        enum "successful exit" {
-            value 1;
-        }
-        enum "grace period expired" {
-            value 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;
-      }
+    revision 2013-11-12 {
     }
 
-    leaf lfbits {
-      type bits {
-        bit bit1;
-        bit bit2;
-        bit bit3;
-        bit bit4;
-      }
+    identity iden {
     }
 
-    leaf lfbinary {
-        type binary;
-    }  
-
-    leaf lfref1 {                  //reference to string type
-        type leafref {
-            path "../lfstr";
-        }
+    identity val {
+        base iden;
     }
 
-    leaf lfref2 {                  //reference to number type
-        type leafref {
-            path "../lfnint8Max";
-        }
+    identity pro {
+        base iden;
     }
 
-    leaf lfempty {
+    typedef tpdfempty {
         type empty;
     }
 
-    leaf lfunion1 {
-        type union {
-            type uint16;
-            type string;
+    typedef tpdfbit {
+        type bits {
+            bit b1;
+            bit b2;
+            bit b3;
         }
     }
-    leaf lfunion2 {
+
+    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;
             }
-            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;
+    typedef tpdfun0 {
+        type enumeration {
+            enum "successful exit" {
+                value 1;
             }
-            type boolean;
+            enum "grace period expired" {
+                value 2;
+            }
         }
     }
 
-    leaf lfunion11 {
-        type union {
-            type tpdfun1;
+    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 lfunion12 {
-        type tpdfun2;
-    }
+        leaf lfunion13 {
+            type tpdfbit;
+        }
 
-    leaf lfunion13 {
-        type tpdfbit;    
-    }
-
-    leaf lfunion14 {
-        type union {
-            type enumeration {
-                enum zero;
-                enum one;
+        leaf lfunion14 {
+            type union {
+                type enumeration {
+                    enum zero;
+                    enum one;
+                }
+                type uint16;
             }
-            type uint16;
+        }
+
+        leaf identityref1 {
+            type identityref {
+                base iden;
+            }
+        }
+
+        leaf lfenum1 {
+            type tpdfun0;
+        }
+
+        leaf inst-iden {
+            type instance-identifier;
+        }
+
+        leaf lref1 {
+            type leafref {
+                path "../lfnint8Min";
+            }
+        }
+
+        leaf lref2 {
+            type leafref {
+                path "../identityref1";
+            }
+        }
+
+        leaf lref3 {
+            type leafref {
+                path "../lfunion14";
+            }
+        }
+
+        leaf lref4 {
+            type leafref {
+                path "../lfunion13";
+            }
+        }
+
+        leaf lref5 {
+            type leafref {
+                path "../lfunion11";
+            }
+        }
+
+        leaf lref6 {
+            type leafref {
+                path "../lfref2";
+            }
+        }
+
+        leaf lref7 {
+            type leafref {
+                path "../lfenum";
+            }
+        }
+
+        leaf lref8 {
+            type leafref {
+                path "../lfdecimal6";
+            }
+        }
+
+        leaf lref9 {
+            type leafref {
+                path "/ytb:leaf12";
+            }
+        }
+
+        leaf lref10 {
+            type leafref {
+                path "/ytb:leaf11";
+            }
+        }
+
+        leaf lref11 {
+            type leafref {
+                path "/ytb:leaf10";
+            }
+        }
+
+        leaf lref12 {
+            type leafref {
+                path "/ytb:leaf9";
+            }
+        }
+
+        leaf lref13 {
+            type leafref {
+                path "/ytb:leaf8";
+            }
+        }
+
+        leaf lref14 {
+            type leafref {
+                path "/ytb:leaf7";
+            }
+        }
+
+        leaf lref15 {
+            type leafref {
+                path "/ytb:leaf6";
+            }
+        }
+
+        leaf lref16 {
+            type leafref {
+                path "/ytb:leaf5";
+            }
+        }
+
+        leaf lref17 {
+            type leafref {
+                path "/ytb:leaf4";
+            }
+        }
+
+        leaf lref18 {
+            type leafref {
+                path "/ytb:leaf3";
+            }
+        }
+
+        leaf lref19 {
+            type leafref {
+                path "/ytb:leaf2";
+            }
+        }
+
+        leaf lref20 {
+            type leafref {
+                path "/ytb:leaf1";
+            }
+        }
+
+        leaf iref1 {
+            type identityref {
+                base iden;
+            }
+        }
+
+        leaf-list iref2 {
+            type identityref {
+                base iden;
+            }
+        }
+
+        leaf iref3 {
+            type identityref {
+                base ytb:type;
+            }
+        }
+
+        leaf-list iref4 {
+            type identityref {
+                base ytb:type;
+            }
+        }
+
+        uses gr;
+    }
+
+    grouping gr {
+        container cont3 {
+            leaf-list llref1 {
+                type leafref {
+                    path "../../lfnint8Min";
+                }
+            }
+
+            leaf-list llref2 {
+                type leafref {
+                    path "../../identityref1";
+                }
+            }
+
+            leaf-list llref3 {
+                type leafref {
+                    path "../../lfunion14";
+                }
+            }
+
+            leaf-list llref4 {
+                type leafref {
+                    path "../../lfunion13";
+                }
+            }
+
+            leaf-list llref5 {
+                type leafref {
+                    path "../../lfunion11";
+                }
+            }
+
+            leaf-list llref6 {
+                type leafref {
+                    path "../../lfref2";
+                }
+            }
+
+            leaf-list llref7 {
+                type leafref {
+                    path "../../lfenum";
+                }
+            }
+
+            leaf-list llref8 {
+                type leafref {
+                    path "../../lfdecimal6";
+                }
+            }
+
+            leaf-list llref9 {
+                type leafref {
+                    path "/ytb:leaf12";
+                }
+            }
+
+            leaf-list llref10 {
+                type leafref {
+                    path "/ytb:leaf11";
+                }
+            }
+
+            leaf-list llref11 {
+                type leafref {
+                    path "/ytb:leaf10";
+                }
+            }
+
+            leaf-list llref12 {
+                type leafref {
+                    path "/ytb:leaf9";
+                }
+            }
+
+            leaf-list llref13 {
+                type leafref {
+                    path "/ytb:leaf8";
+                }
+            }
+
+            leaf-list llref14 {
+                type leafref {
+                    path "/ytb:leaf7";
+                }
+            }
+
+            leaf-list llref15 {
+                type leafref {
+                    path "/ytb:leaf6";
+                }
+            }
+
+            leaf-list llref16 {
+                type leafref {
+                    path "/ytb:leaf5";
+                }
+            }
+
+            leaf-list llref17 {
+                type leafref {
+                    path "/ytb:leaf4";
+                }
+            }
+
+            leaf-list llref18 {
+                type leafref {
+                    path "/ytb:leaf3";
+                }
+            }
+
+            leaf-list llref19 {
+                type leafref {
+                    path "/ytb:leaf2";
+                }
+            }
+
+            leaf-list llref20 {
+                type leafref {
+                    path "/ytb:leaf1";
+                }
+            }
+
+            leaf lref21 {
+                type leafref {
+                    path "/ytb:leaf1";
+                }
+            }
+
+            leaf iref1 {
+                type identityref {
+                    base iden;
+                }
+            }
+
+            leaf-list iref2 {
+                type identityref {
+                    base iden;
+                }
+            }
+
+            leaf iref3 {
+                type identityref {
+                    base ytb:type;
+                }
+            }
+
+            leaf-list iref4 {
+                type identityref {
+                    base ytb:type;
+                }
+            }
         }
     }
-
-    leaf identityref1 {
-        type identityref {
-            base iden;
-        }
-    }
-
-    leaf lfenum1 {
-        type tpdfun0;
-    }
-
-    leaf inst-iden {
-        type instance-identifier;
-    }
-  }
 }