Fix javadoc formatting issues
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / UsesAugmentTest.java
index 1cc18cde67f08828d5b84594fda1b6f881be9a43..48ce134171e557d0571b6e689460b1de731dba07 100644 (file)
@@ -7,20 +7,27 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl;
 
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import com.google.common.collect.Lists;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.DateFormat;
 import java.text.ParseException;
-import java.util.ArrayList;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
 import java.util.Date;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -30,20 +37,25 @@ import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
+import org.opendaylight.yangtools.yang.model.util.BooleanType;
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
+import org.opendaylight.yangtools.yang.model.util.Uint32;
+import org.opendaylight.yangtools.yang.model.util.Uint8;
 import org.opendaylight.yangtools.yang.model.util.UnionType;
 
-import com.google.common.collect.Lists;
-
 public class UsesAugmentTest {
-    private final URI ns = URI.create("urn:opendaylight:params:xml:ns:yang:uses-grouping");
-    private Date rev;
-    private final String prefix = "ug";
+    private static final URI UG_NS = URI.create("urn:opendaylight:params:xml:ns:yang:uses-grouping");
+    private static final URI GD_NS = URI.create("urn:opendaylight:params:xml:ns:yang:grouping-definitions");
+    private Date UG_REV;
+    private Date GD_REV;
 
     private Set<Module> modules;
 
     @Before
     public void init() throws FileNotFoundException, ParseException {
-        rev = TestUtils.simpleDateFormat.parse("2013-07-30");
+        DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        UG_REV = simpleDateFormat.parse("2013-07-30");
+        GD_REV = simpleDateFormat.parse("2013-09-04");
     }
 
     /**
@@ -99,345 +111,510 @@ public class UsesAugmentTest {
      * |-- |-- leaf ignore (U)
      *
      * U = added by uses A = added by augment
+     *
+     * @throws Exception if exception occurs
      */
     @Test
     public void testAugmentInUses() throws Exception {
-        modules = TestUtils.loadModules(getClass().getResource("/grouping-test").getPath());
+        modules = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
         Module testModule = TestUtils.findModule(modules, "uses-grouping");
 
+        LinkedList<QName> path = new LinkedList<>();
+
         // * notification pcreq
         Set<NotificationDefinition> notifications = testModule.getNotifications();
         assertEquals(1, notifications.size());
         NotificationDefinition pcreq = notifications.iterator().next();
         assertNotNull(pcreq);
-        assertEquals(createPath("pcreq"), pcreq.getPath());
-        Set<DataSchemaNode> childNodes = pcreq.getChildNodes();
+        QName expectedQName = QName.create(UG_NS, UG_REV, "pcreq");
+        path.offer(expectedQName);
+        SchemaPath expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, pcreq.getPath());
+        Collection<DataSchemaNode> childNodes = pcreq.getChildNodes();
         assertEquals(4, childNodes.size());
-        // * |-- leaf version (U)
+        // * |-- leaf version
         LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName("version");
         assertNotNull(version);
-        assertEquals(createPath("pcreq", "version"), version.getPath());
-        assertEquals(createPath("pcreq", "version", "protocol-version"), version.getType().getPath());
-        assertEquals(createPathForYangType("pcreq", "version", "protocol-version", "uint8"), version.getType()
-                .getBaseType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "version");
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, version.getPath());
+        expectedQName = QName.create(GD_NS, GD_REV, "protocol-version");
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
+        assertEquals(expectedPath, version.getType().getPath());
+        assertEquals(Uint8.getInstance(), version.getType().getBaseType());
         assertTrue(version.isAddedByUses());
-        // * |-- leaf type (U)
+        // * |-- leaf type
         LeafSchemaNode type = (LeafSchemaNode) pcreq.getDataChildByName("type");
         assertNotNull(type);
+        expectedQName = QName.create(UG_NS, UG_REV, "type");
         assertTrue(type.isAddedByUses());
-        assertEquals(createPath("pcreq", "type"), type.getPath());
-        assertEquals(createPath("pcreq", "type", "int-ext"), type.getType().getPath());
+        path.pollLast();
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, type.getPath());
+        expectedQName = QName.create(GD_NS, GD_REV, "int-ext");
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
+        assertEquals(expectedPath, type.getType().getPath());
         UnionType union = (UnionType)type.getType().getBaseType();
