Cleanup testing AugmentationIdentifier instantiations 41/82341/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 30 May 2019 17:06:07 +0000 (19:06 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 30 May 2019 17:40:35 +0000 (19:40 +0200)
Using ImmutableList.of() is slightly faster, use that.

Change-Id: Ia45d18dc840e8985a1037e7235c01da5f873d870
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-api/src/test/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNodesTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/JsonStreamToNormalizedNodeTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodesToXmlTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemalessXMLStreamNormalizedNodeStreamWriterTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/ImmutableNormalizedNodeStreamWriterTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java

index 77813f20e7487fd25dd33934932ab0482864f862..422fbacf88115c5e7454f70370fa6f5dab254c31 100644 (file)
@@ -14,6 +14,7 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
+import com.google.common.collect.ImmutableSet;
 import java.util.Collections;
 import java.util.Optional;
 import org.junit.Test;
@@ -105,7 +106,7 @@ public class NormalizedNodesTest {
 
         final AugmentationNode mockedAugmentationNode = mock(AugmentationNode.class);
         final QName listQName = QName.create("test-ns", "2016-09-16", "list-node");
-        final AugmentationIdentifier augNodeId = new AugmentationIdentifier(Collections.singleton(listQName));
+        final AugmentationIdentifier augNodeId = new AugmentationIdentifier(ImmutableSet.of(listQName));
         doReturn(augNodeId).when(mockedAugmentationNode).getIdentifier();
 
         final MapNode mockedMapNode = mock(MapNode.class);
index c0f652f246db6372a72e18a266e6fa8569f0071e..7e4e12d9b02d58b6db5deb8a2530074ca8eb1e27 100644 (file)
@@ -17,11 +17,11 @@ import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBu
 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.gson.stream.JsonReader;
 import java.io.IOException;
 import java.io.StringReader;
 import java.net.URISyntaxException;
-import java.util.Collections;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -235,8 +235,8 @@ public class JsonStreamToNormalizedNodeTest {
         final QName containerQName = QName.create(augmentChoice1QName, "case11-choice-case-container");
         final QName leafQName = QName.create(augmentChoice1QName, "case11-choice-case-leaf");
 
-        final AugmentationIdentifier aug1Id = new AugmentationIdentifier(Collections.singleton(augmentChoice1QName));
-        final AugmentationIdentifier aug2Id = new AugmentationIdentifier(Collections.singleton(augmentChoice2QName));
+        final AugmentationIdentifier aug1Id = new AugmentationIdentifier(ImmutableSet.of(augmentChoice1QName));
+        final AugmentationIdentifier aug2Id = new AugmentationIdentifier(ImmutableSet.of(augmentChoice2QName));
         final NodeIdentifier augmentChoice1Id = new NodeIdentifier(augmentChoice1QName);
         final NodeIdentifier augmentChoice2Id = new NodeIdentifier(augmentChoice2QName);
         final NodeIdentifier containerId = new NodeIdentifier(containerQName);
index 5876ec9f172a94ac4ccf2bbcea71ad7d1bb3008f..00fd4487631e968d3e92c06acb4cc17b19a90abe 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.data.codec.gson;
 
 import com.google.common.collect.ImmutableSet;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -128,7 +127,7 @@ public final class TestingNormalizedNodeStructuresCreator {
 
     private static DataContainerChild<? extends PathArgument, ?> augmentC11AWithLf15_21Node() {
         return Builders.augmentationBuilder().withNodeIdentifier(
-            new AugmentationIdentifier(Collections.singleton(QName.create("ns:complex:json", "2014-08-11", "lf15_21"))))
+            new AugmentationIdentifier(ImmutableSet.of(QName.create("ns:complex:json", "2014-08-11", "lf15_21"))))
                 .withChild(lf15_21Node()).build();
     }
 
index b547359608f624fe3e6d65763fca72bba6f476d8..8f5f13ed933f4949b94cd08c40340f44760d19ab 100644 (file)
@@ -10,12 +10,12 @@ package org.opendaylight.yangtools.yang.data.codec.xml;
 
 import static java.util.Objects.requireNonNull;
 
+import com.google.common.collect.ImmutableSet;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
 import java.net.URI;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import javax.xml.stream.XMLOutputFactory;
@@ -233,7 +233,7 @@ public class NormalizedNodesToXmlTest {
                 .build();
 
         AugmentationNode myDoublyKeyedListAugNode = Builders.augmentationBuilder().withNodeIdentifier(
-                new AugmentationIdentifier(Collections.singleton(myDoublyKeyedList)))
+                new AugmentationIdentifier(ImmutableSet.of(myDoublyKeyedList)))
                 .withChild(myDoublyKeyedListNode).build();
 
         ContainerNode myContainer3Node = Builders.containerBuilder().withNodeIdentifier(
@@ -241,7 +241,7 @@ public class NormalizedNodesToXmlTest {
                 .withChild(myDoublyKeyedListAugNode).build();
 
         AugmentationNode myContainer3AugNode = Builders.augmentationBuilder().withNodeIdentifier(
-                new AugmentationIdentifier(Collections.singleton(myContainer3)))
+                new AugmentationIdentifier(ImmutableSet.of(myContainer3)))
                 .withChild(myContainer3Node).build();
 
         ContainerNode outerContainerNode = Builders.containerBuilder().withNodeIdentifier(
index bbb627905e179a859930a8c5383346b373522f90..8391587e5362e26bab52d35688b8b5d42a5a823c 100644 (file)
@@ -10,13 +10,13 @@ package org.opendaylight.yangtools.yang.data.codec.xml;
 
 import static java.util.Objects.requireNonNull;
 
+import com.google.common.collect.ImmutableSet;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -285,7 +285,7 @@ public class SchemalessXMLStreamNormalizedNodeStreamWriterTest {
                 .build();
 
         AugmentationNode myDoublyKeyedListAugNode = Builders.augmentationBuilder().withNodeIdentifier(
-                new AugmentationIdentifier(Collections.singleton(myDoublyKeyedList)))
+                new AugmentationIdentifier(ImmutableSet.of(myDoublyKeyedList)))
                 .withChild(myDoublyKeyedListNode).build();
 
         ContainerNode myContainer3Node = Builders.containerBuilder().withNodeIdentifier(
@@ -293,7 +293,7 @@ public class SchemalessXMLStreamNormalizedNodeStreamWriterTest {
                 .withChild(myDoublyKeyedListAugNode).build();
 
         AugmentationNode myContainer3AugNode = Builders.augmentationBuilder().withNodeIdentifier(
-                new AugmentationIdentifier(Collections.singleton(myContainer3)))
+                new AugmentationIdentifier(ImmutableSet.of(myContainer3)))
                 .withChild(myContainer3Node).build();
 
         ContainerNode outerContainerNode = Builders.containerBuilder().withNodeIdentifier(
index 3e16fee00cfd2e55a7087b17e9c57e250d2b8943..c233e00dfe352e118ac5f2b302237c88c8c11d6f 100644 (file)
@@ -15,11 +15,11 @@ import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import javax.xml.parsers.ParserConfigurationException;
@@ -344,7 +344,7 @@ public class XmlToNormalizedNodesTest {
                 .build();
 
         AugmentationNode myDoublyKeyedListAugNode = Builders.augmentationBuilder().withNodeIdentifier(
-                new AugmentationIdentifier(Collections.singleton(MY_DOUBLY_KEYED_LIST)))
+                new AugmentationIdentifier(ImmutableSet.of(MY_DOUBLY_KEYED_LIST)))
                 .withChild(myDoublyKeyedListNode).build();
 
         ContainerNode myContainer3Node = Builders.containerBuilder().withNodeIdentifier(
@@ -352,7 +352,7 @@ public class XmlToNormalizedNodesTest {
                 .withChild(myDoublyKeyedListAugNode).build();
 
         AugmentationNode myContainer3AugNode = Builders.augmentationBuilder().withNodeIdentifier(
-                new AugmentationIdentifier(Collections.singleton(MY_CONTAINER_3)))
+                new AugmentationIdentifier(ImmutableSet.of(MY_CONTAINER_3)))
                 .withChild(myContainer3Node).build();
 
         ContainerNode outerContainerNode = Builders.containerBuilder().withNodeIdentifier(
index 5cbd4d123443070c6937535773617be6dc17ef34..eee70541eaa9d6c7f1d6f88ea5b655babaf31a85 100644 (file)
@@ -11,12 +11,12 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import com.google.common.collect.ImmutableSet;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.text.ParseException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -241,7 +241,7 @@ public class ImmutableNormalizedNodeStreamWriterTest {
                 .build();
 
         AugmentationNode myDoublyKeyedListAugNode = Builders.augmentationBuilder().withNodeIdentifier(
-                new AugmentationIdentifier(Collections.singleton(myDoublyKeyedList)))
+                new AugmentationIdentifier(ImmutableSet.of(myDoublyKeyedList)))
                 .withChild(myDoublyKeyedListNode).build();
 
         ContainerNode myContainer3Node = Builders.containerBuilder().withNodeIdentifier(
@@ -249,7 +249,7 @@ public class ImmutableNormalizedNodeStreamWriterTest {
                 .withChild(myDoublyKeyedListAugNode).build();
 
         AugmentationNode myContainer3AugNode = Builders.augmentationBuilder().withNodeIdentifier(
-                new AugmentationIdentifier(Collections.singleton(myContainer3)))
+                new AugmentationIdentifier(ImmutableSet.of(myContainer3)))
                 .withChild(myContainer3Node).build();
 
         ContainerNode outerContainerNode = Builders.containerBuilder().withNodeIdentifier(
index 4b9373b9a5a8aef11010e4d79bfa4a0c4a8a5191..8b1dfe41c33bffb962fabb6bea89a358a3ed7ab8 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import static org.junit.Assert.assertEquals;
 
-import java.util.Collections;
+import com.google.common.collect.ImmutableSet;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -38,18 +38,16 @@ public class InstanceIdToNodesTest {
     private final NodeIdentifier outerContainer = new NodeIdentifier(QName.create(NS, REVISION, "outer-container"));
     private final NodeIdentifier augmentedLeaf = new NodeIdentifier(QName.create(NS, REVISION, "augmented-leaf"));
     private final AugmentationIdentifier augmentation = new AugmentationIdentifier(
-            Collections.singleton(augmentedLeaf.getNodeType()));
+            ImmutableSet.of(augmentedLeaf.getNodeType()));
 
-    private final NodeIdentifier outerList = new NodeIdentifier(
-            QName.create(NS, REVISION, "outer-list"));
+    private final NodeIdentifier outerList = new NodeIdentifier(QName.create(NS, REVISION, "outer-list"));
     private final NodeIdentifierWithPredicates outerListWithKey = NodeIdentifierWithPredicates.of(
             QName.create(NS, REVISION, "outer-list"), ID, 1);
     private final NodeIdentifier choice = new NodeIdentifier(QName.create(NS, REVISION, "outer-choice"));
     private final NodeIdentifier leafFromCase = new NodeIdentifier(QName.create(NS, REVISION, "one"));
 
     private final NodeIdentifier leafList = new NodeIdentifier(QName.create(NS, REVISION, "ordered-leaf-list"));
-    private final NodeWithValue<?> leafListWithValue = new NodeWithValue<>(
-            leafList.getNodeType(), "abcd");
+    private final NodeWithValue<?> leafListWithValue = new NodeWithValue<>(leafList.getNodeType(), "abcd");
 
     @BeforeClass
     public static void setUp() {
index 9c975bf9f8f349e7c804929c9c79e586dc13a2c3..7e9a77a335df98fd612c28a521ef44f1bb8c04cb 100644 (file)
@@ -9,6 +9,7 @@ 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.net.URI;
 import java.net.URISyntaxException;
@@ -93,7 +94,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();