Degrade DataNodeContainer.getChildNodes() from Set to Collection
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / UsesAugmentTest.java
index c713f759f1c9e79089067acd45e2a716ea2538ab..010570dc10b9d4d8d2402f10cefb77e1f38ac653 100644 (file)
@@ -7,14 +7,21 @@
  */
 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.text.SimpleDateFormat;
+import java.util.Collection;
 import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
@@ -39,8 +46,6 @@ 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 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");
@@ -126,20 +131,20 @@ public class UsesAugmentTest {
         assertNotNull(pcreq);
         QName expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "pcreq");
         path.offer(expectedQName);
-        SchemaPath expectedPath = new SchemaPath(path, true);
+        SchemaPath expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, pcreq.getPath());
-        Set<DataSchemaNode> childNodes = pcreq.getChildNodes();
+        Collection<DataSchemaNode> childNodes = pcreq.getChildNodes();
         assertEquals(4, childNodes.size());
         // * |-- leaf version
         LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName("version");
         assertNotNull(version);
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "version");
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, version.getPath());
         expectedQName = new QName(GD_NS, GD_REV, GD_PREF, "protocol-version");
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(Lists.newArrayList(expectedQName), true);
+        expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
         assertEquals(expectedPath, version.getType().getPath());
         assertEquals(Uint8.getInstance(), version.getType().getBaseType());
         assertTrue(version.isAddedByUses());
@@ -151,14 +156,14 @@ public class UsesAugmentTest {
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, type.getPath());
         expectedQName = new QName(GD_NS, GD_REV, GD_PREF, "int-ext");
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(Lists.newArrayList(expectedQName), true);
+        expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
         assertEquals(expectedPath, type.getType().getPath());
         UnionType union = (UnionType)type.getType().getBaseType();
-        assertEquals(BaseTypes.schemaPath(BaseTypes.constructQName("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");
@@ -168,7 +173,7 @@ public class UsesAugmentTest {
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, requests.getPath());
         assertFalse(requests.isAddedByUses());
         childNodes = requests.getChildNodes();
@@ -178,7 +183,7 @@ public class UsesAugmentTest {
         assertNotNull(rp);
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "rp");
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, rp.getPath());
         assertFalse(rp.isAddedByUses());
         childNodes = rp.getChildNodes();
@@ -189,7 +194,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, processingRule.getPath());
         assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
@@ -200,7 +205,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, ignore.getPath());
         assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
@@ -211,11 +216,11 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, priority.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, priority.getPath());
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "uint8");
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         // TODO
         //assertEquals(expectedPath, priority.getType().getPath());
         assertEquals(Uint8.getInstance(), priority.getType().getBaseType());
@@ -228,7 +233,7 @@ public class UsesAugmentTest {
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, box.getPath());
         assertTrue(box.isAddedByUses());
         // * |-- |-- |-- |-- container order
@@ -237,7 +242,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "order");
         assertEquals(expectedQName, order.getQName());
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, order.getPath());
         assertTrue(order.isAddedByUses());
         assertTrue(order.isAugmenting());
@@ -248,7 +253,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "delete");
         assertEquals(expectedQName, delete.getQName());
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, delete.getPath());
         assertEquals(Uint32.getInstance(), delete.getType());
         assertTrue(delete.isAddedByUses());
@@ -259,7 +264,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, setup.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, setup.getPath());
         assertEquals(Uint32.getInstance(), setup.getType());
         assertTrue(setup.isAddedByUses());
@@ -273,7 +278,7 @@ public class UsesAugmentTest {
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath = new SchemaPath(path, true);
+        expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, pke.getPath());
         assertFalse(pke.isAddedByUses());
         // * |-- |-- |-- path-key
@@ -282,7 +287,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "path-key");
         assertEquals(expectedQName, pathKey.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, pathKey.getPath());
         assertFalse(pathKey.isAddedByUses());
         assertEquals(3, pathKey.getChildNodes().size());
@@ -292,7 +297,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, processingRule.getPath());
         assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
@@ -303,7 +308,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, ignore.getPath());
         assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
@@ -314,7 +319,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, pathKeys.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, pathKeys.getPath());
         assertTrue(pathKeys.isAddedByUses());
         childNodes = pathKeys.getChildNodes();
@@ -325,7 +330,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "version");
         assertEquals(expectedQName, version.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, version.getPath());
         assertTrue(version.getType() instanceof ExtendedType);
         assertEquals(Uint8.getInstance(), version.getType().getBaseType());
@@ -338,7 +343,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, type.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, type.getPath());
         assertTrue(type.getType() instanceof ExtendedType);
         assertTrue(type.isAddedByUses());