-        assertEquals(createPathForYangType("pcreq", "type", "int-ext", "union"), union.getPath());
+        assertEquals(SchemaPath.create(true, BaseTypes.constructQName("union")), union.getPath());
         assertEquals(2, union.getTypes().size());
         // * |-- list requests
         ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName("requests");
         assertNotNull(requests);
-        assertEquals(createPath("pcreq", "requests"), requests.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "requests");
+        assertEquals(expectedQName, requests.getQName());
+        path.pollLast();
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, requests.getPath());
         assertFalse(requests.isAddedByUses());
         childNodes = requests.getChildNodes();
         assertEquals(3, childNodes.size());
         // * |-- |-- container rp
         ContainerSchemaNode rp = (ContainerSchemaNode) requests.getDataChildByName("rp");
         assertNotNull(rp);
-        assertEquals(createPath("pcreq", "requests", "rp"), rp.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "rp");
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, rp.getPath());
         assertFalse(rp.isAddedByUses());
         childNodes = rp.getChildNodes();
         assertEquals(4, childNodes.size());
-        // * |-- |-- |-- leaf priority (U)
+        // * |-- |-- |-- leaf processing-rule
+        LeafSchemaNode processingRule = (LeafSchemaNode) rp.getDataChildByName("processing-rule");
+        assertNotNull(processingRule);
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        assertEquals(expectedQName, processingRule.getQName());
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, processingRule.getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
+        assertTrue(processingRule.isAddedByUses());
+        // * |-- |-- |-- leaf ignore
+        LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName("ignore");
+        assertNotNull(ignore);
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        assertEquals(expectedQName, ignore.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, ignore.getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
+        assertTrue(ignore.isAddedByUses());
+        // * |-- |-- |-- leaf priority
         LeafSchemaNode priority = (LeafSchemaNode) rp.getDataChildByName("priority");
         assertNotNull(priority);
-        assertEquals(createPath("pcreq", "requests", "rp", "priority"), priority.getPath());
-        assertEquals(createPath("pcreq", "requests", "rp", "priority", "uint8"), priority.getType().getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "priority", "uint8", "uint8"), priority.getType()
-                .getBaseType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "priority");
+        assertEquals(expectedQName, priority.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, priority.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "uint8");
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        // TODO
+        //assertEquals(expectedPath, priority.getType().getPath());
+        assertEquals(Uint8.getInstance(), priority.getType().getBaseType());
         assertTrue(priority.isAddedByUses());
-        // * |-- |-- |-- container box (U)
+        // * |-- |-- |-- container box
         ContainerSchemaNode box = (ContainerSchemaNode) rp.getDataChildByName("box");
         assertNotNull(box);
-        assertEquals(createPath("pcreq", "requests", "rp", "box"), box.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "box");
+        assertEquals(expectedQName, box.getQName());
+        path.pollLast();
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, box.getPath());
         assertTrue(box.isAddedByUses());
-        // * |-- |-- |-- |-- container order (A)
+        // * |-- |-- |-- |-- container order
         ContainerSchemaNode order = (ContainerSchemaNode) box.getDataChildByName("order");
         assertNotNull(order);
-        assertEquals(createPath("pcreq", "requests", "rp", "box", "order"), order.getPath());
-        assertFalse(order.isAddedByUses());
+        expectedQName = QName.create(UG_NS, UG_REV, "order");
+        assertEquals(expectedQName, order.getQName());
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, order.getPath());
+        assertTrue(order.isAddedByUses());
         assertTrue(order.isAugmenting());
         assertEquals(2, order.getChildNodes().size());
-        // * |-- |-- |-- |-- |-- leaf delete (U)
+        // * |-- |-- |-- |-- |-- leaf delete
         LeafSchemaNode delete = (LeafSchemaNode) order.getDataChildByName("delete");
         assertNotNull(delete);
-        assertEquals(createPath("pcreq", "requests", "rp", "box", "order", "delete"), delete.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "box", "order", "delete", "uint32"), delete
-                .getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "delete");
+        assertEquals(expectedQName, delete.getQName());
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, delete.getPath());
+        assertEquals(Uint32.getInstance(), delete.getType());
         assertTrue(delete.isAddedByUses());
