BUG 1131: untangling package cyclic dependencies in yang-parser-impl
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / YangParserTest.java
index 15f6ca805fc428e986e86da6ac716fa47b862766..ab26254433c5f249f51188c29da291e5671d1581 100644 (file)
@@ -7,20 +7,34 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl;
 
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.InputStream;
 import java.net.URI;
+import java.text.DateFormat;
 import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Map;
 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.AnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
@@ -35,9 +49,11 @@ import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -45,6 +61,7 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.model.util.Decimal64;
 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
 import org.opendaylight.yangtools.yang.model.util.Int16;
@@ -52,58 +69,62 @@ import org.opendaylight.yangtools.yang.model.util.Int32;
 import org.opendaylight.yangtools.yang.model.util.StringType;
 import org.opendaylight.yangtools.yang.model.util.Uint32;
 import org.opendaylight.yangtools.yang.model.util.UnionType;
+import org.opendaylight.yangtools.yang.parser.builder.impl.BuilderUtils;
 
 public class YangParserTest {
-    private final URI nodesNS = URI.create("urn:simple.nodes.test");
-    private final URI typesNS = URI.create("urn:simple.types.test");
-    private final URI customNS = URI.create("urn:custom.nodes.test");
-    private Date nodesRev;
-    private Date typesRev;
-    private Date customRev;
+    public static final String FS = File.separator;
+
+    private final URI fooNS = URI.create("urn:opendaylight.foo");
+    private final URI barNS = URI.create("urn:opendaylight.bar");
+    private final URI bazNS = URI.create("urn:opendaylight.baz");
+    private Date fooRev;
+    private Date barRev;
+    private Date bazRev;
 
     private Set<Module> modules;
 
     @Before
-    public void init() throws FileNotFoundException, ParseException {
-        nodesRev = TestUtils.simpleDateFormat.parse("2013-02-27");
-        typesRev = TestUtils.simpleDateFormat.parse("2013-07-03");
-        customRev = TestUtils.simpleDateFormat.parse("2013-02-27");
+    public void init() throws Exception {
+        DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        fooRev = simpleDateFormat.parse("2013-02-27");
+        barRev = simpleDateFormat.parse("2013-07-03");
+        bazRev = simpleDateFormat.parse("2013-02-27");
 
-        modules = TestUtils.loadModules(getClass().getResource("/model").getPath());
+        modules = TestUtils.loadModules(getClass().getResource("/model").toURI());
         assertEquals(3, modules.size());
     }
 
     @Test
     public void testHeaders() throws ParseException {
-        Module test = TestUtils.findModule(modules, "nodes");
+        Module foo = TestUtils.findModule(modules, "foo");
 
-        assertEquals("nodes", test.getName());
-        assertEquals("1", test.getYangVersion());
-        assertEquals(nodesNS, test.getNamespace());
-        assertEquals("n", test.getPrefix());
+        assertEquals("foo", foo.getName());
+        assertEquals("1", foo.getYangVersion());
+        assertEquals(fooNS, foo.getNamespace());
+        assertEquals("foo", foo.getPrefix());
 
-        Set<ModuleImport> imports = test.getImports();
+        Set<ModuleImport> imports = foo.getImports();
         assertEquals(2, imports.size());
 
-        ModuleImport import2 = TestUtils.findImport(imports, "t");
-        assertEquals("types", import2.getModuleName());
-        assertEquals(typesRev, import2.getRevision());
+        ModuleImport import2 = TestUtils.findImport(imports, "br");
+        assertEquals("bar", import2.getModuleName());
+        assertEquals(barRev, import2.getRevision());
 
-        ModuleImport import3 = TestUtils.findImport(imports, "c");
-        assertEquals("custom", import3.getModuleName());
-        assertEquals(customRev, import3.getRevision());
+        ModuleImport import3 = TestUtils.findImport(imports, "bz");
+        assertEquals("baz", import3.getModuleName());
+        assertEquals(bazRev, import3.getRevision());
 
-        assertEquals("opendaylight", test.getOrganization());
-        assertEquals("http://www.opendaylight.org/", test.getContact());
+        assertEquals("opendaylight", foo.getOrganization());
+        assertEquals("http://www.opendaylight.org/", foo.getContact());
         Date expectedRevision = TestUtils.createDate("2013-02-27");
-        assertEquals(expectedRevision, test.getRevision());
-        assertEquals(" WILL BE DEFINED LATER", test.getReference());
+        assertEquals(expectedRevision, foo.getRevision());
+        assertEquals(" WILL BE DEFINED LATER", foo.getReference());
     }
 
     @Test
     public void testOrderingTypedef() {
-        Module test = TestUtils.findModule(modules, "types");
-        Set<TypeDefinition<?>> typedefs = test.getTypeDefinitions();
+        Module bar = TestUtils.findModule(modules, "bar");
+        Set<TypeDefinition<?>> typedefs = bar.getTypeDefinitions();
         String[] expectedOrder = new String[] { "int32-ext1", "int32-ext2", "my-decimal-type", "my-union",
                 "my-union-ext", "nested-union2", "string-ext1", "string-ext2", "string-ext3", "string-ext4" };
         String[] actualOrder = new String[typedefs.size()];
@@ -118,9 +139,9 @@ public class YangParserTest {
 
     @Test
     public void testOrderingChildNodes() {
-        Module test = TestUtils.findModule(modules, "nodes");
+        Module foo = TestUtils.findModule(modules, "foo");
         AugmentationSchema augment1 = null;
-        for (AugmentationSchema as : test.getAugmentations()) {
+        for (AugmentationSchema as : foo.getAugmentations()) {
             if ("if:ifType='ds0'".equals(as.getWhenCondition().toString())) {
                 augment1 = as;
                 break;
@@ -142,9 +163,9 @@ public class YangParserTest {
 
     @Test
     public void testOrderingNestedChildNodes1() {
-        Module test = TestUtils.findModule(modules, "nodes");
+        Module foo = TestUtils.findModule(modules, "foo");
 
-        Set<DataSchemaNode> childNodes = test.getChildNodes();
+        Set<DataSchemaNode> childNodes = foo.getChildNodes();
         String[] expectedOrder = new String[] { "address", "addresses", "custom-union-leaf", "data", "datas",
                 "decimal-leaf", "decimal-leaf2", "ext", "how", "int32-leaf", "length-leaf", "mycont", "peer", "port",
                 "string-leaf", "transfer", "union-leaf" };
@@ -160,8 +181,8 @@ public class YangParserTest {
 
     @Test
     public void testOrderingNestedChildNodes2() {
-        Module test = TestUtils.findModule(modules, "custom");
-        Set<GroupingDefinition> groupings = test.getGroupings();
+        Module baz = TestUtils.findModule(modules, "baz");
+        Set<GroupingDefinition> groupings = baz.getGroupings();
         assertEquals(1, groupings.size());
         GroupingDefinition target = groupings.iterator().next();
 
@@ -179,17 +200,17 @@ public class YangParserTest {
 
     @Test
     public void testParseList() {
-        Module test = TestUtils.findModule(modules, "types");
-        URI expectedNamespace = URI.create("urn:simple.types.test");
-        String expectedPrefix = "t";
+        Module bar = TestUtils.findModule(modules, "bar");
+        URI expectedNamespace = URI.create("urn:opendaylight.bar");
+        String expectedPrefix = "bar";
 
-        ContainerSchemaNode interfaces = (ContainerSchemaNode) test.getDataChildByName("interfaces");
+        ContainerSchemaNode interfaces = (ContainerSchemaNode) bar.getDataChildByName("interfaces");
 
         ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName("ifEntry");
         // test SchemaNode args
-        QName expectedQName = new QName(expectedNamespace, typesRev, expectedPrefix, "ifEntry");
+        QName expectedQName = new QName(expectedNamespace, barRev, expectedPrefix, "ifEntry");
         assertEquals(expectedQName, ifEntry.getQName());
-        SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace, typesRev, expectedPrefix, "interfaces",
+        SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace, barRev, expectedPrefix, "interfaces",
                 "ifEntry");
         assertEquals(expectedPath, ifEntry.getPath());
         assertNull(ifEntry.getDescription());
@@ -209,8 +230,8 @@ public class YangParserTest {
         Set<AugmentationSchema> availableAugmentations = ifEntry.getAvailableAugmentations();
         assertEquals(2, availableAugmentations.size());
         // test ListSchemaNode args
-        List<QName> expectedKey = new ArrayList<QName>();
-        expectedKey.add(new QName(expectedNamespace, typesRev, expectedPrefix, "ifIndex"));
+        List<QName> expectedKey = new ArrayList<>();
+        expectedKey.add(new QName(expectedNamespace, barRev, expectedPrefix, "ifIndex"));
         assertEquals(expectedKey, ifEntry.getKeyDefinition());
         assertFalse(ifEntry.isUserOrdered());
         // test DataNodeContainer args
@@ -220,6 +241,7 @@ public class YangParserTest {
         assertEquals(0, ifEntry.getUses().size());
 
         LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry.getDataChildByName("ifIndex");
+        assertEquals(ifEntry.getKeyDefinition().get(0), ifIndex.getQName());
         assertTrue(ifIndex.getType() instanceof Uint32);
         LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry.getDataChildByName("ifMtu");
         assertTrue(ifMtu.getType() instanceof Int32);
@@ -227,20 +249,20 @@ public class YangParserTest {
 
     @Test
     public void testTypedefRangesResolving() throws ParseException {
-        Module testModule = TestUtils.findModule(modules, "nodes");
-        LeafSchemaNode int32Leaf = (LeafSchemaNode) testModule.getDataChildByName("int32-leaf");
+        Module foo = TestUtils.findModule(modules, "foo");
+        LeafSchemaNode int32Leaf = (LeafSchemaNode) foo.getDataChildByName("int32-leaf");
 
         ExtendedType leafType = (ExtendedType) int32Leaf.getType();
         QName leafTypeQName = leafType.getQName();
         assertEquals("int32-ext2", leafTypeQName.getLocalName());
-        assertEquals("n", leafTypeQName.getPrefix());
-        assertEquals(nodesNS, leafTypeQName.getNamespace());
-        assertEquals(nodesRev, leafTypeQName.getRevision());
+        assertEquals("foo", leafTypeQName.getPrefix());
+        assertEquals(fooNS, leafTypeQName.getNamespace());
+        assertEquals(fooRev, leafTypeQName.getRevision());
         assertNull(leafType.getUnits());
         assertNull(leafType.getDefaultValue());
-        assertTrue(leafType.getLengths().isEmpty());
-        assertTrue(leafType.getPatterns().isEmpty());
-        List<RangeConstraint> ranges = leafType.getRanges();
+        assertTrue(leafType.getLengthConstraints().isEmpty());
+        assertTrue(leafType.getPatternConstraints().isEmpty());
+        List<RangeConstraint> ranges = leafType.getRangeConstraints();
         assertEquals(1, ranges.size());
         RangeConstraint range = ranges.get(0);
         assertEquals(12L, range.getMin());
@@ -249,14 +271,14 @@ public class YangParserTest {
         ExtendedType baseType = (ExtendedType) leafType.getBaseType();
         QName baseTypeQName = baseType.getQName();
         assertEquals("int32-ext2", baseTypeQName.getLocalName());
-        assertEquals("t", baseTypeQName.getPrefix());
-        assertEquals(typesNS, baseTypeQName.getNamespace());
-        assertEquals(typesRev, baseTypeQName.getRevision());
+        assertEquals("bar", baseTypeQName.getPrefix());
+        assertEquals(barNS, baseTypeQName.getNamespace());
+        assertEquals(barRev, baseTypeQName.getRevision());
         assertEquals("mile", baseType.getUnits());
         assertEquals("11", baseType.getDefaultValue());
-        assertTrue(leafType.getLengths().isEmpty());
-        assertTrue(leafType.getPatterns().isEmpty());
-        List<RangeConstraint> baseTypeRanges = baseType.getRanges();
+        assertTrue(leafType.getLengthConstraints().isEmpty());
+        assertTrue(leafType.getPatternConstraints().isEmpty());
+        List<RangeConstraint> baseTypeRanges = baseType.getRangeConstraints();
         assertEquals(2, baseTypeRanges.size());
         RangeConstraint baseTypeRange1 = baseTypeRanges.get(0);
         assertEquals(3L, baseTypeRange1.getMin());
@@ -268,14 +290,14 @@ public class YangParserTest {
         ExtendedType base = (ExtendedType) baseType.getBaseType();
         QName baseQName = base.getQName();
         assertEquals("int32-ext1", baseQName.getLocalName());
-        assertEquals("t", baseQName.getPrefix());
-        assertEquals(typesNS, baseQName.getNamespace());
-        assertEquals(typesRev, baseQName.getRevision());
+        assertEquals("bar", baseQName.getPrefix());
+        assertEquals(barNS, baseQName.getNamespace());
+        assertEquals(barRev, baseQName.getRevision());
         assertNull(base.getUnits());
         assertNull(base.getDefaultValue());
-        assertTrue(leafType.getLengths().isEmpty());
-        assertTrue(leafType.getPatterns().isEmpty());
-        List<RangeConstraint> baseRanges = base.getRanges();
+        assertTrue(leafType.getLengthConstraints().isEmpty());
+        assertTrue(leafType.getPatternConstraints().isEmpty());
+        List<RangeConstraint> baseRanges = base.getRangeConstraints();
         assertEquals(1, baseRanges.size());
         RangeConstraint baseRange = baseRanges.get(0);
         assertEquals(2L, baseRange.getMin());
@@ -286,167 +308,167 @@ public class YangParserTest {
 
     @Test
     public void testTypedefPatternsResolving() {
-        Module testModule = TestUtils.findModule(modules, "nodes");
-        LeafSchemaNode stringleaf = (LeafSchemaNode) testModule.getDataChildByName("string-leaf");
+        Module foo = TestUtils.findModule(modules, "foo");
+        LeafSchemaNode stringleaf = (LeafSchemaNode) foo.getDataChildByName("string-leaf");
 
         ExtendedType type = (ExtendedType) stringleaf.getType();
         QName typeQName = type.getQName();
         assertEquals("string-ext4", typeQName.getLocalName());
-        assertEquals("t", typeQName.getPrefix());
-        assertEquals(typesNS, typeQName.getNamespace());
-        assertEquals(typesRev, typeQName.getRevision());
+        assertEquals("bar", typeQName.getPrefix());
+        assertEquals(barNS, typeQName.getNamespace());
+        assertEquals(barRev, typeQName.getRevision());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
-        List<PatternConstraint> patterns = type.getPatterns();
+        List<PatternConstraint> patterns = type.getPatternConstraints();
         assertEquals(1, patterns.size());
         PatternConstraint pattern = patterns.iterator().next();
         assertEquals("[e-z]*", pattern.getRegularExpression());
-        assertTrue(type.getLengths().isEmpty());
-        assertTrue(type.getRanges().isEmpty());
+        assertTrue(type.getLengthConstraints().isEmpty());
+        assertTrue(type.getRangeConstraints().isEmpty());
 
         ExtendedType baseType1 = (ExtendedType) type.getBaseType();
         QName baseType1QName = baseType1.getQName();
         assertEquals("string-ext3", baseType1QName.getLocalName());
-        assertEquals("t", baseType1QName.getPrefix());
-        assertEquals(typesNS, baseType1QName.getNamespace());
-        assertEquals(typesRev, baseType1QName.getRevision());
+        assertEquals("bar", baseType1QName.getPrefix());
+        assertEquals(barNS, baseType1QName.getNamespace());
+        assertEquals(barRev, baseType1QName.getRevision());
         assertNull(baseType1.getUnits());
         assertNull(baseType1.getDefaultValue());
-        patterns = baseType1.getPatterns();
+        patterns = baseType1.getPatternConstraints();
         assertEquals(1, patterns.size());
         pattern = patterns.iterator().next();
         assertEquals("[b-u]*", pattern.getRegularExpression());
-        assertTrue(baseType1.getLengths().isEmpty());
-        assertTrue(baseType1.getRanges().isEmpty());
+        assertTrue(baseType1.getLengthConstraints().isEmpty());
+        assertTrue(baseType1.getRangeConstraints().isEmpty());
 
         ExtendedType baseType2 = (ExtendedType) baseType1.getBaseType();
         QName baseType2QName = baseType2.getQName();
         assertEquals("string-ext2", baseType2QName.getLocalName());
-        assertEquals("t", baseType2QName.getPrefix());
-        assertEquals(typesNS, baseType2QName.getNamespace());
-        assertEquals(typesRev, baseType2QName.getRevision());
+        assertEquals("bar", baseType2QName.getPrefix());
+        assertEquals(barNS, baseType2QName.getNamespace());
+        assertEquals(barRev, baseType2QName.getRevision());
         assertNull(baseType2.getUnits());
         assertNull(baseType2.getDefaultValue());
-        assertTrue(baseType2.getPatterns().isEmpty());
-        List<LengthConstraint> baseType2Lengths = baseType2.getLengths();
+        assertTrue(baseType2.getPatternConstraints().isEmpty());
+        List<LengthConstraint> baseType2Lengths = baseType2.getLengthConstraints();
         assertEquals(1, baseType2Lengths.size());
         LengthConstraint length = baseType2Lengths.get(0);
         assertEquals(6L, length.getMin());
         assertEquals(10L, length.getMax());
-        assertTrue(baseType2.getRanges().isEmpty());
+        assertTrue(baseType2.getRangeConstraints().isEmpty());
 
         ExtendedType baseType3 = (ExtendedType) baseType2.getBaseType();
         QName baseType3QName = baseType3.getQName();
         assertEquals("string-ext1", baseType3QName.getLocalName());
-        assertEquals("t", baseType3QName.getPrefix());
-        assertEquals(typesNS, baseType3QName.getNamespace());
-        assertEquals(typesRev, baseType3QName.getRevision());
+        assertEquals("bar", baseType3QName.getPrefix());
+        assertEquals(barNS, baseType3QName.getNamespace());
+        assertEquals(barRev, baseType3QName.getRevision());
         assertNull(baseType3.getUnits());
         assertNull(baseType3.getDefaultValue());
-        patterns = baseType3.getPatterns();
+        patterns = baseType3.getPatternConstraints();
         assertEquals(1, patterns.size());
         pattern = patterns.iterator().next();
         assertEquals("[a-k]*", pattern.getRegularExpression());
-        List<LengthConstraint> baseType3Lengths = baseType3.getLengths();
+        List<LengthConstraint> baseType3Lengths = baseType3.getLengthConstraints();
         assertEquals(1, baseType3Lengths.size());
         length = baseType3Lengths.get(0);
         assertEquals(5L, length.getMin());
         assertEquals(11L, length.getMax());
-        assertTrue(baseType3.getRanges().isEmpty());
+        assertTrue(baseType3.getRangeConstraints().isEmpty());
 
         assertTrue(baseType3.getBaseType() instanceof StringType);
     }
 
     @Test
     public void testTypedefLengthsResolving() {
-        Module testModule = TestUtils.findModule(modules, "nodes");
+        Module foo = TestUtils.findModule(modules, "foo");
 
-        LeafSchemaNode lengthLeaf = (LeafSchemaNode) testModule.getDataChildByName("length-leaf");
+        LeafSchemaNode lengthLeaf = (LeafSchemaNode) foo.getDataChildByName("length-leaf");
         ExtendedType type = (ExtendedType) lengthLeaf.getType();
 
         QName typeQName = type.getQName();
         assertEquals("string-ext2", typeQName.getLocalName());
-        assertEquals("n", typeQName.getPrefix());
-        assertEquals(nodesNS, typeQName.getNamespace());
-        assertEquals(nodesRev, typeQName.getRevision());
+        assertEquals("foo", typeQName.getPrefix());
+        assertEquals(fooNS, typeQName.getNamespace());
+        assertEquals(fooRev, typeQName.getRevision());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
-        assertTrue(type.getPatterns().isEmpty());
-        List<LengthConstraint> typeLengths = type.getLengths();
+        assertTrue(type.getPatternConstraints().isEmpty());
+        List<LengthConstraint> typeLengths = type.getLengthConstraints();
         assertEquals(1, typeLengths.size());
         LengthConstraint length = typeLengths.get(0);
         assertEquals(7L, length.getMin());
         assertEquals(10L, length.getMax());
-        assertTrue(type.getRanges().isEmpty());
+        assertTrue(type.getRangeConstraints().isEmpty());
 
         ExtendedType baseType1 = (ExtendedType) type.getBaseType();
         QName baseType1QName = baseType1.getQName();
         assertEquals("string-ext2", baseType1QName.getLocalName());
-        assertEquals("t", baseType1QName.getPrefix());
-        assertEquals(typesNS, baseType1QName.getNamespace());
-        assertEquals(typesRev, baseType1QName.getRevision());
+        assertEquals("bar", baseType1QName.getPrefix());
+        assertEquals(barNS, baseType1QName.getNamespace());
+        assertEquals(barRev, baseType1QName.getRevision());
         assertNull(baseType1.getUnits());
         assertNull(baseType1.getDefaultValue());
-        assertTrue(baseType1.getPatterns().isEmpty());
-        List<LengthConstraint> baseType2Lengths = baseType1.getLengths();
+        assertTrue(baseType1.getPatternConstraints().isEmpty());
+        List<LengthConstraint> baseType2Lengths = baseType1.getLengthConstraints();
         assertEquals(1, baseType2Lengths.size());
         length = baseType2Lengths.get(0);
         assertEquals(6L, length.getMin());
         assertEquals(10L, length.getMax());
-        assertTrue(baseType1.getRanges().isEmpty());
+        assertTrue(baseType1.getRangeConstraints().isEmpty());
 
         ExtendedType baseType2 = (ExtendedType) baseType1.getBaseType();
         QName baseType2QName = baseType2.getQName();
         assertEquals("string-ext1", baseType2QName.getLocalName());
-        assertEquals("t", baseType2QName.getPrefix());
-        assertEquals(typesNS, baseType2QName.getNamespace());
-        assertEquals(typesRev, baseType2QName.getRevision());
+        assertEquals("bar", baseType2QName.getPrefix());
+        assertEquals(barNS, baseType2QName.getNamespace());
+        assertEquals(barRev, baseType2QName.getRevision());
         assertNull(baseType2.getUnits());
         assertNull(baseType2.getDefaultValue());
-        List<PatternConstraint> patterns = baseType2.getPatterns();
+        List<PatternConstraint> patterns = baseType2.getPatternConstraints();
         assertEquals(1, patterns.size());
         PatternConstraint pattern = patterns.iterator().next();
         assertEquals("[a-k]*", pattern.getRegularExpression());
-        List<LengthConstraint> baseType3Lengths = baseType2.getLengths();
+        List<LengthConstraint> baseType3Lengths = baseType2.getLengthConstraints();
         assertEquals(1, baseType3Lengths.size());
         length = baseType3Lengths.get(0);
         assertEquals(5L, length.getMin());
         assertEquals(11L, length.getMax());
-        assertTrue(baseType2.getRanges().isEmpty());
+        assertTrue(baseType2.getRangeConstraints().isEmpty());
 
         assertTrue(baseType2.getBaseType() instanceof StringType);
     }
 
     @Test
     public void testTypedefDecimal1() {
-        Module testModule = TestUtils.findModule(modules, "nodes");
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("decimal-leaf");
+        Module foo = TestUtils.findModule(modules, "foo");
+        LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName("decimal-leaf");
 
         ExtendedType type = (ExtendedType) testleaf.getType();
         QName typeQName = type.getQName();
         assertEquals("my-decimal-type", typeQName.getLocalName());
-        assertEquals("n", typeQName.getPrefix());
-        assertEquals(nodesNS, typeQName.getNamespace());
-        assertEquals(nodesRev, typeQName.getRevision());
+        assertEquals("foo", typeQName.getPrefix());
+        assertEquals(fooNS, typeQName.getNamespace());
+        assertEquals(fooRev, typeQName.getRevision());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         assertEquals(4, (int) type.getFractionDigits());
-        assertTrue(type.getLengths().isEmpty());
-        assertTrue(type.getPatterns().isEmpty());
-        assertTrue(type.getRanges().isEmpty());
+        assertTrue(type.getLengthConstraints().isEmpty());
+        assertTrue(type.getPatternConstraints().isEmpty());
+        assertTrue(type.getRangeConstraints().isEmpty());
 
         ExtendedType typeBase = (ExtendedType) type.getBaseType();
         QName typeBaseQName = typeBase.getQName();
         assertEquals("my-decimal-type", typeBaseQName.getLocalName());
-        assertEquals("t", typeBaseQName.getPrefix());
-        assertEquals(typesNS, typeBaseQName.getNamespace());
-        assertEquals(typesRev, typeBaseQName.getRevision());
+        assertEquals("bar", typeBaseQName.getPrefix());
+        assertEquals(barNS, typeBaseQName.getNamespace());
+        assertEquals(barRev, typeBaseQName.getRevision());
         assertNull(typeBase.getUnits());
         assertNull(typeBase.getDefaultValue());
         assertNull(typeBase.getFractionDigits());
-        assertTrue(typeBase.getLengths().isEmpty());
-        assertTrue(typeBase.getPatterns().isEmpty());
-        assertTrue(typeBase.getRanges().isEmpty());
+        assertTrue(typeBase.getLengthConstraints().isEmpty());
+        assertTrue(typeBase.getPatternConstraints().isEmpty());
+        assertTrue(typeBase.getRangeConstraints().isEmpty());
 
         Decimal64 decimal = (Decimal64) typeBase.getBaseType();
         assertEquals(6, (int) decimal.getFractionDigits());
@@ -454,21 +476,21 @@ public class YangParserTest {
 
     @Test
     public void testTypedefDecimal2() {
-        Module testModule = TestUtils.findModule(modules, "nodes");
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("decimal-leaf2");
+        Module foo = TestUtils.findModule(modules, "foo");
+        LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName("decimal-leaf2");
 
         ExtendedType type = (ExtendedType) testleaf.getType();
         QName typeQName = type.getQName();
         assertEquals("my-decimal-type", typeQName.getLocalName());
-        assertEquals("t", typeQName.getPrefix());
-        assertEquals(typesNS, typeQName.getNamespace());
-        assertEquals(typesRev, typeQName.getRevision());
+        assertEquals("bar", typeQName.getPrefix());
+        assertEquals(barNS, typeQName.getNamespace());
+        assertEquals(barRev, typeQName.getRevision());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         assertNull(type.getFractionDigits());
-        assertTrue(type.getLengths().isEmpty());
-        assertTrue(type.getPatterns().isEmpty());
-        assertTrue(type.getRanges().isEmpty());
+        assertTrue(type.getLengthConstraints().isEmpty());
+        assertTrue(type.getPatternConstraints().isEmpty());
+        assertTrue(type.getRangeConstraints().isEmpty());
 
         Decimal64 baseTypeDecimal = (Decimal64) type.getBaseType();
         assertEquals(6, (int) baseTypeDecimal.getFractionDigits());
@@ -476,34 +498,34 @@ public class YangParserTest {
 
     @Test
     public void testTypedefUnion() {
-        Module testModule = TestUtils.findModule(modules, "nodes");
-        LeafSchemaNode unionleaf = (LeafSchemaNode) testModule.getDataChildByName("union-leaf");
+        Module foo = TestUtils.findModule(modules, "foo");
+        LeafSchemaNode unionleaf = (LeafSchemaNode) foo.getDataChildByName("union-leaf");
 
         ExtendedType type = (ExtendedType) unionleaf.getType();
         QName typeQName = type.getQName();
         assertEquals("my-union-ext", typeQName.getLocalName());
-        assertEquals("t", typeQName.getPrefix());
-        assertEquals(typesNS, typeQName.getNamespace());
-        assertEquals(typesRev, typeQName.getRevision());
+        assertEquals("bar", typeQName.getPrefix());
+        assertEquals(barNS, typeQName.getNamespace());
+        assertEquals(barRev, typeQName.getRevision());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         assertNull(type.getFractionDigits());
-        assertTrue(type.getLengths().isEmpty());
-        assertTrue(type.getPatterns().isEmpty());
-        assertTrue(type.getRanges().isEmpty());
+        assertTrue(type.getLengthConstraints().isEmpty());
+        assertTrue(type.getPatternConstraints().isEmpty());
+        assertTrue(type.getRangeConstraints().isEmpty());
 
         ExtendedType baseType = (ExtendedType) type.getBaseType();
         QName baseTypeQName = baseType.getQName();
         assertEquals("my-union", baseTypeQName.getLocalName());
-        assertEquals("t", baseTypeQName.getPrefix());
-        assertEquals(typesNS, baseTypeQName.getNamespace());
-        assertEquals(typesRev, baseTypeQName.getRevision());
+        assertEquals("bar", baseTypeQName.getPrefix());
+        assertEquals(barNS, baseTypeQName.getNamespace());
+        assertEquals(barRev, baseTypeQName.getRevision());
         assertNull(baseType.getUnits());
         assertNull(baseType.getDefaultValue());
         assertNull(baseType.getFractionDigits());
-        assertTrue(baseType.getLengths().isEmpty());
-        assertTrue(baseType.getPatterns().isEmpty());
-        assertTrue(baseType.getRanges().isEmpty());
+        assertTrue(baseType.getLengthConstraints().isEmpty());
+        assertTrue(baseType.getPatternConstraints().isEmpty());
+        assertTrue(baseType.getRangeConstraints().isEmpty());
 
         UnionType unionType = (UnionType) baseType.getBaseType();
         List<TypeDefinition<?>> unionTypes = unionType.getTypes();
@@ -512,15 +534,15 @@ public class YangParserTest {
         ExtendedType unionType1 = (ExtendedType) unionTypes.get(0);
         QName unionType1QName = baseType.getQName();
         assertEquals("my-union", unionType1QName.getLocalName());
-        assertEquals("t", unionType1QName.getPrefix());
-        assertEquals(typesNS, unionType1QName.getNamespace());
-        assertEquals(typesRev, unionType1QName.getRevision());
+        assertEquals("bar", unionType1QName.getPrefix());
+        assertEquals(barNS, unionType1QName.getNamespace());
+        assertEquals(barRev, unionType1QName.getRevision());
         assertNull(unionType1.getUnits());
         assertNull(unionType1.getDefaultValue());
         assertNull(unionType1.getFractionDigits());
-        assertTrue(unionType1.getLengths().isEmpty());
-        assertTrue(unionType1.getPatterns().isEmpty());
-        List<RangeConstraint> ranges = unionType1.getRanges();
+        assertTrue(unionType1.getLengthConstraints().isEmpty());
+        assertTrue(unionType1.getPatternConstraints().isEmpty());
+        List<RangeConstraint> ranges = unionType1.getRangeConstraints();
         assertEquals(1, ranges.size());
         RangeConstraint range = ranges.get(0);
         assertEquals(1L, range.getMin());
@@ -532,34 +554,34 @@ public class YangParserTest {
 
     @Test
     public void testNestedUnionResolving() {
-        Module testModule = TestUtils.findModule(modules, "nodes");
-        LeafSchemaNode testleaf = (LeafSchemaNode) testModule.getDataChildByName("custom-union-leaf");
+        Module foo = TestUtils.findModule(modules, "foo");
+        LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName("custom-union-leaf");
 
         ExtendedType type = (ExtendedType) testleaf.getType();
         QName testleafTypeQName = type.getQName();
-        assertEquals(customNS, testleafTypeQName.getNamespace());
-        assertEquals(customRev, testleafTypeQName.getRevision());
-        assertEquals("c", testleafTypeQName.getPrefix());
+        assertEquals(bazNS, testleafTypeQName.getNamespace());
+        assertEquals(bazRev, testleafTypeQName.getRevision());
+        assertEquals("baz", testleafTypeQName.getPrefix());
         assertEquals("union1", testleafTypeQName.getLocalName());
         assertNull(type.getUnits());
         assertNull(type.getDefaultValue());
         assertNull(type.getFractionDigits());
-        assertTrue(type.getLengths().isEmpty());
-        assertTrue(type.getPatterns().isEmpty());
-        assertTrue(type.getRanges().isEmpty());
+        assertTrue(type.getLengthConstraints().isEmpty());
+        assertTrue(type.getPatternConstraints().isEmpty());
+        assertTrue(type.getRangeConstraints().isEmpty());
 
         ExtendedType typeBase = (ExtendedType) type.getBaseType();
         QName typeBaseQName = typeBase.getQName();
-        assertEquals(customNS, typeBaseQName.getNamespace());
-        assertEquals(customRev, typeBaseQName.getRevision());
-        assertEquals("c", typeBaseQName.getPrefix());
+        assertEquals(bazNS, typeBaseQName.getNamespace());
+        assertEquals(bazRev, typeBaseQName.getRevision());
+        assertEquals("baz", typeBaseQName.getPrefix());
         assertEquals("union2", typeBaseQName.getLocalName());
         assertNull(typeBase.getUnits());
         assertNull(typeBase.getDefaultValue());
         assertNull(typeBase.getFractionDigits());
-        assertTrue(typeBase.getLengths().isEmpty());
-        assertTrue(typeBase.getPatterns().isEmpty());
-        assertTrue(typeBase.getRanges().isEmpty());
+        assertTrue(typeBase.getLengthConstraints().isEmpty());
+        assertTrue(typeBase.getPatternConstraints().isEmpty());
+        assertTrue(typeBase.getRangeConstraints().isEmpty());
 
         UnionType union = (UnionType) typeBase.getBaseType();
         List<TypeDefinition<?>> unionTypes = union.getTypes();
@@ -569,16 +591,16 @@ public class YangParserTest {
 
         ExtendedType unionType1 = (ExtendedType) unionTypes.get(1);
         QName uniontType1QName = unionType1.getQName();
-        assertEquals(typesNS, uniontType1QName.getNamespace());
-        assertEquals(typesRev, uniontType1QName.getRevision());
-        assertEquals("t", uniontType1QName.getPrefix());
+        assertEquals(barNS, uniontType1QName.getNamespace());
+        assertEquals(barRev, uniontType1QName.getRevision());
+        assertEquals("bar", uniontType1QName.getPrefix());
         assertEquals("nested-union2", uniontType1QName.getLocalName());
         assertNull(unionType1.getUnits());
         assertNull(unionType1.getDefaultValue());
         assertNull(unionType1.getFractionDigits());
-        assertTrue(unionType1.getLengths().isEmpty());
-        assertTrue(unionType1.getPatterns().isEmpty());
-        assertTrue(unionType1.getRanges().isEmpty());
+        assertTrue(unionType1.getLengthConstraints().isEmpty());
+        assertTrue(unionType1.getPatternConstraints().isEmpty());
+        assertTrue(unionType1.getRangeConstraints().isEmpty());
 
         UnionType nestedUnion = (UnionType) unionType1.getBaseType();
         List<TypeDefinition<?>> nestedUnion2Types = nestedUnion.getTypes();
@@ -588,29 +610,29 @@ public class YangParserTest {
 
         ExtendedType myUnionExt = (ExtendedType) nestedUnion2Types.get(1);
         QName myUnionExtQName = myUnionExt.getQName();
-        assertEquals(typesNS, myUnionExtQName.getNamespace());
-        assertEquals(typesRev, myUnionExtQName.getRevision());
-        assertEquals("t", myUnionExtQName.getPrefix());
+        assertEquals(barNS, myUnionExtQName.getNamespace());
+        assertEquals(barRev, myUnionExtQName.getRevision());
+        assertEquals("bar", myUnionExtQName.getPrefix());
         assertEquals("my-union-ext", myUnionExtQName.getLocalName());
         assertNull(myUnionExt.getUnits());
         assertNull(myUnionExt.getDefaultValue());
         assertNull(myUnionExt.getFractionDigits());
-        assertTrue(myUnionExt.getLengths().isEmpty());
-        assertTrue(myUnionExt.getPatterns().isEmpty());
-        assertTrue(myUnionExt.getRanges().isEmpty());
+        assertTrue(myUnionExt.getLengthConstraints().isEmpty());
+        assertTrue(myUnionExt.getPatternConstraints().isEmpty());
+        assertTrue(myUnionExt.getRangeConstraints().isEmpty());
 
         ExtendedType myUnion = (ExtendedType) myUnionExt.getBaseType();
         QName myUnionQName = myUnion.getQName();
-        assertEquals(typesNS, myUnionQName.getNamespace());
-        assertEquals(typesRev, myUnionQName.getRevision());
-        assertEquals("t", myUnionQName.getPrefix());
+        assertEquals(barNS, myUnionQName.getNamespace());
+        assertEquals(barRev, myUnionQName.getRevision());
+        assertEquals("bar", myUnionQName.getPrefix());
         assertEquals("my-union", myUnionQName.getLocalName());
         assertNull(myUnion.getUnits());
         assertNull(myUnion.getDefaultValue());
         assertNull(myUnion.getFractionDigits());
-        assertTrue(myUnion.getLengths().isEmpty());
-        assertTrue(myUnion.getPatterns().isEmpty());
-        assertTrue(myUnion.getRanges().isEmpty());
+        assertTrue(myUnion.getLengthConstraints().isEmpty());
+        assertTrue(myUnion.getPatternConstraints().isEmpty());
+        assertTrue(myUnion.getRangeConstraints().isEmpty());
 
         UnionType myUnionBase = (UnionType) myUnion.getBaseType();
         List<TypeDefinition<?>> myUnionBaseTypes = myUnionBase.getTypes();
@@ -620,16 +642,16 @@ public class YangParserTest {
 
         ExtendedType int16Ext = (ExtendedType) myUnionBaseTypes.get(0);
         QName int16ExtQName = int16Ext.getQName();
-        assertEquals(typesNS, int16ExtQName.getNamespace());
-        assertEquals(typesRev, int16ExtQName.getRevision());
-        assertEquals("t", int16ExtQName.getPrefix());
+        assertEquals(barNS, int16ExtQName.getNamespace());
+        assertEquals(barRev, int16ExtQName.getRevision());
+        assertEquals("bar", int16ExtQName.getPrefix());
         assertEquals("int16", int16ExtQName.getLocalName());
         assertNull(int16Ext.getUnits());
         assertNull(int16Ext.getDefaultValue());
         assertNull(int16Ext.getFractionDigits());
-        assertTrue(int16Ext.getLengths().isEmpty());
-        assertTrue(int16Ext.getPatterns().isEmpty());
-        List<RangeConstraint> ranges = int16Ext.getRanges();
+        assertTrue(int16Ext.getLengthConstraints().isEmpty());
+        assertTrue(int16Ext.getPatternConstraints().isEmpty());
+        List<RangeConstraint> ranges = int16Ext.getRangeConstraints();
         assertEquals(1, ranges.size());
         RangeConstraint range = ranges.get(0);
         assertEquals(1L, range.getMin());
@@ -640,8 +662,8 @@ public class YangParserTest {
 
     @Test
     public void testChoice() {
-        Module testModule = TestUtils.findModule(modules, "nodes");
-        ContainerSchemaNode transfer = (ContainerSchemaNode) testModule.getDataChildByName("transfer");
+        Module foo = TestUtils.findModule(modules, "foo");
+        ContainerSchemaNode transfer = (ContainerSchemaNode) foo.getDataChildByName("transfer");
         ChoiceNode how = (ChoiceNode) transfer.getDataChildByName("how");
         Set<ChoiceCaseNode> cases = how.getCases();
         assertEquals(5, cases.size());
@@ -662,17 +684,16 @@ public class YangParserTest {
 
     @Test
     public void testDeviation() {
-        Module testModule = TestUtils.findModule(modules, "nodes");
-        Set<Deviation> deviations = testModule.getDeviations();
+        Module foo = TestUtils.findModule(modules, "foo");
+        Set<Deviation> deviations = foo.getDeviations();
         assertEquals(1, deviations.size());
         Deviation dev = deviations.iterator().next();
-
         assertEquals("system/user ref", dev.getReference());
 
-        List<QName> path = new ArrayList<QName>();
-        path.add(new QName(typesNS, typesRev, "t", "interfaces"));
-        path.add(new QName(typesNS, typesRev, "t", "ifEntry"));
-        SchemaPath expectedPath = new SchemaPath(path, true);
+        List<QName> path = new ArrayList<>();
+        path.add(new QName(barNS, barRev, "br", "interfaces"));
+        path.add(new QName(barNS, barRev, "br", "ifEntry"));
+        SchemaPath expectedPath = SchemaPath.create(path, true);
 
         assertEquals(expectedPath, dev.getTargetPath());
         assertEquals(Deviate.ADD, dev.getDeviate());
@@ -680,8 +701,8 @@ public class YangParserTest {
 
     @Test
     public void testUnknownNode() {
-        Module testModule = TestUtils.findModule(modules, "custom");
-        ContainerSchemaNode network = (ContainerSchemaNode) testModule.getDataChildByName("network");
+        Module baz = TestUtils.findModule(modules, "baz");
+        ContainerSchemaNode network = (ContainerSchemaNode) baz.getDataChildByName("network");
         List<UnknownSchemaNode> unknownNodes = network.getUnknownSchemaNodes();
         assertEquals(1, unknownNodes.size());
         UnknownSchemaNode unknownNode = unknownNodes.get(0);
@@ -691,15 +712,15 @@ public class YangParserTest {
 
     @Test
     public void testFeature() {
-        Module testModule = TestUtils.findModule(modules, "custom");
-        Set<FeatureDefinition> features = testModule.getFeatures();
+        Module baz = TestUtils.findModule(modules, "baz");
+        Set<FeatureDefinition> features = baz.getFeatures();
         assertEquals(1, features.size());
     }
 
     @Test
     public void testExtension() {
-        Module testModule = TestUtils.findModule(modules, "custom");
-        List<ExtensionDefinition> extensions = testModule.getExtensionSchemaNodes();
+        Module baz = TestUtils.findModule(modules, "baz");
+        List<ExtensionDefinition> extensions = baz.getExtensionSchemaNodes();
         assertEquals(1, extensions.size());
         ExtensionDefinition extension = extensions.get(0);
         assertEquals("name", extension.getArgument());
@@ -708,17 +729,17 @@ public class YangParserTest {
 
     @Test
     public void testNotification() {
-        Module testModule = TestUtils.findModule(modules, "custom");
+        Module baz = TestUtils.findModule(modules, "baz");
         String expectedPrefix = "c";
 
-        Set<NotificationDefinition> notifications = testModule.getNotifications();
+        Set<NotificationDefinition> notifications = baz.getNotifications();
         assertEquals(1, notifications.size());
 
         NotificationDefinition notification = notifications.iterator().next();
         // test SchemaNode args
-        QName expectedQName = new QName(customNS, customRev, expectedPrefix, "event");
+        QName expectedQName = new QName(bazNS, bazRev, expectedPrefix, "event");
         assertEquals(expectedQName, notification.getQName());
-        SchemaPath expectedPath = TestUtils.createPath(true, customNS, customRev, expectedPrefix, "event");
+        SchemaPath expectedPath = TestUtils.createPath(true, bazNS, bazRev, expectedPrefix, "event");
         assertEquals(expectedPath, notification.getPath());
         assertNull(notification.getDescription());
         assertNull(notification.getReference());
@@ -732,48 +753,42 @@ public class YangParserTest {
 
         LeafSchemaNode eventClass = (LeafSchemaNode) notification.getDataChildByName("event-class");
         assertTrue(eventClass.getType() instanceof StringType);
-        AnyXmlSchemaNode reportingEntity = (AnyXmlSchemaNode) notification.getDataChildByName("reporting-entity");
-        assertNotNull(reportingEntity);
         LeafSchemaNode severity = (LeafSchemaNode) notification.getDataChildByName("severity");
         assertTrue(severity.getType() instanceof StringType);
     }
 
     @Test
     public void testRpc() {
-        Module testModule = TestUtils.findModule(modules, "custom");
+        Module baz = TestUtils.findModule(modules, "baz");
 
-        Set<RpcDefinition> rpcs = testModule.getRpcs();
+        Set<RpcDefinition> rpcs = baz.getRpcs();
         assertEquals(1, rpcs.size());
 
         RpcDefinition rpc = rpcs.iterator().next();
         assertEquals("Retrieve all or part of a specified configuration.", rpc.getDescription());
         assertEquals("RFC 6241, Section 7.1", rpc.getReference());
-
-        ContainerSchemaNode input = rpc.getInput();
-        assertNotNull(input.getDataChildByName("source"));
-        assertNotNull(input.getDataChildByName("filter"));
-        ContainerSchemaNode output = rpc.getOutput();
-        assertNotNull(output.getDataChildByName("data"));
     }
 
     @Test
     public void testTypePath() throws ParseException {
-        Module test = TestUtils.findModule(modules, "types");
-        Set<TypeDefinition<?>> types = test.getTypeDefinitions();
+        Module bar = TestUtils.findModule(modules, "bar");
+        Set<TypeDefinition<?>> types = bar.getTypeDefinitions();
 
         // int32-ext1
         ExtendedType int32ext1 = (ExtendedType) TestUtils.findTypedef(types, "int32-ext1");
         QName int32TypedefQName = int32ext1.getQName();
 
-        assertEquals(typesNS, int32TypedefQName.getNamespace());
-        assertEquals(typesRev, int32TypedefQName.getRevision());
-        assertEquals("t", int32TypedefQName.getPrefix());
+        assertEquals(barNS, int32TypedefQName.getNamespace());
+        assertEquals(barRev, int32TypedefQName.getRevision());
+        assertEquals("bar", int32TypedefQName.getPrefix());
         assertEquals("int32-ext1", int32TypedefQName.getLocalName());
 
         SchemaPath typeSchemaPath = int32ext1.getPath();
-        List<QName> typePath = typeSchemaPath.getPath();
-        assertEquals(1, typePath.size());
-        assertEquals(int32TypedefQName, typePath.get(0));
+        Iterable<QName> typePath = typeSchemaPath.getPathFromRoot();
+        Iterator<QName> typePathIt = typePath.iterator();
+        assertEquals(int32TypedefQName, typePathIt.next());
+        assertFalse(typePathIt.hasNext());
+
 
         // int32-ext1/int32
         Int32 int32 = (Int32) int32ext1.getBaseType();
@@ -782,22 +797,23 @@ public class YangParserTest {
 
     @Test
     public void testTypePath2() throws ParseException {
-        Module test = TestUtils.findModule(modules, "types");
-        Set<TypeDefinition<?>> types = test.getTypeDefinitions();
+        Module bar = TestUtils.findModule(modules, "bar");
+        Set<TypeDefinition<?>> types = bar.getTypeDefinitions();
 
         // my-decimal-type
         ExtendedType myDecType = (ExtendedType) TestUtils.findTypedef(types, "my-decimal-type");
         QName myDecTypeQName = myDecType.getQName();
 
-        assertEquals(typesNS, myDecTypeQName.getNamespace());
-        assertEquals(typesRev, myDecTypeQName.getRevision());
-        assertEquals("t", myDecTypeQName.getPrefix());
+        assertEquals(barNS, myDecTypeQName.getNamespace());
+        assertEquals(barRev, myDecTypeQName.getRevision());
+        assertEquals("bar", myDecTypeQName.getPrefix());
         assertEquals("my-decimal-type", myDecTypeQName.getLocalName());
 
         SchemaPath typeSchemaPath = myDecType.getPath();
-        List<QName> typePath = typeSchemaPath.getPath();
-        assertEquals(1, typePath.size());
-        assertEquals(myDecTypeQName, typePath.get(0));
+        Iterable<QName> typePath = typeSchemaPath.getPathFromRoot();
+        Iterator<QName> typePathIt = typePath.iterator();
+        assertEquals(myDecTypeQName, typePathIt.next());
+        assertFalse(typePathIt.hasNext());
 
         // my-base-int32-type/int32
         Decimal64 dec64 = (Decimal64) myDecType.getBaseType();
@@ -809,10 +825,148 @@ public class YangParserTest {
         assertEquals("decimal64", dec64QName.getLocalName());
 
         SchemaPath dec64SchemaPath = dec64.getPath();
-        List<QName> dec64Path = dec64SchemaPath.getPath();
-        assertEquals(2, dec64Path.size());
-        assertEquals(myDecTypeQName, dec64Path.get(0));
-        assertEquals(dec64QName, dec64Path.get(1));
+        Iterable<QName> dec64Path = dec64SchemaPath.getPathFromRoot();
+        Iterator<QName> dec64PathIt = dec64Path.iterator();
+        assertEquals(myDecTypeQName, dec64PathIt.next());
+        assertEquals(dec64QName, dec64PathIt.next());
+        assertFalse(dec64PathIt.hasNext());
+    }
+
+    @Test
+    public void testParseMethod1() throws Exception {
+        File yangFile = new File(getClass().getResource("/parse-methods/m1.yang").toURI());
+        File dependenciesDir = new File(getClass().getResource("/parse-methods").toURI());
+        YangContextParser parser = new YangParserImpl();
+        modules = parser.parseFile(yangFile, dependenciesDir).getModules();
+        assertEquals(6, modules.size());
+    }
+
+    @Test
+    public void testParseMethod2() throws Exception {
+        File yangFile = new File(getClass().getResource("/parse-methods/m1.yang").toURI());
+        File dependenciesDir = new File(getClass().getResource("/parse-methods/dependencies").toURI());
+        YangContextParser parser = new YangParserImpl();
+        modules = parser.parseFile(yangFile, dependenciesDir).getModules();
+        assertEquals(6, modules.size());
+    }
+
+    @Test
+    public void testSorting() throws Exception {
+        // Correct order: m2, m4, m6, m8, m7, m6, m3, m1
+        File yangFile = new File(getClass().getResource("/sorting-test/m1.yang").toURI());
+        File dependenciesDir = new File(getClass().getResource("/sorting-test").toURI());
+        YangContextParser parser = new YangParserImpl();
+        modules = parser.parseFile(yangFile, dependenciesDir).getModules();
+        SchemaContext ctx = new SchemaContextImpl(modules, Collections.<ModuleIdentifier, String>emptyMap());
+        checkOrder(modules);
+        assertSetEquals(modules, ctx.getModules());
+
+        // ##########
+        parser = new YangParserImpl();
+        final File testDir = dependenciesDir;
+        final String[] fileList = testDir.list();
+        final List<File> testFiles = new ArrayList<>();
+        if (fileList == null) {
+            throw new FileNotFoundException(dependenciesDir.getAbsolutePath());
+        }
+        for (String fileName : fileList) {
+            testFiles.add(new File(testDir, fileName));
+        }
+        Set<Module> newModules = parser.parseFiles(testFiles).getModules();
+        assertSetEquals(newModules, modules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
+        assertSetEquals(newModules, ctx.getModules());
+        // ##########
+        newModules = parser.parseFiles(testFiles, null).getModules();
+        assertSetEquals(newModules, modules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
+        assertSetEquals(newModules, ctx.getModules());
+        // ##########
+        List<InputStream> streams = new ArrayList<>();
+        for (File f : testFiles) {
+            streams.add(new FileInputStream(f));
+        }
+        newModules = parser.parseSources(BuilderUtils.filesToByteSources(testFiles)).getModules();
+        assertSetEquals(newModules, modules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
+        assertSetEquals(newModules, ctx.getModules());
+        // ##########
+        streams.clear();
+        for (File f : testFiles) {
+            streams.add(new FileInputStream(f));
+        }
+        newModules = parser.parseSources(BuilderUtils.filesToByteSources(testFiles), null).getModules();
+        assertSetEquals(newModules, modules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
+        assertSetEquals(newModules, ctx.getModules());
+        // ##########
+        Map<File, Module> mapped = parser.parseYangModelsMapped(testFiles);
+        newModules = new LinkedHashSet<>(mapped.values());
+        assertSetEquals(newModules, modules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
+        assertSetEquals(newModules, ctx.getModules());
+        // ##########
+        streams.clear();
+        for (File f : testFiles) {
+            streams.add(new FileInputStream(f));
+        }
+        Map<InputStream, Module> mappedStreams = parser.parseYangModelsFromStreamsMapped(streams);
+        newModules = new LinkedHashSet<>(mappedStreams.values());
+        assertSetEquals(newModules, modules);
+        ctx = new SchemaContextImpl(newModules, Collections.<ModuleIdentifier, String>emptyMap());
+        assertSetEquals(newModules, ctx.getModules());
+    }
+
+    private void checkOrder(final Collection<Module> modules) {
+        Iterator<Module> it = modules.iterator();
+        Module m = it.next();
+        assertEquals("m2", m.getName());
+        m = it.next();
+        assertEquals("m4", m.getName());
+        m = it.next();
+        assertEquals("m6", m.getName());
+        m = it.next();
+        assertEquals("m8", m.getName());
+        m = it.next();
+        assertEquals("m7", m.getName());
+        m = it.next();
+        assertEquals("m5", m.getName());
+        m = it.next();
+        assertEquals("m3", m.getName());
+        m = it.next();
+        assertEquals("m1", m.getName());
+    }
+
+    private void assertSetEquals(final Set<Module> s1, final Set<Module> s2) {
+        assertEquals(s1, s2);
+        Iterator<Module> it = s1.iterator();
+        for (Module m : s2) {
+            assertEquals(m, it.next());
+        }
+    }
+
+    @Test
+    public void testSubmodules() throws Exception {
+        URI yangFilePath = getClass().getResource("/submodule-test/subfoo.yang").toURI();
+        URI directoryPath = getClass().getResource("/model").toURI();
+
+        File directory = new File(directoryPath);
+        File yangFile = new File(yangFilePath);
+
+        Set<Module> modules = new YangParserImpl().parseFile(yangFile, directory).getModules();
+        assertEquals(3, modules.size());
+
+        Module foo = TestUtils.findModule(modules, "foo");
+
+        DataSchemaNode id = foo.getDataChildByName("id");
+        assertNotNull(id);
+        DataSchemaNode subExt = foo.getDataChildByName("sub-ext");
+        assertNotNull(subExt);
+        DataSchemaNode subTransfer = foo.getDataChildByName("sub-transfer");
+        assertNotNull(subTransfer);
+
+        assertEquals(2, foo.getExtensionSchemaNodes().size());
+        assertEquals(2, foo.getAugmentations().size());
     }
 
 }