@@ -353,7 +358,7 @@ public class UsesAugmentTest {
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, sc.getPath());
         assertFalse(sc.isAddedByUses());
         // * |-- |-- |-- container p2p
@@ -362,7 +367,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "p2p");
         assertEquals(expectedQName, p2p.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, p2p.getPath());
         assertFalse(p2p.isAddedByUses());
         // * |-- |-- |-- |-- container endpoints
@@ -371,7 +376,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "endpoints");
         assertEquals(expectedQName, endpoints.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, endpoints.getPath());
         assertFalse(endpoints.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf processing-rule
@@ -380,7 +385,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, processingRule.getPath());
         assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
@@ -391,7 +396,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, ignore.getPath());
         assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
@@ -402,7 +407,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, box.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, box.getPath());
         assertTrue(box.isAddedByUses());
         // * |-- |-- |-- |-- |-- choice address-family
@@ -412,7 +417,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, af.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, af.getPath());
         assertTrue(af.isAddedByUses());
         // * |-- |-- |-- |-- container reported-route
@@ -423,7 +428,7 @@ public class UsesAugmentTest {
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, reportedRoute.getPath());
         assertFalse(reportedRoute.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf processing-rule
@@ -432,7 +437,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, processingRule.getPath());
         assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
@@ -443,7 +448,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, ignore.getPath());
         assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
@@ -454,7 +459,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, subobjects.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, subobjects.getPath());
         assertTrue(subobjects.isAddedByUses());
         // * |-- |-- |-- |-- |-- container bandwidth
@@ -464,7 +469,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, bandwidth.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, bandwidth.getPath());
         assertFalse(bandwidth.isAddedByUses());
         // * |-- |-- |-- |-- container bandwidth
@@ -475,7 +480,7 @@ public class UsesAugmentTest {
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, bandwidth.getPath());
         assertTrue(bandwidth.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf processing-rule
@@ -484,7 +489,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, processingRule.getPath());
         assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
@@ -495,7 +500,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, ignore.getPath());
         assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
@@ -506,7 +511,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, bandwidth.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, bandwidthInner.getPath());
         assertTrue(bandwidthInner.isAddedByUses());
         // * |-- list svec
@@ -520,7 +525,7 @@ public class UsesAugmentTest {
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, svec.getPath());
         assertFalse(svec.isAddedByUses());
         // * |-- |-- leaf link-diverse
@@ -529,7 +534,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "link-diverse");
         assertEquals(expectedQName, linkDiverse.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, linkDiverse.getPath());
         assertEquals(BooleanType.getInstance(), linkDiverse.getType());
         assertTrue(linkDiverse.isAddedByUses());
@@ -540,7 +545,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, processingRule.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, processingRule.getPath());
         assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
@@ -551,7 +556,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, ignore.getPath());
         assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
@@ -562,7 +567,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, metric.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, metric.getPath());
         assertFalse(metric.isAddedByUses());
         // * |-- |-- |-- leaf metric-type
@@ -571,7 +576,7 @@ public class UsesAugmentTest {
         expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "metric-type");
         assertEquals(expectedQName, metricType.getQName());
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, metricType.getPath());
         assertEquals(Uint8.getInstance(), metricType.getType());
         assertTrue(metricType.isAddedByUses());
@@ -582,7 +587,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, box.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, box.getPath());
         assertTrue(box.isAddedByUses());
         // * |-- |-- |-- leaf processing-rule
@@ -592,7 +597,7 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, processingRule.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, processingRule.getPath());
         assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
@@ -603,14 +608,14 @@ public class UsesAugmentTest {
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
-        expectedPath= new SchemaPath(path, true);
+        expectedPath= SchemaPath.create(path, true);
         assertEquals(expectedPath, ignore.getPath());
         assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
     }
 
     @Test
-    public void testTypedefs() throws FileNotFoundException, URISyntaxException {
+    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();
@@ -624,7 +629,7 @@ public class UsesAugmentTest {
         assertNotNull(intExt);
 
         List<QName> path = Lists.newArrayList(new QName(GD_NS, GD_REV, GD_PREF, "int-ext"));
-        SchemaPath expectedPath = new SchemaPath(path, true);
+        SchemaPath expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, intExt.getPath());
 
         UnionType union = (UnionType)intExt.getBaseType();
@@ -642,7 +647,7 @@ public class UsesAugmentTest {
         assertNotNull(pv);
 
         QName q1 = BaseTypes.constructQName("union");
-        expectedPath = new SchemaPath(Lists.newArrayList(q1), true);
+        expectedPath = SchemaPath.create(Lists.newArrayList(q1), true);
         assertEquals(expectedPath, union.getPath());
     }