Add XMLNamespace
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / schema / NormalizedDataBuilderTest.java
index dc7f12f1315aaeb48d4310a0bc130ebe17648a20..8073f21ab608384621bdac48a9c39b74bd4ce9d0 100644 (file)
@@ -9,14 +9,14 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import static com.google.common.base.Preconditions.checkState;
 
+import com.google.common.collect.ImmutableSet;
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Collections;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -42,7 +42,6 @@ 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.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class NormalizedDataBuilderTest {
@@ -51,10 +50,8 @@ public class NormalizedDataBuilderTest {
     private SchemaContext schema;
 
     @Before
-    public void setUp() throws URISyntaxException, FileNotFoundException, ReactorException {
-        final File resourceFile = new File(getClass().getResource(
-                "test.yang").toURI());
-        schema = YangParserTestUtils.parseYangFiles(resourceFile);
+    public void setUp() throws URISyntaxException {
+        schema = YangParserTestUtils.parseYangFiles(new File(getClass().getResource("test.yang").toURI()));
         containerNode = (ContainerSchemaNode) getSchemaNode(schema, "test", "container");
     }
 
@@ -73,9 +70,8 @@ public class NormalizedDataBuilderTest {
         LeafSetNode<Integer> leafList = Builders.<Integer>leafSetBuilder()
                 .withNodeIdentifier(getNodeIdentifier("leaf"))
                 .withChildValue(1)
-                .withChild(
-                        Builders.<Integer>leafSetEntryBuilder()
-                                .withNodeIdentifier(getNodeWithValueIdentifier("leaf", 3)).withValue(3).build())
+                .withChild(Builders.<Integer>leafSetEntryBuilder()
+                        .withNodeIdentifier(getNodeWithValueIdentifier("leaf", 3)).withValue(3).build())
                 .build();
         builder.withChild(leafList);
 
@@ -86,8 +82,7 @@ public class NormalizedDataBuilderTest {
                         Builders.<Integer>leafBuilder().withNodeIdentifier(getNodeIdentifier("uint32InList"))
                                 .withValue(1).build())
                 .withChild(Builders.containerBuilder().withNodeIdentifier(getNodeIdentifier("containerInList")).build())
-                .withNodeIdentifier(
-                        new NodeIdentifierWithPredicates(
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(
                                 getNodeIdentifier("list").getNodeType(), Collections.singletonMap(
                                 getNodeIdentifier("uint32InList").getNodeType(), 1))).build();
 
@@ -98,7 +93,7 @@ public class NormalizedDataBuilderTest {
         AugmentationNode augmentation = Builders
                 .augmentationBuilder()
                 .withNodeIdentifier(
-                        new AugmentationIdentifier(Collections.singleton(getQName("augmentUint32"))))
+                        new AugmentationIdentifier(ImmutableSet.of(getQName("augmentUint32"))))
                 .withChild(
                         Builders.<Integer>leafBuilder().withNodeIdentifier(getNodeIdentifier("augmentUint32"))
                                 .withValue(11).build()).build();
@@ -120,8 +115,10 @@ public class NormalizedDataBuilderTest {
         builder.withChild(leafChild);
 
         LeafListSchemaNode leafListSchemaNode = (LeafListSchemaNode) getSchemaNode(schema, "test", "leafList");
-        LeafSetNode<Integer> leafList = Builders.<Integer>leafSetBuilder(leafListSchemaNode).withChildValue(1)
-                .withChild(Builders.<Integer>leafSetEntryBuilder(leafListSchemaNode).withValue(3).build()).build();
+        LeafSetNode<Integer> leafList = Builders.<Integer>leafSetBuilder(leafListSchemaNode)
+                .withChildValue(1)
+                .withChild(Builders.<Integer>leafSetEntryBuilder(leafListSchemaNode).withValue(3).build())
+                .build();
         builder.withChild(leafList);
 
         ListSchemaNode listSchema = (ListSchemaNode) getSchemaNode(schema, "test", "list");
@@ -170,7 +167,7 @@ public class NormalizedDataBuilderTest {
     private static AugmentationSchemaNode getAugmentationSchemaForChild(final ContainerSchemaNode containerNode,
             final QName qname) {
         for (AugmentationSchemaNode augmentationSchema : containerNode.getAvailableAugmentations()) {
-            if (augmentationSchema.getDataChildByName(qname) != null) {
+            if (augmentationSchema.findDataChildByName(qname).isPresent()) {
                 return augmentationSchema;
             }
         }
@@ -182,7 +179,7 @@ public class NormalizedDataBuilderTest {
     }
 
     private static QName getQName(final String localName) {
-        return QName.create(URI.create("namespace"), localName);
+        return QName.create(XMLNamespace.of("namespace"), localName);
     }
 
     private static NodeIdentifier getNodeIdentifier(final String localName) {
@@ -212,7 +209,7 @@ public class NormalizedDataBuilderTest {
                     return retVal;
                 }
             } else if (dataSchemaNode instanceof ChoiceSchemaNode) {
-                for (CaseSchemaNode caseNode : ((ChoiceSchemaNode) dataSchemaNode).getCases().values()) {
+                for (CaseSchemaNode caseNode : ((ChoiceSchemaNode) dataSchemaNode).getCases()) {
                     DataSchemaNode retVal = findChildNode(caseNode, name);
                     if (retVal != null) {
                         return retVal;