-        // * |-- |-- |-- |-- |-- leaf ignore (U)
+        // * |-- |-- |-- |-- |-- leaf setup
         LeafSchemaNode setup = (LeafSchemaNode) order.getDataChildByName("setup");
         assertNotNull(setup);
-        assertEquals(createPath("pcreq", "requests", "rp", "box", "order", "setup"), setup.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "box", "order", "setup", "uint32"), setup
-                .getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "setup");
+        assertEquals(expectedQName, setup.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, setup.getPath());
+        assertEquals(Uint32.getInstance(), setup.getType());
         assertTrue(setup.isAddedByUses());
-        // * |-- |-- |-- leaf processing-rule (U)
-        LeafSchemaNode processingRule = (LeafSchemaNode) rp.getDataChildByName("processing-rule");
-        assertNotNull(processingRule);
-        assertEquals(createPath("pcreq", "requests", "rp", "processing-rule"), processingRule.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "processing-rule", "boolean"), processingRule
-                .getType().getPath());
-        assertTrue(processingRule.isAddedByUses());
-        // * |-- |-- |-- leaf ignore (U)
-        LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName("ignore");
-        assertNotNull(ignore);
-        assertEquals(createPath("pcreq", "requests", "rp", "ignore"), ignore.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "ignore", "boolean"), ignore.getType().getPath());
-        assertTrue(ignore.isAddedByUses());
         // * |-- |-- path-key-expansion
         ContainerSchemaNode pke = (ContainerSchemaNode) requests.getDataChildByName("path-key-expansion");
         assertNotNull(pke);
-        assertEquals(createPath("pcreq", "requests", "path-key-expansion"), pke.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "path-key-expansion");
+        assertEquals(expectedQName, pke.getQName());
+        path.pollLast();
+        path.pollLast();
+        path.pollLast();
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, pke.getPath());
         assertFalse(pke.isAddedByUses());
         // * |-- |-- |-- path-key
         ContainerSchemaNode pathKey = (ContainerSchemaNode) pke.getDataChildByName("path-key");
         assertNotNull(pathKey);
-        assertEquals(createPath("pcreq", "requests", "path-key-expansion", "path-key"), pathKey.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "path-key");
+        assertEquals(expectedQName, pathKey.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, pathKey.getPath());
         assertFalse(pathKey.isAddedByUses());
         assertEquals(3, pathKey.getChildNodes().size());
