Merge "BUG-1382: eliminate QName.getPrefix()"
authorTony Tkacik <ttkacik@cisco.com>
Wed, 7 Jan 2015 09:36:26 +0000 (09:36 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 7 Jan 2015 09:36:26 +0000 (09:36 +0000)
16 files changed:
code-generator/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/yang/wadl/generator/WadlRestconfGenerator.xtend
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/QName.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlStreamUtils.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/MyNodeBuilder.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/RandomPrefixTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlStreamUtilsTest.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseTypes.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/CopyUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserListenerImpl.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/AugmentTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/TestUtils.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/UsesAugmentTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangParserSimpleTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangParserTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangParserWithContextTest.java

index 3a39b85229e14f5e051bed202bb93d61d7b07182..e860fc12ccd3936c8ee968498f216d1389b905bb 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.wadl.generator
 import java.io.BufferedWriter
 import java.io.File
 import java.io.OutputStreamWriter
+import java.net.URI
 import java.util.ArrayList
 import java.util.HashSet
 import java.util.List
@@ -157,8 +158,11 @@ class WadlRestconfGenerator {
                if (schemaNode instanceof ListSchemaNode) {
                        val listKeys = (schemaNode as ListSchemaNode).keyDefinition
                        for (listKey : listKeys) {
-                               pathListParams.add((schemaNode as DataNodeContainer).getDataChildByName(listKey) as LeafSchemaNode) 
-                               path.append(PATH_DELIMETER + "{" + listKey.localName + "}")
+                               pathListParams.add((schemaNode as DataNodeContainer).getDataChildByName(listKey) as LeafSchemaNode)
+                               path.append(PATH_DELIMETER)
+                               path.append('{')
+                               path.append(listKey.localName)
+                               path.append('}')
                        }
                }
                return path.toString
@@ -185,8 +189,7 @@ class WadlRestconfGenerator {
        private def resourceParams() '''
                «FOR pathParam : pathListParams»
                    «IF pathParam != null»
-                       «val prefix = pathParam.type.QName.prefix»
-                       «val type = if (prefix.nullOrEmpty) pathParam.type.QName.localName else prefix + ":" + pathParam.type.QName.localName»
+                       «val type = pathParam.type.QName.localName»
                        <param required="true" style="template" name="«pathParam.QName.localName»" type="«type»"/>
                        «ENDIF»
                «ENDFOR»
@@ -195,7 +198,7 @@ class WadlRestconfGenerator {
        private def methodGet(DataSchemaNode schemaNode) '''
                <method name="GET">
                        <response>
-                               «representation(schemaNode.QName.prefix, schemaNode.QName.localName)»
+                               «representation(schemaNode.QName.namespace, schemaNode.QName.localName)»
                        </response>
                </method>
        '''
@@ -203,7 +206,7 @@ class WadlRestconfGenerator {
        private def mehodPut(DataSchemaNode schemaNode) '''
                <method name="PUT">
                        <request>
-                               «representation(schemaNode.QName.prefix, schemaNode.QName.localName)»
+                               «representation(schemaNode.QName.namespace, schemaNode.QName.localName)»
                        </request>
                </method>
        '''
@@ -211,7 +214,7 @@ class WadlRestconfGenerator {
        private def mehodPost(DataSchemaNode schemaNode) '''
                <method name="POST">
                        <request>
-                               «representation(schemaNode.QName.prefix, schemaNode.QName.localName)»
+                               «representation(schemaNode.QName.namespace, schemaNode.QName.localName)»
                        </request>
                </method>
        '''
@@ -235,8 +238,8 @@ class WadlRestconfGenerator {
                <method name="DELETE" />
        '''
 
-       private def representation(String prefix, String name) '''
-               «val elementData = if (prefix.nullOrEmpty) name else prefix + ":" + name»
+       private def representation(URI prefix, String name) '''
+               «val elementData = name»
                <representation mediaType="application/xml" element="«elementData»"/>
                <representation mediaType="text/xml" element="«elementData»"/>
                <representation mediaType="application/json" element="«elementData»"/>
index 18969403d01d0f6c663814170d6653fd2128eacb..f37721eaf1ff373fb493bc1dd58daf89c3f0106a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.Fpre
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.common;
 
 import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat;
-
 import java.io.Serializable;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -17,7 +16,6 @@ import java.util.Date;
 import java.util.Objects;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.objcache.ObjectCache;
 import org.opendaylight.yangtools.objcache.ObjectCacheFactory;
@@ -64,12 +62,9 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
     private final QNameModule module;
     // Mandatory
     private final String localName;
-    // Nullable
-    private final String prefix;
 
-    private QName(final QNameModule module, final String prefix, final String localName) {
+    private QName(final QNameModule module, final String localName) {
         this.localName = checkLocalName(localName);
-        this.prefix = prefix;
         this.module = module;
     }
 
@@ -94,25 +89,6 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
         return CACHE.getReference(what);
     }
 
-    /**
-     * QName Constructor.
-     *
-     * @param namespace
-     *            the namespace assigned to the YANG module
-     * @param revision
-     *            the revision of the YANG module
-     * @param prefix
-     *            locally defined prefix assigned to local name
-     * @param localName
-     *            YANG schema identifier
-     *
-     * @deprecated Prefix storage in QNames is deprecated.
-     */
-    @Deprecated
-    public QName(final URI namespace, final Date revision, final String prefix, final String localName) {
-        this(QNameModule.create(namespace, revision), prefix, localName);
-    }
-
     /**
      * QName Constructor.
      *
@@ -122,7 +98,7 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
      *            YANG schema identifier
      */
     public QName(final URI namespace, final String localName) {
-        this(namespace, null, "", localName);
+        this(QNameModule.create(namespace, null), localName);
     }
 
     private static String checkLocalName(final String localName) {
@@ -204,18 +180,6 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
         return module.getRevision();
     }
 
-    /**
-     * Returns locally defined prefix assigned to local name
-     *
-     * @return locally defined prefix assigned to local name
-     *
-     * @deprecated Prefix storage in QNames is deprecated.
-     */
-    @Deprecated
-    public String getPrefix() {
-        return prefix;
-    }
-
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -256,7 +220,7 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
     }
 
     public static QName create(final QName base, final String localName) {
-        return create(base.getModule(), base.getPrefix(), localName);
+        return create(base.getModule(), localName);
     }
 
     /**
@@ -264,33 +228,15 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
      *
      * @param qnameModule
      *            Namespace and revision enclosed as a QNameModule
-     * @param prefix
-     *            Namespace prefix
      * @param localName
      *            Local name part of QName. MUST NOT BE null.
      * @return Instance of QName
-     *
-     * @deprecated Prefix storage in QNames is deprecated.
      */
-    @Deprecated
-    public static QName create(final QNameModule module, final String prefix, final String localName) {
-        if (module == null) {
+    public static QName create(final QNameModule qnameModule, final String localName) {
+        if (qnameModule == null) {
             throw new NullPointerException("module may not be null");
         }
-        return new QName(module, prefix, localName);
-    }
-
-    /**
-     * Creates new QName.
-     *
-     * @param qnameModule
-     *            Namespace and revision enclosed as a QNameModule
-     * @param localName
-     *            Local name part of QName. MUST NOT BE null.
-     * @return Instance of QName
-     */
-    public static QName create(final QNameModule qnameModule, final String localName) {
-        return create(qnameModule, null, localName);
+        return new QName(qnameModule, localName);
     }
 
     /**
@@ -305,7 +251,7 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
      * @return Instance of QName
      */
     public static QName create(final URI namespace, final Date revision, final String localName) {
-        return create(QNameModule.create(namespace, revision), null, localName);
+        return create(QNameModule.create(namespace, revision), localName);
     }
 
     /**
index f167b41bb72f5274ba27bedfd0486da63ccf3a7a..1a235d92618bee4b4abc65a081b35ebdcaa0957d 100644 (file)
@@ -153,8 +153,8 @@ public class XmlStreamUtils {
      */
     public void writeElement(final XMLStreamWriter writer, final @Nonnull Node<?> data, final SchemaNode schema) throws XMLStreamException {
         final QName qname = data.getNodeType();
-        final String pfx = qname.getPrefix() != null ? qname.getPrefix() : "";
         final String ns = qname.getNamespace() != null ? qname.getNamespace().toString() : "";
+        final String pfx = "";
 
         if (isEmptyElement(data)) {
             if (hasAttributes(data)) {
@@ -341,12 +341,7 @@ public class XmlStreamUtils {
     private static void write(final @Nonnull XMLStreamWriter writer, final @Nonnull IdentityrefTypeDefinition type, final @Nonnull Object value) throws XMLStreamException {
         if (value instanceof QName) {
             final QName qname = (QName) value;
-            final String prefix;
-            if (qname.getPrefix() != null && !qname.getPrefix().isEmpty()) {
-                prefix = qname.getPrefix();
-            } else {
-                prefix = "x";
-            }
+            final String prefix = "x";
 
             final String ns = qname.getNamespace().toString();
             writer.writeNamespace(prefix, ns);
index b0a4573f6aeedbcc214ca8f1e5fa2792288fbe3c..2ad9aed28f910f7d4cc187b65b1a04e9018f52ff 100644 (file)
@@ -33,7 +33,6 @@ public class MyNodeBuilder extends BuilderSupport {
     private static final Logger LOG = LoggerFactory.getLogger(MyNodeBuilder.class);
 
     private URI qnNamespace;
-    private final String qnPrefix;
     private final Date qnRevision;
 
     private CompositeNode rootNode;
@@ -43,7 +42,6 @@ public class MyNodeBuilder extends BuilderSupport {
      */
     private MyNodeBuilder(final QName baseQName) {
         qnNamespace = baseQName.getNamespace();
-        qnPrefix = baseQName.getPrefix();
         qnRevision = baseQName.getRevision();
     }
 
@@ -53,9 +51,9 @@ public class MyNodeBuilder extends BuilderSupport {
     public static MyNodeBuilder newInstance() {
         QName qName = null;
         try {
-            qName = new QName(
+            qName = QName.create(
                     new URI("urn:opendaylight:controller:network"),
-                    new Date(42), "yang-data-impl-groovyTest_", "node");
+                    new Date(42), "node");
         } catch (URISyntaxException e) {
             LOG.error(e.getMessage(), e);
         }
@@ -138,7 +136,7 @@ public class MyNodeBuilder extends BuilderSupport {
 
     private QName createQName(final Object localName) {
         LOG.debug("qname for: "+localName);
-        return new QName(qnNamespace, qnRevision, qnPrefix, (String) localName);
+        return QName.create(qnNamespace, qnRevision, (String) localName);
     }
 
     protected CompositeNode getCurrentNode() {
@@ -186,4 +184,4 @@ public class MyNodeBuilder extends BuilderSupport {
     public CompositeNode getRootNode() {
         return rootNode;
     }
-}
\ No newline at end of file
+}
index 73e3ad6f25c686006a5e24d05cb4e3e310ca5c2c..f7fb6a64b291cbc64725bfcc0292b7664556e95e 100644 (file)
@@ -70,8 +70,8 @@ public class RandomPrefixTest {
         final RandomPrefix a = new RandomPrefix();
 
         final URI uri = URI.create("localhost");
-        final QName qName = QName.create(QNameModule.create(uri, new Date()), "p1", "local-name");
-        final QName qName2 = QName.create(QNameModule.create(uri, new Date()), "p2", "local-name");
+        final QName qName = QName.create(QNameModule.create(uri, new Date()), "local-name");
+        final QName qName2 = QName.create(QNameModule.create(uri, new Date()), "local-name");
 
         assertEquals(a.encodePrefix(qName.getNamespace()), a.encodePrefix(qName2.getNamespace()));
     }
@@ -83,9 +83,9 @@ public class RandomPrefixTest {
         final URI uri = URI.create("localhost");
         QName qName = QName.create(uri, new Date(), "local-name");
         assertEquals("a", a.encodePrefix(qName.getNamespace()));
-        qName = QName.create(QNameModule.create(uri, new Date()), "", "local-name");
+        qName = QName.create(QNameModule.create(uri, new Date()), "local-name");
         assertEquals("a", a.encodePrefix(qName.getNamespace()));
-        qName = QName.create(QNameModule.create(URI.create("second"), new Date()), "", "local-name");
+        qName = QName.create(QNameModule.create(URI.create("second"), new Date()), "local-name");
         assertEquals("b", a.encodePrefix(qName.getNamespace()));
 
     }
index c4787d5ba2dc4cad26a01e3695da3861e8502d38..be321e526508a824e210fb7edebe037e0f9aeea4 100644 (file)
@@ -187,7 +187,7 @@ public class XmlStreamUtilsTest {
         if(prefix.isPresent()) {
             final QName moduleQName = QName.create(namespace, revision, "module");
             final QNameModule module = QNameModule.create(moduleQName.getNamespace(), moduleQName.getRevision());
-            return QName.create(module, prefix.get(), localName);
+            return QName.create(module, localName);
         } else {
             return QName.create(namespace, revision, localName);
         }
@@ -217,4 +217,4 @@ public class XmlStreamUtilsTest {
         }
         return null;
     }
-}
\ No newline at end of file
+}
index dccd07221db1baa4cc2e9867b4e5b85044b9292c..c5c098713e7e8f93f645efd9e7095f8dd109642e 100644 (file)
@@ -85,7 +85,7 @@ public final class BaseTypes {
      * @return built-in base yang type QName.
      */
     public static QName constructQName(final String typeName) {
-        return QName.create(BASE_TYPES_MODULE, "", typeName);
+        return QName.create(BASE_TYPES_MODULE, typeName);
     }
 
     /**
index 6c20697ad5ae3aacad1f61e3cdc5802b388d4eb8..0ca3d88b276ce03c509f8a2705cd469603592de1 100644 (file)
@@ -450,8 +450,7 @@ public final class CopyUtils {
         if (newParent instanceof ModuleBuilder) {
             ModuleBuilder parent = (ModuleBuilder) newParent;
             if (identityrefTypeCheck) {
-                newQName = QName.create(parent.getQNameModule(), parent.getPrefix(), old.getQName()
-                        .getLocalName());
+                newQName = QName.create(parent.getQNameModule(), old.getQName().getLocalName());
             } else {
                 newQName = old.getQName();
             }
@@ -460,8 +459,7 @@ public final class CopyUtils {
             AugmentationSchemaBuilder augment = (AugmentationSchemaBuilder) newParent;
             ModuleBuilder parent = BuilderUtils.getParentModule(newParent);
             if (identityrefTypeCheck) {
-                newQName = QName.create(parent.getQNameModule(), parent.getPrefix(), old.getQName()
-                        .getLocalName());
+                newQName = QName.create(parent.getQNameModule(), old.getQName().getLocalName());
             } else {
                 newQName = old.getQName();
             }
index 5c4afe6ae17b49e99535784d7e4ab2a74c28f26a..aa85be959c313ee999d6e48daeb0104598e77749 100644 (file)
@@ -131,7 +131,7 @@ public class ModuleBuilder extends AbstractDocumentedDataNodeContainerBuilder im
     }
 
     public ModuleBuilder(final Module base) {
-        super(base.getName(), 0, QName.create(base.getQNameModule(), base.getPrefix(), base.getName()),
+        super(base.getName(), 0, QName.create(base.getQNameModule(), base.getName()),
                 SCHEMA_PATH, base);
         this.name = base.getName();
         this.sourcePath = base.getModuleSourcePath();
index e5127b3142f1082f47f4789ffaa7acae875bc4b4..39dfbc9222bd7b3a27cc753de40fcc75c32dbeec 100644 (file)
@@ -114,7 +114,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     private final SchemaPathStack stack = new SchemaPathStack();
     private final Map<String, TreeMap<Date, URI>> namespaceContext;
     private final String sourcePath;
-    private QName moduleQName = new QName(null, new Date(0L), null, "dummy");
+    private QName moduleQName = QName.create(null, new Date(0L), "dummy");
     private ModuleBuilder moduleBuilder;
     private String moduleName;
     private int augmentOrder;
@@ -249,7 +249,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 setLog("namespace", namespaceStr);
             } else if (treeNode instanceof Prefix_stmtContext) {
                 yangModelPrefix = stringFromNode(treeNode);
-                this.moduleQName = QName.create(moduleQName.getModule(), yangModelPrefix, moduleQName.getLocalName());
+                this.moduleQName = QName.create(moduleQName.getModule(), moduleQName.getLocalName());
                 moduleBuilder.setPrefix(yangModelPrefix);
                 setLog("prefix", yangModelPrefix);
             } else if (treeNode instanceof Yang_version_stmtContext) {
index b20c9780875c3729a7219fd9cf7f0ae15f7816ed..e3c2b3cdaa02410740cf9c6f0a327ab5afc5f09b 100644 (file)
@@ -11,7 +11,6 @@ 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 java.io.FileNotFoundException;
 import java.net.URI;
 import java.text.DateFormat;
@@ -24,7 +23,6 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Set;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -48,9 +46,6 @@ public class AugmentTest {
     private static Date fooRev;
     private static Date barRev;
     private static Date bazRev;
-    private static final String foo = "foo";
-    private static final String bar = "bar";
-    private static final String baz = "baz";
     private static QName q0;
     private static QName q1;
     private static QName q2;
@@ -64,9 +59,9 @@ public class AugmentTest {
         barRev = simpleDateFormat.parse("2013-10-14");
         bazRev = simpleDateFormat.parse("2013-10-15");
 
-        q0 = new QName(barNS, barRev, bar, "interfaces");
-        q1 = new QName(barNS, barRev, bar, "ifEntry");
-        q2 = new QName(bazNS, bazRev, baz, "augment-holder");
+        q0 = QName.create(barNS, barRev, "interfaces");
+        q1 = QName.create(barNS, barRev, "ifEntry");
+        q2 = QName.create(bazNS, bazRev, "augment-holder");
     }
 
     @Test
@@ -105,7 +100,7 @@ public class AugmentTest {
         assertNotNull(odl);
 
         // leaf ds0ChannelNumber
-        QName qname = new QName(fooNS, fooRev, foo, "ds0ChannelNumber");
+        QName qname = QName.create(fooNS, fooRev, "ds0ChannelNumber");
         qnames.add(qname);
         assertEquals(qname, ds0ChannelNumber.getQName());
         expectedSchemaPath = SchemaPath.create(qnames, true);
@@ -118,7 +113,7 @@ public class AugmentTest {
         assertEquals(expectedSchemaPath, ds0ChannelNumber.getType().getPath());
 
         // leaf interface-id
-        qname = new QName(fooNS, fooRev, foo, "interface-id");
+        qname = QName.create(fooNS, fooRev, "interface-id");
         assertEquals(qname, interfaceId.getQName());
         qnames.set(3, qname);
         expectedSchemaPath = SchemaPath.create(qnames, true);
@@ -126,7 +121,7 @@ public class AugmentTest {
         assertFalse(interfaceId.isAugmenting());
 
         // container schemas
-        qname = new QName(fooNS, fooRev, foo, "schemas");
+        qname = QName.create(fooNS, fooRev, "schemas");
         assertEquals(qname, schemas.getQName());
         qnames.set(3, qname);
         expectedSchemaPath = SchemaPath.create(qnames, true);
@@ -134,7 +129,7 @@ public class AugmentTest {
         assertFalse(schemas.isAugmenting());
 
         // choice odl
-        qname = new QName(fooNS, fooRev, foo, "odl");
+        qname = QName.create(fooNS, fooRev, "odl");
         assertEquals(qname, odl.getQName());
         qnames.set(3, qname);
         expectedSchemaPath = SchemaPath.create(qnames, true);
@@ -208,28 +203,28 @@ public class AugmentTest {
         assertNotNull(odl);
 
         // leaf ds0ChannelNumber
-        QName qname = new QName(fooNS, fooRev, foo, "ds0ChannelNumber");
+        QName qname = QName.create(fooNS, fooRev, "ds0ChannelNumber");
         assertEquals(qname, ds0ChannelNumber.getQName());
         qnames.add(qname);
         expectedPath = SchemaPath.create(qnames, true);
         assertEquals(expectedPath, ds0ChannelNumber.getPath());
 
         // leaf interface-id
-        qname = new QName(fooNS, fooRev, foo, "interface-id");
+        qname = QName.create(fooNS, fooRev, "interface-id");
         assertEquals(qname, interfaceId.getQName());
         qnames.set(3, qname);
         expectedPath = SchemaPath.create(qnames, true);
         assertEquals(expectedPath, interfaceId.getPath());
 
         // container schemas
-        qname = new QName(fooNS, fooRev, foo, "schemas");
+        qname = QName.create(fooNS, fooRev, "schemas");
         assertEquals(qname, schemas.getQName());
         qnames.set(3, qname);
         expectedPath = SchemaPath.create(qnames, true);
         assertEquals(expectedPath, schemas.getPath());
 
         // choice odl
-        qname = new QName(fooNS, fooRev, foo, "odl");
+        qname = QName.create(fooNS, fooRev, "odl");
         assertEquals(qname, odl.getQName());
         qnames.set(3, qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -279,10 +274,10 @@ public class AugmentTest {
         qnames.add(q0);
         qnames.add(q1);
         qnames.add(q2);
-        qnames.add(new QName(fooNS, fooRev, foo, "odl"));
+        qnames.add(QName.create(fooNS, fooRev, "odl"));
 
         // case id
-        QName qname = new QName(fooNS, fooRev, foo, "id");
+        QName qname = QName.create(fooNS, fooRev, "id");
         assertEquals(qname, id.getQName());
         qnames.add(qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -291,7 +286,7 @@ public class AugmentTest {
         assertEquals(1, idChildren.size());
 
         // case node1
-        qname = new QName(fooNS, fooRev, foo, "node1");
+        qname = QName.create(fooNS, fooRev, "node1");
         assertEquals(qname, node1.getQName());
         qnames.set(4, qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -300,7 +295,7 @@ public class AugmentTest {
         assertTrue(node1Children.isEmpty());
 
         // case node2
-        qname = new QName(fooNS, fooRev, foo, "node2");
+        qname = QName.create(fooNS, fooRev, "node2");
         assertEquals(qname, node2.getQName());
         qnames.set(4, qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -309,7 +304,7 @@ public class AugmentTest {
         assertTrue(node2Children.isEmpty());
 
         // case node3
-        qname = new QName(fooNS, fooRev, foo, "node3");
+        qname = QName.create(fooNS, fooRev, "node3");
         assertEquals(qname, node3.getQName());
         qnames.set(4, qname);
         expectedPath = SchemaPath.create(qnames, true);
@@ -322,19 +317,19 @@ public class AugmentTest {
         qnames.add(q0);
         qnames.add(q1);
         qnames.add(q2);
-        qnames.add(new QName(fooNS, fooRev, foo, "odl"));
+        qnames.add(QName.create(fooNS, fooRev, "odl"));
 
         // case id child
-        qnames.add(new QName(fooNS, fooRev, foo, "id"));
-        qnames.add(new QName(fooNS, fooRev, foo, "id"));
+        qnames.add(QName.create(fooNS, fooRev, "id"));
+        qnames.add(QName.create(fooNS, fooRev, "id"));
         LeafSchemaNode caseIdChild = (LeafSchemaNode) idChildren.iterator().next();
         assertNotNull(caseIdChild);
         expectedPath = SchemaPath.create(qnames, true);
         assertEquals(expectedPath, caseIdChild.getPath());
 
         // case node3 child
-        qnames.set(4, new QName(fooNS, fooRev, foo, "node3"));
-        qnames.set(5, new QName(fooNS, fooRev, foo, "node3"));
+        qnames.set(4, QName.create(fooNS, fooRev, "node3"));
+        qnames.set(5, QName.create(fooNS, fooRev, "node3"));
         ContainerSchemaNode caseNode3Child = (ContainerSchemaNode) node3Children.iterator().next();
         assertNotNull(caseNode3Child);
         expectedPath = SchemaPath.create(qnames, true);
@@ -361,13 +356,13 @@ public class AugmentTest {
         }
         assertNotNull(submit);
 
-        QName submitQName = new QName(NS_BAR, revision, "b", "submit");
+        QName submitQName = QName.create(NS_BAR, revision, "submit");
         assertEquals(submitQName, submit.getQName());
         ContainerSchemaNode input = submit.getInput();
-        QName inputQName = new QName(NS_BAR, revision, "b", "input");
+        QName inputQName = QName.create(NS_BAR, revision, "input");
         assertEquals(inputQName, input.getQName());
         ChoiceNode arguments = (ChoiceNode) input.getDataChildByName("arguments");
-        QName argumentsQName = new QName(NS_BAR, revision, "b", "arguments");
+        QName argumentsQName = QName.create(NS_BAR, revision, "arguments");
         assertEquals(argumentsQName, arguments.getQName());
         assertFalse(arguments.isAugmenting());
         Set<ChoiceCaseNode> cases = arguments.getCases();
@@ -400,7 +395,7 @@ public class AugmentTest {
         qnames[2] = argumentsQName;
 
         // case attach
-        qnames[3] = new QName(NS_FOO, revision, "f", "attach");
+        qnames[3] = QName.create(NS_FOO, revision, "attach");
         assertEquals(qnames[3], attach.getQName());
         expectedPath = SchemaPath.create(Arrays.asList(qnames), true);
         assertEquals(expectedPath, attach.getPath());
@@ -408,7 +403,7 @@ public class AugmentTest {
         assertEquals(1, attachChildren.size());
 
         // case create
-        qnames[3] = new QName(NS_FOO, revision, "f", "create");
+        qnames[3] = QName.create(NS_FOO, revision, "create");
         assertEquals(qnames[3], create.getQName());
         expectedPath = SchemaPath.create(Arrays.asList(qnames), true);
         assertEquals(expectedPath, create.getPath());
@@ -416,7 +411,7 @@ public class AugmentTest {
         assertEquals(1, createChildren.size());
 
         // case attach
-        qnames[3] = new QName(NS_FOO, revision, "f", "destroy");
+        qnames[3] = QName.create(NS_FOO, revision, "destroy");
         assertEquals(qnames[3], destroy.getQName());
         expectedPath = SchemaPath.create(Arrays.asList(qnames), true);
         assertEquals(expectedPath, destroy.getPath());
index 8fd6c1896dc640b324acc54dedd1f232a7e2bc34..300ed776ffc10fff613dabc3ad7ae24341314ed5 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.parser.impl;
 
 import static org.junit.Assert.assertEquals;
-
 import com.google.common.io.ByteSource;
 import com.google.common.io.ByteStreams;
 import java.io.File;
@@ -149,7 +148,7 @@ final class TestUtils {
     public static SchemaPath createPath(final boolean absolute, final URI namespace, final Date revision, final String prefix, final String... names) {
         List<QName> path = new ArrayList<>();
         for (String name : names) {
-            path.add(new QName(namespace, revision, prefix, name));
+            path.add(QName.create(namespace, revision, name));
         }
         return SchemaPath.create(path, absolute);
     }
index 010570dc10b9d4d8d2402f10cefb77e1f38ac653..d221e7c218b52c0a2b6e1c5aebf170b7ddbeed01 100644 (file)
@@ -11,9 +11,7 @@ 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;
@@ -26,7 +24,6 @@ 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;
@@ -51,8 +48,6 @@ public class UsesAugmentTest {
     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 static final String UG_PREF = "ug";
-    private static final String GD_PREF = "gd";
 
     private Set<Module> modules;
 
@@ -129,7 +124,7 @@ public class UsesAugmentTest {
         assertEquals(1, notifications.size());
         NotificationDefinition pcreq = notifications.iterator().next();
         assertNotNull(pcreq);
-        QName expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "pcreq");
+        QName expectedQName = QName.create(UG_NS, UG_REV, "pcreq");
         path.offer(expectedQName);
         SchemaPath expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, pcreq.getPath());
@@ -138,11 +133,11 @@ public class UsesAugmentTest {
         // * |-- leaf version
         LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName("version");
         assertNotNull(version);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "version");
+        expectedQName = QName.create(UG_NS, UG_REV, "version");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, version.getPath());
-        expectedQName = new QName(GD_NS, GD_REV, GD_PREF, "protocol-version");
+        expectedQName = QName.create(GD_NS, GD_REV, "protocol-version");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
         assertEquals(expectedPath, version.getType().getPath());
@@ -151,14 +146,14 @@ public class UsesAugmentTest {
         // * |-- leaf type
         LeafSchemaNode type = (LeafSchemaNode) pcreq.getDataChildByName("type");
         assertNotNull(type);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "type");
+        expectedQName = QName.create(UG_NS, UG_REV, "type");
         assertTrue(type.isAddedByUses());
         path.pollLast();
         path.pollLast();
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, type.getPath());
-        expectedQName = new QName(GD_NS, GD_REV, GD_PREF, "int-ext");
+        expectedQName = QName.create(GD_NS, GD_REV, "int-ext");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(Lists.newArrayList(expectedQName), true);
         assertEquals(expectedPath, type.getType().getPath());
@@ -168,7 +163,7 @@ public class UsesAugmentTest {
         // * |-- list requests
         ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName("requests");
         assertNotNull(requests);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "requests");
+        expectedQName = QName.create(UG_NS, UG_REV, "requests");
         assertEquals(expectedQName, requests.getQName());
         path.pollLast();
         path.pollLast();
@@ -181,7 +176,7 @@ public class UsesAugmentTest {
         // * |-- |-- container rp
         ContainerSchemaNode rp = (ContainerSchemaNode) requests.getDataChildByName("rp");
         assertNotNull(rp);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "rp");
+        expectedQName = QName.create(UG_NS, UG_REV, "rp");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, rp.getPath());
@@ -191,7 +186,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- leaf processing-rule
         LeafSchemaNode processingRule = (LeafSchemaNode) rp.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -201,7 +196,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- leaf ignore
         LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName("ignore");
         assertNotNull(ignore);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "ignore");
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -212,13 +207,13 @@ public class UsesAugmentTest {
         // * |-- |-- |-- leaf priority
         LeafSchemaNode priority = (LeafSchemaNode) rp.getDataChildByName("priority");
         assertNotNull(priority);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "priority");
+        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 = new QName(UG_NS, UG_REV, UG_PREF, "uint8");
+        expectedQName = QName.create(UG_NS, UG_REV, "uint8");
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
         // TODO
@@ -228,7 +223,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- container box
         ContainerSchemaNode box = (ContainerSchemaNode) rp.getDataChildByName("box");
         assertNotNull(box);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "box");
+        expectedQName = QName.create(UG_NS, UG_REV, "box");
         assertEquals(expectedQName, box.getQName());
         path.pollLast();
         path.pollLast();
@@ -239,7 +234,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- container order
         ContainerSchemaNode order = (ContainerSchemaNode) box.getDataChildByName("order");
         assertNotNull(order);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "order");
+        expectedQName = QName.create(UG_NS, UG_REV, "order");
         assertEquals(expectedQName, order.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -250,7 +245,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf delete
         LeafSchemaNode delete = (LeafSchemaNode) order.getDataChildByName("delete");
         assertNotNull(delete);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "delete");
+        expectedQName = QName.create(UG_NS, UG_REV, "delete");
         assertEquals(expectedQName, delete.getQName());
         path.offer(expectedQName);
         expectedPath = SchemaPath.create(path, true);
@@ -260,7 +255,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf setup
         LeafSchemaNode setup = (LeafSchemaNode) order.getDataChildByName("setup");
         assertNotNull(setup);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "setup");
+        expectedQName = QName.create(UG_NS, UG_REV, "setup");
         assertEquals(expectedQName, setup.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -271,7 +266,7 @@ public class UsesAugmentTest {
         // * |-- |-- path-key-expansion
         ContainerSchemaNode pke = (ContainerSchemaNode) requests.getDataChildByName("path-key-expansion");
         assertNotNull(pke);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "path-key-expansion");
+        expectedQName = QName.create(UG_NS, UG_REV, "path-key-expansion");
         assertEquals(expectedQName, pke.getQName());
         path.pollLast();
         path.pollLast();
@@ -284,7 +279,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- path-key
         ContainerSchemaNode pathKey = (ContainerSchemaNode) pke.getDataChildByName("path-key");
         assertNotNull(pathKey);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "path-key");
+        expectedQName = QName.create(UG_NS, UG_REV, "path-key");
         assertEquals(expectedQName, pathKey.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -294,7 +289,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) pathKey.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -304,7 +299,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) pathKey.getDataChildByName("ignore");
         assertNotNull(ignore);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "ignore");
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -315,7 +310,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- list path-keys
         ListSchemaNode pathKeys = (ListSchemaNode) pathKey.getDataChildByName("path-keys");
         assertNotNull(pathKeys);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "path-keys");
+        expectedQName = QName.create(UG_NS, UG_REV, "path-keys");
         assertEquals(expectedQName, pathKeys.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -327,7 +322,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf version
         version = (LeafSchemaNode) pathKeys.getDataChildByName("version");
         assertNotNull(version);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "version");
+        expectedQName = QName.create(UG_NS, UG_REV, "version");
         assertEquals(expectedQName, version.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -339,7 +334,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf type
         type = (LeafSchemaNode) pathKeys.getDataChildByName("type");
         assertNotNull(type);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "type");
+        expectedQName = QName.create(UG_NS, UG_REV, "type");
         assertEquals(expectedQName, type.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -351,7 +346,7 @@ public class UsesAugmentTest {
         // * |-- |-- container segment-computation
         ContainerSchemaNode sc = (ContainerSchemaNode) requests.getDataChildByName("segment-computation");
         assertNotNull(sc);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "segment-computation");
+        expectedQName = QName.create(UG_NS, UG_REV, "segment-computation");
         assertEquals(expectedQName, sc.getQName());
         path.pollLast();
         path.pollLast();
@@ -364,7 +359,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- container p2p
         ContainerSchemaNode p2p = (ContainerSchemaNode) sc.getDataChildByName("p2p");
         assertNotNull(p2p);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "p2p");
+        expectedQName = QName.create(UG_NS, UG_REV, "p2p");
         assertEquals(expectedQName, p2p.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -373,7 +368,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- container endpoints
         ContainerSchemaNode endpoints = (ContainerSchemaNode) p2p.getDataChildByName("endpoints");
         assertNotNull(endpoints);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "endpoints");
+        expectedQName = QName.create(UG_NS, UG_REV, "endpoints");
         assertEquals(expectedQName, endpoints.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -382,7 +377,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) endpoints.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -392,7 +387,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) endpoints.getDataChildByName("ignore");
         assertNotNull(ignore);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "ignore");
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -403,7 +398,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- container box
         box = (ContainerSchemaNode) endpoints.getDataChildByName("box");
         assertNotNull(box);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "box");
+        expectedQName = QName.create(UG_NS, UG_REV, "box");
         assertEquals(expectedQName, box.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -413,7 +408,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- choice address-family
         ChoiceNode af = (ChoiceNode) endpoints.getDataChildByName("address-family");
         assertNotNull(af);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "address-family");
+        expectedQName = QName.create(UG_NS, UG_REV, "address-family");
         assertEquals(expectedQName, af.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -423,7 +418,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- container reported-route
         ContainerSchemaNode reportedRoute = (ContainerSchemaNode) p2p.getDataChildByName("reported-route");
         assertNotNull(reportedRoute);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "reported-route");
+        expectedQName = QName.create(UG_NS, UG_REV, "reported-route");
         assertEquals(expectedQName, reportedRoute.getQName());
         path.pollLast();
         path.pollLast();
@@ -434,7 +429,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) reportedRoute.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -444,7 +439,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) reportedRoute.getDataChildByName("ignore");
         assertNotNull(ignore);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "ignore");
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -455,7 +450,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- list subobjects
         ListSchemaNode subobjects = (ListSchemaNode) reportedRoute.getDataChildByName("subobjects");
         assertNotNull(subobjects);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "subobjects");
+        expectedQName = QName.create(UG_NS, UG_REV, "subobjects");
         assertEquals(expectedQName, subobjects.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -465,7 +460,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- container bandwidth
         ContainerSchemaNode bandwidth = (ContainerSchemaNode) reportedRoute.getDataChildByName("bandwidth");
         assertNotNull(bandwidth);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "bandwidth");
+        expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
         assertEquals(expectedQName, bandwidth.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -475,7 +470,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- container bandwidth
         bandwidth = (ContainerSchemaNode) p2p.getDataChildByName("bandwidth");
         assertNotNull(bandwidth);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "bandwidth");
+        expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
         assertEquals(expectedQName, bandwidth.getQName());
         path.pollLast();
         path.pollLast();
@@ -486,7 +481,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) bandwidth.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -496,7 +491,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) bandwidth.getDataChildByName("ignore");
         assertNotNull(ignore);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "ignore");
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -507,7 +502,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- |-- |-- container bandwidth
         ContainerSchemaNode bandwidthInner = (ContainerSchemaNode) bandwidth.getDataChildByName("bandwidth");
         assertNotNull(bandwidthInner);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "bandwidth");
+        expectedQName = QName.create(UG_NS, UG_REV, "bandwidth");
         assertEquals(expectedQName, bandwidth.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -517,7 +512,7 @@ public class UsesAugmentTest {
         // * |-- list svec
         ListSchemaNode svec = (ListSchemaNode) pcreq.getDataChildByName("svec");
         assertNotNull(svec);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "svec");
+        expectedQName = QName.create(UG_NS, UG_REV, "svec");
         assertEquals(expectedQName, svec.getQName());
         path.pollLast();
         path.pollLast();
@@ -531,7 +526,7 @@ public class UsesAugmentTest {
         // * |-- |-- leaf link-diverse
         LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName("link-diverse");
         assertNotNull(linkDiverse);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "link-diverse");
+        expectedQName = QName.create(UG_NS, UG_REV, "link-diverse");
         assertEquals(expectedQName, linkDiverse.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -541,7 +536,7 @@ public class UsesAugmentTest {
         // * |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) svec.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -552,7 +547,7 @@ public class UsesAugmentTest {
         // * |-- |-- leaf ignore
         ignore = (LeafSchemaNode) svec.getDataChildByName("ignore");
         assertNotNull(ignore);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "ignore");
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -563,7 +558,7 @@ public class UsesAugmentTest {
         // * |-- |-- list metric
         ListSchemaNode metric = (ListSchemaNode) svec.getDataChildByName("metric");
         assertNotNull(metric);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "metric");
+        expectedQName = QName.create(UG_NS, UG_REV, "metric");
         assertEquals(expectedQName, metric.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -573,7 +568,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- leaf metric-type
         LeafSchemaNode metricType = (LeafSchemaNode) metric.getDataChildByName("metric-type");
         assertNotNull(metricType);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "metric-type");
+        expectedQName = QName.create(UG_NS, UG_REV, "metric-type");
         assertEquals(expectedQName, metricType.getQName());
         path.offer(expectedQName);
         expectedPath= SchemaPath.create(path, true);
@@ -583,7 +578,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- box
         box = (ContainerSchemaNode) metric.getDataChildByName("box");
         assertNotNull(box);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "box");
+        expectedQName = QName.create(UG_NS, UG_REV, "box");
         assertEquals(expectedQName, box.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -593,7 +588,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- leaf processing-rule
         processingRule = (LeafSchemaNode) metric.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "processing-rule");
+        expectedQName = QName.create(UG_NS, UG_REV, "processing-rule");
         assertEquals(expectedQName, processingRule.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -604,7 +599,7 @@ public class UsesAugmentTest {
         // * |-- |-- |-- leaf ignore
         ignore = (LeafSchemaNode) metric.getDataChildByName("ignore");
         assertNotNull(ignore);
-        expectedQName = new QName(UG_NS, UG_REV, UG_PREF, "ignore");
+        expectedQName = QName.create(UG_NS, UG_REV, "ignore");
         assertEquals(expectedQName, ignore.getQName());
         path.pollLast();
         path.offer(expectedQName);
@@ -628,7 +623,7 @@ public class UsesAugmentTest {
         }
         assertNotNull(intExt);
 
-        List<QName> path = Lists.newArrayList(new QName(GD_NS, GD_REV, GD_PREF, "int-ext"));
+        List<QName> path = Lists.newArrayList(QName.create(GD_NS, GD_REV, "int-ext"));
         SchemaPath expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, intExt.getPath());
 
index 0320fa123a3d9484cb4aece830279d98b331e010..3c11b016089e9043cd72e906a465a96e79cb2ee5 100644 (file)
@@ -107,7 +107,7 @@ public class YangParserSimpleTest {
 
         ContainerSchemaNode nodes = (ContainerSchemaNode) test.getDataChildByName("nodes");
         // test SchemaNode args
-        QName expectedQName = new QName(snNS, snRev, snPref, "nodes");
+        QName expectedQName = QName.create(snNS, snRev, "nodes");
         assertEquals(expectedQName, nodes.getQName());
         SchemaPath expectedPath = TestUtils.createPath(true, snNS, snRev, snPref, "nodes");
         assertEquals(expectedPath, nodes.getPath());
@@ -155,7 +155,7 @@ public class YangParserSimpleTest {
         Set<TypeDefinition<?>> typedefs = nodes.getTypeDefinitions();
         assertEquals(1, typedefs.size());
         TypeDefinition<?> nodesType = typedefs.iterator().next();
-        QName typedefQName = new QName(snNS, snRev, snPref, "nodes-type");
+        QName typedefQName = QName.create(snNS, snRev, "nodes-type");
         assertEquals(typedefQName, nodesType.getQName());
         SchemaPath nodesTypePath = TestUtils.createPath(true, snNS, snRev, snPref, "nodes", "nodes-type");
         assertEquals(nodesTypePath, nodesType.getPath());
@@ -177,7 +177,7 @@ public class YangParserSimpleTest {
         Set<GroupingDefinition> groupings = nodes.getGroupings();
         assertEquals(1, groupings.size());
         GroupingDefinition nodeGroup = groupings.iterator().next();
-        QName groupQName = new QName(snNS, snRev, snPref, "node-group");
+        QName groupQName = QName.create(snNS, snRev, "node-group");
         assertEquals(groupQName, nodeGroup.getQName());
         SchemaPath nodeGroupPath = TestUtils.createPath(true, snNS, snRev, snPref, "nodes", "node-group");
         assertEquals(nodeGroupPath, nodeGroup.getPath());
@@ -202,7 +202,7 @@ public class YangParserSimpleTest {
 
         List<QName> path = new ArrayList<>();
         for (String name : names) {
-            path.add(new QName(ns, rev, prefix, name));
+            path.add(QName.create(ns, rev, name));
         }
         return SchemaPath.create(path, true);
     }
index ebd6b6e5246ec0a3b1db1b10c64256724c3e52e4..adab3c93a3c12a1364d5bf4fee313c3fee99b309 100644 (file)
@@ -129,7 +129,7 @@ public class YangParserTest {
 
         ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName("ifEntry");
         // test SchemaNode args
-        QName expectedQName = new QName(expectedNamespace, barRev, expectedPrefix, "ifEntry");
+        QName expectedQName = QName.create(expectedNamespace, barRev, "ifEntry");
         assertEquals(expectedQName, ifEntry.getQName());
         SchemaPath expectedPath = TestUtils.createPath(true, expectedNamespace, barRev, expectedPrefix, "interfaces",
                 "ifEntry");
@@ -152,7 +152,7 @@ public class YangParserTest {
         assertEquals(2, availableAugmentations.size());
         // test ListSchemaNode args
         List<QName> expectedKey = new ArrayList<>();
-        expectedKey.add(new QName(expectedNamespace, barRev, expectedPrefix, "ifIndex"));
+        expectedKey.add(QName.create(expectedNamespace, barRev, "ifIndex"));
         assertEquals(expectedKey, ifEntry.getKeyDefinition());
         assertFalse(ifEntry.isUserOrdered());
         // test DataNodeContainer args
@@ -656,8 +656,8 @@ public class YangParserTest {
         assertEquals("system/user ref", dev.getReference());
 
         List<QName> path = new ArrayList<>();
-        path.add(new QName(barNS, barRev, "br", "interfaces"));
-        path.add(new QName(barNS, barRev, "br", "ifEntry"));
+        path.add(QName.create(barNS, barRev, "interfaces"));
+        path.add(QName.create(barNS, barRev, "ifEntry"));
         SchemaPath expectedPath = SchemaPath.create(path, true);
 
         assertEquals(expectedPath, dev.getTargetPath());
@@ -704,7 +704,7 @@ public class YangParserTest {
 
         NotificationDefinition notification = notifications.iterator().next();
         // test SchemaNode args
-        QName expectedQName = new QName(bazNS, bazRev, expectedPrefix, "event");
+        QName expectedQName = QName.create(bazNS, bazRev, "event");
         assertEquals(expectedQName, notification.getQName());
         SchemaPath expectedPath = TestUtils.createPath(true, bazNS, bazRev, expectedPrefix, "event");
         assertEquals(expectedPath, notification.getPath());
index f2b076930cca2c812aec1d45d7d77dc706ee6720..f997164fe06fcd7e9dc3d656d0c343af78204604 100644 (file)
@@ -222,8 +222,7 @@ public class YangParserWithContextTest {
 
         // test grouping path
         List<QName> path = new ArrayList<>();
-        QName qname = new QName(URI.create("urn:opendaylight.baz"), simpleDateFormat.parse("2013-02-27"), "baz",
-                "target");
+        QName qname = QName.create(URI.create("urn:opendaylight.baz"), simpleDateFormat.parse("2013-02-27"), "target");
         path.add(qname);
         SchemaPath expectedPath = SchemaPath.create(path, true);
         assertEquals(expectedPath, usesNode.getGroupingPath());
@@ -401,8 +400,8 @@ public class YangParserWithContextTest {
         DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Date expectedRev = simpleDateFormat.parse("2013-07-03");
         List<QName> path = new ArrayList<>();
-        path.add(new QName(expectedNS, expectedRev, "bar", "interfaces"));
-        path.add(new QName(expectedNS, expectedRev, "bar", "ifEntry"));
+        path.add(QName.create(expectedNS, expectedRev, "interfaces"));
+        path.add(QName.create(expectedNS, expectedRev, "ifEntry"));
         SchemaPath expectedPath = SchemaPath.create(path, true);
 
         assertEquals(expectedPath, dev.getTargetPath());