-        // * |-- |-- |-- |-- list path-keys (U)
+        // * |-- |-- |-- |-- leaf processing-rule
+        processingRule = (LeafSchemaNode) pathKey.getDataChildByName("processing-rule");
+        assertNotNull(processingRule);
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        assertEquals(expectedQName, processingRule.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, processingRule.getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
+        assertTrue(processingRule.isAddedByUses());
+        // * |-- |-- |-- |-- leaf ignore
+        ignore = (LeafSchemaNode) pathKey.getDataChildByName("ignore");
+        assertNotNull(ignore);
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        assertEquals(expectedQName, ignore.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, ignore.getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
+        assertTrue(ignore.isAddedByUses());
+        // * |-- |-- |-- |-- list path-keys
         ListSchemaNode pathKeys = (ListSchemaNode) pathKey.getDataChildByName("path-keys");
         assertNotNull(pathKeys);
-        assertEquals(createPath("pcreq", "requests", "path-key-expansion", "path-key", "path-keys"), pathKeys.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "path-keys");
+        assertEquals(expectedQName, pathKeys.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, pathKeys.getPath());
         assertTrue(pathKeys.isAddedByUses());
         childNodes = pathKeys.getChildNodes();
         assertEquals(2, childNodes.size());
-        // * |-- |-- |-- |-- |-- leaf version (U)
+        // * |-- |-- |-- |-- |-- leaf version
         version = (LeafSchemaNode) pathKeys.getDataChildByName("version");
         assertNotNull(version);
-        assertEquals(createPath("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "version"),
-                version.getPath());
-        assertEquals(
-                createPath("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "version",
-                        "protocol-version"), version.getType().getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "version",
-                        "protocol-version", "uint8"), version.getType().getBaseType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "version");
+        assertEquals(expectedQName, version.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, version.getPath());
+        assertTrue(version.getType() instanceof ExtendedType);
+        assertEquals(Uint8.getInstance(), version.getType().getBaseType());
         assertTrue(version.isAddedByUses());
-        assertFalse(version.isAugmenting());
-        // * |-- |-- |-- |-- |-- leaf type (U)
+        assertTrue(version.isAugmenting());
+        // * |-- |-- |-- |-- |-- leaf type
         type = (LeafSchemaNode) pathKeys.getDataChildByName("type");
         assertNotNull(type);
-        assertEquals(createPath("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "type"),
-                type.getPath());
-        assertEquals(
-                createPath("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "type",
-                        "int-ext"), type.getType().getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "type",
-                        "int-ext", "union"), type.getType().getBaseType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "type");
+        assertEquals(expectedQName, type.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, type.getPath());
+        assertTrue(type.getType() instanceof ExtendedType);
         assertTrue(type.isAddedByUses());
-        assertFalse(type.isAugmenting());
-        // * |-- |-- |-- |-- |-- leaf processing-rule (U)
-        processingRule = (LeafSchemaNode) pathKey.getDataChildByName("processing-rule");
-        assertNotNull(processingRule);
-        assertEquals(createPath("pcreq", "requests", "path-key-expansion", "path-key", "processing-rule"),
-                processingRule.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "path-key-expansion", "path-key", "processing-rule",
-                        "boolean"), processingRule.getType().getPath());
-        assertTrue(processingRule.isAddedByUses());
-        // * |-- |-- |-- |-- |-- leaf ignore (U)
-        ignore = (LeafSchemaNode) pathKey.getDataChildByName("ignore");
-        assertNotNull(ignore);
-        assertEquals(createPath("pcreq", "requests", "path-key-expansion", "path-key", "ignore"), ignore.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "path-key-expansion", "path-key", "ignore", "boolean"),
-                ignore.getType().getPath());
-        assertTrue(ignore.isAddedByUses());
+        assertTrue(type.isAugmenting());
         // * |-- |-- container segment-computation
         ContainerSchemaNode sc = (ContainerSchemaNode) requests.getDataChildByName("segment-computation");
         assertNotNull(sc);
-        assertEquals(createPath("pcreq", "requests", "segment-computation"), sc.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "segment-computation");
+        assertEquals(expectedQName, sc.getQName());
+        path.pollLast();
+        path.pollLast();
+        path.pollLast();
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, sc.getPath());
         assertFalse(sc.isAddedByUses());
         // * |-- |-- |-- container p2p
         ContainerSchemaNode p2p = (ContainerSchemaNode) sc.getDataChildByName("p2p");
         assertNotNull(p2p);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p"), p2p.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "p2p");
+        assertEquals(expectedQName, p2p.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, p2p.getPath());
         assertFalse(p2p.isAddedByUses());
         // * |-- |-- |-- |-- container endpoints
         ContainerSchemaNode endpoints = (ContainerSchemaNode) p2p.getDataChildByName("endpoints");
         assertNotNull(endpoints);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "endpoints"), endpoints.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "endpoints");
+        assertEquals(expectedQName, endpoints.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, endpoints.getPath());
         assertFalse(endpoints.isAddedByUses());
-        // * |-- |-- |-- |-- |-- leaf processing-rule (U)
+        // * |-- |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) endpoints.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "endpoints", "processing-rule"),
-                processingRule.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "endpoints",
-                        "processing-rule", "boolean"), processingRule.getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        assertEquals(expectedQName, processingRule.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, processingRule.getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
-        // * |-- |-- |-- |-- |-- leaf ignore (U)
+        // * |-- |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) endpoints.getDataChildByName("ignore");
         assertNotNull(ignore);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "endpoints", "ignore"),
-                ignore.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "endpoints", "ignore",
-                        "boolean"), ignore.getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        assertEquals(expectedQName, ignore.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, ignore.getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- |-- |-- |-- container box
         box = (ContainerSchemaNode) endpoints.getDataChildByName("box");
         assertNotNull(box);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "endpoints", "box"), box.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "box");
+        assertEquals(expectedQName, box.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, box.getPath());
         assertTrue(box.isAddedByUses());
-        // * |-- |-- |-- |-- |-- choice address-family (U)
-        ChoiceNode af = (ChoiceNode) endpoints.getDataChildByName("address-family");
+        // * |-- |-- |-- |-- |-- choice address-family
+        ChoiceSchemaNode af = (ChoiceSchemaNode) endpoints.getDataChildByName("address-family");
         assertNotNull(af);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "endpoints", "address-family"),
-                af.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "address-family");
+        assertEquals(expectedQName, af.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, af.getPath());
         assertTrue(af.isAddedByUses());
         // * |-- |-- |-- |-- container reported-route
         ContainerSchemaNode reportedRoute = (ContainerSchemaNode) p2p.getDataChildByName("reported-route");
         assertNotNull(reportedRoute);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "reported-route"),
-                reportedRoute.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "reported-route");
+        assertEquals(expectedQName, reportedRoute.getQName());
+        path.pollLast();
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, reportedRoute.getPath());
         assertFalse(reportedRoute.isAddedByUses());
-        // * |-- |-- |-- |-- |-- container bandwidth
-        ContainerSchemaNode bandwidth = (ContainerSchemaNode) reportedRoute.getDataChildByName("bandwidth");
-        assertNotNull(bandwidth);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "reported-route", "bandwidth"),
-                bandwidth.getPath());
-        assertFalse(bandwidth.isAddedByUses());
-        // * |-- |-- |-- |-- |-- list subobjects
-        ListSchemaNode subobjects = (ListSchemaNode) reportedRoute.getDataChildByName("subobjects");
-        assertNotNull(subobjects);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "reported-route", "subobjects"),
-                subobjects.getPath());
-        assertTrue(subobjects.isAddedByUses());
-        // * |-- |-- |-- |-- |-- leaf processing-rule (U)
+        // * |-- |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) reportedRoute.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        assertEquals(
-                createPath("pcreq", "requests", "segment-computation", "p2p", "reported-route", "processing-rule"),
-                processingRule.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "reported-route",
-                        "processing-rule", "boolean"), processingRule.getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        assertEquals(expectedQName, processingRule.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, processingRule.getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
-        // * |-- |-- |-- |-- |-- leaf ignore (U)
+        // * |-- |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) reportedRoute.getDataChildByName("ignore");
         assertNotNull(ignore);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "reported-route", "ignore"),
-                ignore.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "reported-route", "ignore",
-                        "boolean"), ignore.getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        assertEquals(expectedQName, ignore.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, ignore.getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
-        // * |-- |-- |-- |-- container bandwidth (U)
+        // * |-- |-- |-- |-- |-- list subobjects
+        ListSchemaNode subobjects = (ListSchemaNode) reportedRoute.getDataChildByName("subobjects");
+        assertNotNull(subobjects);
+        expectedQName = QName.create(UG_NS, UG_REV, "subobjects");
+        assertEquals(expectedQName, subobjects.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, subobjects.getPath());
+        assertTrue(subobjects.isAddedByUses());
+        // * |-- |-- |-- |-- |-- container bandwidth
+        ContainerSchemaNode bandwidth = (ContainerSchemaNode) reportedRoute.getDataChildByName("bandwidth");
+        assertNotNull(bandwidth);
+        expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
+        assertEquals(expectedQName, bandwidth.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, bandwidth.getPath());
+        assertFalse(bandwidth.isAddedByUses());
+        // * |-- |-- |-- |-- container bandwidth
         bandwidth = (ContainerSchemaNode) p2p.getDataChildByName("bandwidth");
         assertNotNull(bandwidth);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "bandwidth"), bandwidth.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
+        assertEquals(expectedQName, bandwidth.getQName());
+        path.pollLast();
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, bandwidth.getPath());
         assertTrue(bandwidth.isAddedByUses());
-        // * |-- |-- |-- |-- |-- container bandwidth (U)
-        ContainerSchemaNode bandwidthInner = (ContainerSchemaNode) bandwidth.getDataChildByName("bandwidth");
-        assertNotNull(bandwidthInner);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "bandwidth", "bandwidth"),
-                bandwidthInner.getPath());
-        assertTrue(bandwidthInner.isAddedByUses());
-        // * |-- |-- |-- |-- |-- leaf processing-rule (U)
+        // * |-- |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) bandwidth.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "bandwidth", "processing-rule"),
-                processingRule.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "bandwidth",
-                        "processing-rule", "boolean"), processingRule.getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        assertEquals(expectedQName, processingRule.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, processingRule.getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
-        // * |-- |-- |-- |-- |-- leaf ignore (U)
+        // * |-- |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) bandwidth.getDataChildByName("ignore");
         assertNotNull(ignore);
-        assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "bandwidth", "ignore"),
-                ignore.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "bandwidth", "ignore",
-                        "boolean"), ignore.getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        assertEquals(expectedQName, ignore.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, ignore.getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
+        // * |-- |-- |-- |-- |-- container bandwidth
+        ContainerSchemaNode bandwidthInner = (ContainerSchemaNode) bandwidth.getDataChildByName("bandwidth");
+        assertNotNull(bandwidthInner);
+        expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
+        assertEquals(expectedQName, bandwidth.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, bandwidthInner.getPath());
+        assertTrue(bandwidthInner.isAddedByUses());
         // * |-- list svec
         ListSchemaNode svec = (ListSchemaNode) pcreq.getDataChildByName("svec");
         assertNotNull(svec);
-        assertEquals(createPath("pcreq", "svec"), svec.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "svec");
+        assertEquals(expectedQName, svec.getQName());
+        path.pollLast();
+        path.pollLast();
+        path.pollLast();
+        path.pollLast();
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, svec.getPath());
         assertFalse(svec.isAddedByUses());
+        // * |-- |-- leaf link-diverse
+        LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName("link-diverse");
+        assertNotNull(linkDiverse);
+        expectedQName = QName.create(UG_NS, UG_REV, "link-diverse");
+        assertEquals(expectedQName, linkDiverse.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, linkDiverse.getPath());
+        assertEquals(BooleanType.getInstance(), linkDiverse.getType());
+        assertTrue(linkDiverse.isAddedByUses());
+        // * |-- |-- leaf processing-rule
+        processingRule = (LeafSchemaNode) svec.getDataChildByName("processing-rule");
+        assertNotNull(processingRule);
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        assertEquals(expectedQName, processingRule.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, processingRule.getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
+        assertTrue(processingRule.isAddedByUses());
+        // * |-- |-- leaf ignore
+        ignore = (LeafSchemaNode) svec.getDataChildByName("ignore");
+        assertNotNull(ignore);
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        assertEquals(expectedQName, ignore.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, ignore.getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
+        assertTrue(ignore.isAddedByUses());
         // * |-- |-- list metric
         ListSchemaNode metric = (ListSchemaNode) svec.getDataChildByName("metric");
         assertNotNull(metric);
-        assertEquals(createPath("pcreq", "svec", "metric"), metric.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "metric");
+        assertEquals(expectedQName, metric.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, metric.getPath());
         assertFalse(metric.isAddedByUses());
-        // * |-- |-- |-- leaf metric-type (U)
+        // * |-- |-- |-- leaf metric-type
         LeafSchemaNode metricType = (LeafSchemaNode) metric.getDataChildByName("metric-type");
         assertNotNull(metricType);
-        assertEquals(createPath("pcreq", "svec", "metric", "metric-type"), metricType.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "metric", "metric-type", "uint8"), metricType.getType()
-                .getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "metric-type");
+        assertEquals(expectedQName, metricType.getQName());
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, metricType.getPath());
+        assertEquals(Uint8.getInstance(), metricType.getType());
         assertTrue(metricType.isAddedByUses());
-        // * |-- |-- |-- box (U)
+        // * |-- |-- |-- box
         box = (ContainerSchemaNode) metric.getDataChildByName("box");
         assertNotNull(box);
-        assertEquals(createPath("pcreq", "svec", "metric", "box"), box.getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "box");
+        assertEquals(expectedQName, box.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, box.getPath());
         assertTrue(box.isAddedByUses());
-        // * |-- |-- |-- leaf processing-rule (U)
+        // * |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) metric.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        assertEquals(createPath("pcreq", "svec", "metric", "processing-rule"), processingRule.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "metric", "processing-rule", "boolean"), processingRule
-                .getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
+        assertEquals(expectedQName, processingRule.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, processingRule.getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
-        // * |-- |-- |-- leaf ignore (U)
+        // * |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) metric.getDataChildByName("ignore");
         assertNotNull(ignore);
-        assertEquals(createPath("pcreq", "svec", "metric", "ignore"), ignore.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "metric", "ignore", "boolean"), ignore.getType().getPath());
-        assertTrue(ignore.isAddedByUses());
-        // * |-- |-- leaf link-diverse (U)
-        LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName("link-diverse");
-        assertNotNull(linkDiverse);
-        assertEquals(createPath("pcreq", "svec", "link-diverse"), linkDiverse.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "link-diverse", "boolean"), linkDiverse.getType().getPath());
-        assertTrue(linkDiverse.isAddedByUses());
-        // * |-- |-- leaf processing-rule (U)
-        processingRule = (LeafSchemaNode) svec.getDataChildByName("processing-rule");
-        assertNotNull(processingRule);
-        assertEquals(createPath("pcreq", "svec", "processing-rule"), processingRule.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "processing-rule", "boolean"), processingRule.getType()
-                .getPath());
-        assertTrue(processingRule.isAddedByUses());
-        // * |-- |-- leaf ignore (U)
-        ignore = (LeafSchemaNode) svec.getDataChildByName("ignore");
-        assertNotNull(ignore);
-        assertEquals(createPath("pcreq", "svec", "ignore"), ignore.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "ignore", "boolean"), ignore.getType().getPath());
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
+        assertEquals(expectedQName, ignore.getQName());
+        path.pollLast();
+        path.offer(expectedQName);
+        expectedPath= SchemaPath.create(path, true);
+        assertEquals(expectedPath, ignore.getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
     }
 
-    private SchemaPath createPath(String... names) {
-        List<QName> path = new ArrayList<>();
-        for (String name : names) {
-            path.add(new QName(ns, rev, prefix, name));
-        }
-        return new SchemaPath(path, true);
-    }
-
-    private SchemaPath createPathForYangType(String... names) {
-        List<QName> path = new ArrayList<>();
-        for (int i = 0; i < names.length - 1; i++) {
-            path.add(new QName(ns, rev, prefix, names[i]));
-        }
-        path.add(new QName(URI.create("urn:ietf:params:xml:ns:yang:1"), names[names.length - 1]));
-        return new SchemaPath(path, true);
-    }
-
     @Test
-    public void testTypedefs() throws FileNotFoundException {
-        modules = TestUtils.loadModules(getClass().getResource("/grouping-test").getPath());
-        Module testModule = TestUtils.findModule(modules, "uses-grouping");
+    public void testTypedefs() throws IOException, URISyntaxException {
+        modules = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
+        Module testModule = TestUtils.findModule(modules, "grouping-definitions");
         Set<TypeDefinition<?>> types = testModule.getTypeDefinitions();
 
         TypeDefinition<?> intExt = null;
@@ -447,7 +624,10 @@ public class UsesAugmentTest {
             }
         }
         assertNotNull(intExt);
-        assertEquals(createPath("int-ext"), intExt.getPath());
+
+        List<QName> path = Lists.newArrayList(QName.create(GD_NS, GD_REV, "int-ext"));
+        SchemaPath expectedPath = SchemaPath.create(path, true);
+        assertEquals(expectedPath, intExt.getPath());
 
         UnionType union = (UnionType)intExt.getBaseType();
 
@@ -463,11 +643,8 @@ public class UsesAugmentTest {
         assertNotNull(uint8);
         assertNotNull(pv);
 
-        SchemaPath expectedPath = null;
-        QName q0 = new QName(ns, rev, prefix, "int-ext");
         QName q1 = BaseTypes.constructQName("union");
-
-        expectedPath = new SchemaPath(Lists.newArrayList(q0, q1), true);
+        expectedPath = SchemaPath.create(Lists.newArrayList(q1), true);
         assertEquals(expectedPath, union.getPath());
     }