Bug 865: Fixed use of removed deprecated YANGInstanceIdentifier methods.
[controller.git] / opendaylight / md-sal / sal-common-impl / src / test / java / org / opendaylight / controller / md / sal / common / impl / util / compat / DataNormalizerTest.java
index ddf089c68fd0e5000d0eec58d51b2ee841311bd0..3fa8d4e5e9ad48c57b3e811188d916c33e5c5f5f 100644 (file)
@@ -14,10 +14,13 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+
 import java.util.AbstractMap;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
@@ -25,15 +28,16 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+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;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.data.api.SimpleNode;
 import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
@@ -67,7 +71,7 @@ public class DataNormalizerTest {
         Class<?> nodeClass;
         Object nodeData; // List for a container, value Object for a leaf
 
-        NormalizedNodeData(PathArgument nodeID, Class<?> nodeClass, Object nodeData) {
+        NormalizedNodeData(final PathArgument nodeID, final Class<?> nodeClass, final Object nodeData) {
             this.nodeID = nodeID;
             this.nodeClass = nodeClass;
             this.nodeData = nodeData;
@@ -77,9 +81,9 @@ public class DataNormalizerTest {
     static class LegacyNodeData {
         QName nodeKey;
         Object nodeData; // List for a CompositeNode, value Object for a
-                         // SimpeNode
+        // SimpeNode
 
-        LegacyNodeData(QName nodeKey, Object nodeData) {
+        LegacyNodeData(final QName nodeKey, final Object nodeData) {
             this.nodeKey = nodeKey;
             this.nodeData = nodeData;
         }
@@ -99,8 +103,8 @@ public class DataNormalizerTest {
     static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
     static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
 
-    static final InstanceIdentifier TEST_PATH = InstanceIdentifier.of(TEST_QNAME);
-    static final InstanceIdentifier OUTER_LIST_PATH = InstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME)
+    static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
+    static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME)
             .build();
     static final QName ONE_QNAME = QName.create(TEST_QNAME, "one");
     static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
@@ -115,10 +119,10 @@ public class DataNormalizerTest {
 
     static final Short OUTER_LIST_ID = (short) 10;
 
-    static final InstanceIdentifier OUTER_LIST_PATH_LEGACY = InstanceIdentifier.builder(TEST_QNAME)
+    static final YangInstanceIdentifier OUTER_LIST_PATH_LEGACY = YangInstanceIdentifier.builder(TEST_PATH)
             .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, OUTER_LIST_ID).build();
 
-    static final InstanceIdentifier LEAF_TWO_PATH_LEGACY = InstanceIdentifier.builder(OUTER_LIST_PATH_LEGACY)
+    static final YangInstanceIdentifier LEAF_TWO_PATH_LEGACY = YangInstanceIdentifier.builder(OUTER_LIST_PATH_LEGACY)
             .node(TWO_QNAME).build();
 
     static final QName ANY_XML_LEAF_QNAME = QName.create(TEST_QNAME, "leaf");;
@@ -137,19 +141,19 @@ public class DataNormalizerTest {
         SchemaContext testCtx = createTestContext();
         DataNormalizer normalizer = new DataNormalizer(testCtx);
 
-        InstanceIdentifier normalizedPath = normalizer.toNormalized(LEAF_TWO_PATH_LEGACY);
+        YangInstanceIdentifier normalizedPath = normalizer.toNormalized(LEAF_TWO_PATH_LEGACY);
 
         verifyNormalizedInstanceIdentifier(normalizedPath, TEST_QNAME, OUTER_LIST_QNAME, new Object[] {
                 OUTER_LIST_QNAME, ID_QNAME, OUTER_LIST_ID }, OUTER_CHOICE_QNAME, TWO_QNAME);
     }
 
-    private void verifyNormalizedInstanceIdentifier(InstanceIdentifier actual, Object... expPath) {
+    private void verifyNormalizedInstanceIdentifier(final YangInstanceIdentifier actual, final Object... expPath) {
 
         assertNotNull("Actual InstanceIdentifier is null", actual);
-        assertEquals("InstanceIdentifier path length", expPath.length, actual.getPath().size());
+        assertEquals("InstanceIdentifier path length", expPath.length, Iterables.size(actual.getPathArguments()));
 
         for (int i = 0; i < expPath.length; i++) {
-            PathArgument actualArg = actual.getPath().get(i);
+            PathArgument actualArg = Iterables.get(actual.getPathArguments(), i);
             if (expPath[i] instanceof Object[]) { // NodeIdentifierWithPredicates
                 Object[] exp = (Object[]) expPath[i];
                 assertEquals("Actual path arg " + (i + 1) + " class", NodeIdentifierWithPredicates.class,
@@ -177,11 +181,11 @@ public class DataNormalizerTest {
 
         DataNormalizer normalizer = new DataNormalizer(createTestContext());
 
-        InstanceIdentifier normalized = InstanceIdentifier.builder().node(TEST_QNAME).node(OUTER_LIST_QNAME)
+        YangInstanceIdentifier normalized = YangInstanceIdentifier.builder().node(TEST_QNAME).node(OUTER_LIST_QNAME)
                 .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, OUTER_LIST_ID).node(OUTER_CHOICE_QNAME).node(TWO_QNAME)
                 .build();
 
-        InstanceIdentifier legacy = normalizer.toLegacy(normalized);
+        YangInstanceIdentifier legacy = normalizer.toLegacy(normalized);
 
         assertEquals("Legacy InstanceIdentifier", LEAF_TWO_PATH_LEGACY, legacy);
     }
@@ -255,12 +259,12 @@ public class DataNormalizerTest {
                                 expectCompositeNode(INNER_LIST_QNAME, expectSimpleNode(NAME_QNAME, "inner-name1"),
                                         expectSimpleNode(VALUE_QNAME, "inner-value1")),
 
-                                expectCompositeNode(INNER_LIST_QNAME, expectSimpleNode(NAME_QNAME, "inner-name2"),
-                                        expectSimpleNode(VALUE_QNAME, "inner-value2"))),
-                        expectCompositeNode(OUTER_LIST_QNAME, expectSimpleNode(ID_QNAME, outerListID2),
-                                expectSimpleNode(ONE_QNAME, "one")),
-                        expectCompositeNode(UNKEYED_LIST_QNAME, expectSimpleNode(NAME_QNAME, "unkeyed1")),
-                        expectCompositeNode(UNKEYED_LIST_QNAME, expectSimpleNode(NAME_QNAME, "unkeyed2"))));
+                                        expectCompositeNode(INNER_LIST_QNAME, expectSimpleNode(NAME_QNAME, "inner-name2"),
+                                                expectSimpleNode(VALUE_QNAME, "inner-value2"))),
+                                                expectCompositeNode(OUTER_LIST_QNAME, expectSimpleNode(ID_QNAME, outerListID2),
+                                                        expectSimpleNode(ONE_QNAME, "one")),
+                                                        expectCompositeNode(UNKEYED_LIST_QNAME, expectSimpleNode(NAME_QNAME, "unkeyed1")),
+                                                        expectCompositeNode(UNKEYED_LIST_QNAME, expectSimpleNode(NAME_QNAME, "unkeyed2"))));
 
         // Conversion of Mixin type nodes is not supported.
 
@@ -291,7 +295,7 @@ public class DataNormalizerTest {
                 .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)).withChild(testAnyXmlNode).build();
 
         DataNormalizer normalizer = new DataNormalizer(createTestContext());
-        Node<?> legacyNode = normalizer.toLegacy(InstanceIdentifier.builder(TEST_QNAME).build(), testContainerNode);
+        Node<?> legacyNode = normalizer.toLegacy(YangInstanceIdentifier.builder().node(TEST_QNAME).build(), testContainerNode);
 
         verifyLegacyNode(
                 legacyNode,
@@ -328,7 +332,7 @@ public class DataNormalizerTest {
 
         DataNormalizer normalizer = new DataNormalizer(createTestContext());
 
-        Node<?> legacyNode = normalizer.toLegacy(InstanceIdentifier.builder(TEST_QNAME).build(), testContainerNode);
+        Node<?> legacyNode = normalizer.toLegacy(YangInstanceIdentifier.builder().node(TEST_QNAME).build(), testContainerNode);
 
         verifyLegacyNode(
                 legacyNode,
@@ -355,7 +359,7 @@ public class DataNormalizerTest {
 
         DataNormalizer normalizer = new DataNormalizer(createTestContext());
 
-        Node<?> legacyNode = normalizer.toLegacy(InstanceIdentifier.builder(TEST_QNAME).build(), testContainerNode);
+        Node<?> legacyNode = normalizer.toLegacy(YangInstanceIdentifier.builder().node(TEST_QNAME).build(), testContainerNode);
 
         verifyLegacyNode(
                 legacyNode,
@@ -365,12 +369,12 @@ public class DataNormalizerTest {
                                 expectSimpleNode(AUGMENTED_LEAF_QNAME, "augmented-value"))));
     }
 
-    private boolean isOrdered(QName nodeName) {
+    private boolean isOrdered(final QName nodeName) {
         return ORDERED_LEAF_LIST_QNAME.equals(nodeName) || INNER_LIST_QNAME.equals(nodeName);
     }
 
     @SuppressWarnings("unchecked")
-    private void verifyLegacyNode(Node<?> actual, LegacyNodeData expNodeData) {
+    private void verifyLegacyNode(final Node<?> actual, final LegacyNodeData expNodeData) {
 
         assertNotNull("Actual Node is null", actual);
         assertTrue("Expected CompositeNode instance", actual instanceof CompositeNode);
@@ -389,16 +393,45 @@ public class DataNormalizerTest {
 
         Collections.sort(unorderdChildData, new Comparator<LegacyNodeData>() {
             @Override
-            public int compare(LegacyNodeData arg1, LegacyNodeData arg2) {
-                String str1 = arg1.nodeKey.getLocalName();
-                if (!(arg1.nodeData instanceof List))
-                    str1 += arg1.nodeData; // add simple node value
-
-                String str2 = arg2.nodeKey.getLocalName();
-                if (!(arg2.nodeData instanceof List))
-                    str2 += arg2.nodeData; // add simple node value
-
-                return str1.compareTo(str2);
+            public int compare(final LegacyNodeData arg1, final LegacyNodeData arg2) {
+                if (!(arg1.nodeData instanceof List) && !(arg2.nodeData instanceof List)) {
+                    // if neither is a list, just compare them
+                    String str1 = arg1.nodeKey.getLocalName() + arg1.nodeData;
+                    String str2 = arg2.nodeKey.getLocalName() + arg2.nodeData;
+                    return str1.compareTo(str2);
+                } else if (arg1.nodeData instanceof List && arg2.nodeData instanceof List) {
+                    // if both are lists, first check their local name
+                    String str1 = arg1.nodeKey.getLocalName();
+                    String str2 = arg2.nodeKey.getLocalName();
+                    if (!str1.equals(str2)) {
+                        return str1.compareTo(str2);
+                    } else {
+                        // if local names are the same, then look at the list contents
+                        List<LegacyNodeData> l1 = (List<LegacyNodeData>) arg1.nodeData;
+                        List<LegacyNodeData> l2 = (List<LegacyNodeData>) arg2.nodeData;
+
+                        if (l1.size() != l2.size()) {
+                            // if the sizes are different, use that
+                            return l2.size() - l1.size();
+                        } else {
+                            // lastly sort and recursively check the list contents
+                            Collections.sort(l1, this);
+                            Collections.sort(l2, this);
+
+                            for (int i = 0 ; i < l1.size() ; i++) {
+                                int diff = this.compare(l1.get(i), l2.get(i));
+                                if (diff != 0) {
+                                    return diff;
+                                }
+                            }
+                            return 0;
+                        }
+                    }
+                } else if( arg1.nodeData instanceof List ) {
+                    return -1;
+                } else{
+                    return 1;
+                }
             }
         });
 
@@ -416,16 +449,50 @@ public class DataNormalizerTest {
 
         Collections.sort(unorderedChildNodes, new Comparator<Node<?>>() {
             @Override
-            public int compare(Node<?> n1, Node<?> n2) {
-                String str1 = n1.getKey().getLocalName();
-                if (n1 instanceof SimpleNode)
-                    str1 += ((SimpleNode<?>) n1).getValue();
-
-                String str2 = n2.getKey().getLocalName();
-                if (n2 instanceof SimpleNode)
-                    str2 += ((SimpleNode<?>) n2).getValue();
-
-                return str1.compareTo(str2);
+            public int compare(final Node<?> n1, final Node<?> n2) {
+                if (n1 instanceof SimpleNode && n2 instanceof SimpleNode) {
+                    // if they're SimpleNodes just compare their strings
+                    String str1 = n1.getKey().getLocalName() + ((SimpleNode<?>)n1).getValue();
+                    String str2 = n2.getKey().getLocalName() + ((SimpleNode<?>)n2).getValue();
+                    return str1.compareTo(str2);
+                } else if (n1 instanceof CompositeNode && n2 instanceof CompositeNode) {
+                    // if they're CompositeNodes, things are more interesting
+                    String str1 = n1.getKey().getLocalName();
+                    String str2 = n2.getKey().getLocalName();
+                    if (!str1.equals(str2)) {
+                        // if their local names differ, return that difference
+                        return str1.compareTo(str2);
+                    } else {
+                        // otherwise, we need to look at their contents
+                        ArrayList<Node<?>> l1 = new ArrayList<Node<?>>( ((CompositeNode)n1).getValue() );
+                        ArrayList<Node<?>> l2 = new ArrayList<Node<?>>( ((CompositeNode)n2).getValue() );
+
+                        if (l1.size() != l2.size()) {
+                            // if they have different numbers of things in them return that
+                            return l2.size() - l1.size();
+                        } else {
+                            // otherwise, compare the individual elements, first sort them
+                            Collections.sort(l1, this);
+                            Collections.sort(l2, this);
+
+                            // then compare them individually
+                            for(int i = 0 ; i < l2.size() ; i++) {
+                                int diff = this.compare(l1.get(i), l2.get(i));
+                                if(diff != 0){
+                                    return diff;
+                                }
+                            }
+                            return 0;
+                        }
+                    }
+                } else if (n1 instanceof CompositeNode && n2 instanceof SimpleNode) {
+                    return -1;
+                } else if (n2 instanceof CompositeNode && n1 instanceof SimpleNode) {
+                    return 1;
+                } else {
+                    assertTrue("Expected either SimpleNodes CompositeNodes", false);
+                    return 0;
+                }
             }
         });
 
@@ -437,7 +504,7 @@ public class DataNormalizerTest {
             assertEquals("Child node QName", expData.nodeKey, actualChild.getKey());
 
             if (expData.nodeData instanceof List) { // List represents a
-                                                    // composite node
+                // composite node
                 verifyLegacyNode(actualChild, expData);
             } else { // else a simple node
                 assertTrue("Expected SimpleNode instance", actualChild instanceof SimpleNode);
@@ -451,11 +518,11 @@ public class DataNormalizerTest {
         }
     }
 
-    private LegacyNodeData expectCompositeNode(QName key, LegacyNodeData... childData) {
+    private LegacyNodeData expectCompositeNode(final QName key, final LegacyNodeData... childData) {
         return new LegacyNodeData(key, Lists.newArrayList(childData));
     }
 
-    private LegacyNodeData expectSimpleNode(QName key, Object value) {
+    private LegacyNodeData expectSimpleNode(final QName key, final Object value) {
         return new LegacyNodeData(key, value);
     }
 
@@ -496,8 +563,8 @@ public class DataNormalizerTest {
             testBuilder.add(unkeyedListBuilder.toInstance());
         }
 
-        Entry<InstanceIdentifier, NormalizedNode<?, ?>> normalizedNodeEntry = normalizer
-                .toNormalized(new AbstractMap.SimpleEntry<InstanceIdentifier, CompositeNode>(new InstanceIdentifier(
+        Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedNodeEntry = normalizer
+                .toNormalized(new AbstractMap.SimpleEntry<YangInstanceIdentifier, CompositeNode>(YangInstanceIdentifier.create(
                         ImmutableList.<PathArgument> of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance()));
 
         verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME);
@@ -519,25 +586,25 @@ public class DataNormalizerTest {
                                                 expectMapEntryNode(INNER_LIST_QNAME, NAME_QNAME, "inner-name3",
                                                         expectLeafNode(NAME_QNAME, "inner-name3"),
                                                         expectLeafNode(VALUE_QNAME, "inner-value3")),
-                                                expectMapEntryNode(INNER_LIST_QNAME, NAME_QNAME, "inner-name2",
-                                                        expectLeafNode(NAME_QNAME, "inner-name2"),
-                                                        expectLeafNode(VALUE_QNAME, "inner-value2")),
-                                                expectMapEntryNode(INNER_LIST_QNAME, NAME_QNAME, "inner-name1",
-                                                        expectLeafNode(NAME_QNAME, "inner-name1"),
-                                                        expectLeafNode(VALUE_QNAME, "inner-value1")))),
-                                expectMapEntryNode(
-                                        OUTER_LIST_QNAME,
-                                        ID_QNAME,
-                                        20,
-                                        expectLeafNode(ID_QNAME, 20),
-                                        expectChoiceNode(OUTER_CHOICE_QNAME, expectLeafNode(TWO_QNAME, "two"),
-                                                expectLeafNode(THREE_QNAME, "three")))),
-                        expectUnkeyedListNode(
-                                UNKEYED_LIST_QNAME,
-                                expectUnkeyedListEntryNode(UNKEYED_LIST_QNAME,
-                                        expectLeafNode(NAME_QNAME, "unkeyed-name1")),
-                                expectUnkeyedListEntryNode(UNKEYED_LIST_QNAME,
-                                        expectLeafNode(NAME_QNAME, "unkeyed-name2")))));
+                                                        expectMapEntryNode(INNER_LIST_QNAME, NAME_QNAME, "inner-name2",
+                                                                expectLeafNode(NAME_QNAME, "inner-name2"),
+                                                                expectLeafNode(VALUE_QNAME, "inner-value2")),
+                                                                expectMapEntryNode(INNER_LIST_QNAME, NAME_QNAME, "inner-name1",
+                                                                        expectLeafNode(NAME_QNAME, "inner-name1"),
+                                                                        expectLeafNode(VALUE_QNAME, "inner-value1")))),
+                                                                        expectMapEntryNode(
+                                                                                OUTER_LIST_QNAME,
+                                                                                ID_QNAME,
+                                                                                20,
+                                                                                expectLeafNode(ID_QNAME, 20),
+                                                                                expectChoiceNode(OUTER_CHOICE_QNAME, expectLeafNode(TWO_QNAME, "two"),
+                                                                                        expectLeafNode(THREE_QNAME, "three")))),
+                                                                                        expectUnkeyedListNode(
+                                                                                                UNKEYED_LIST_QNAME,
+                                                                                                expectUnkeyedListEntryNode(UNKEYED_LIST_QNAME,
+                                                                                                        expectLeafNode(NAME_QNAME, "unkeyed-name1")),
+                                                                                                        expectUnkeyedListEntryNode(UNKEYED_LIST_QNAME,
+                                                                                                                expectLeafNode(NAME_QNAME, "unkeyed-name2")))));
     }
 
     @Test
@@ -560,8 +627,8 @@ public class DataNormalizerTest {
         CompositeNode anyXmlLegacy = anyXmlBuilder.toInstance();
         testBuilder.add(anyXmlLegacy);
 
-        Entry<InstanceIdentifier, NormalizedNode<?, ?>> normalizedNodeEntry = normalizer
-                .toNormalized(new AbstractMap.SimpleEntry<InstanceIdentifier, CompositeNode>(new InstanceIdentifier(
+        Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedNodeEntry = normalizer
+                .toNormalized(new AbstractMap.SimpleEntry<YangInstanceIdentifier, CompositeNode>(YangInstanceIdentifier.create(
                         ImmutableList.<PathArgument> of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance()));
 
         verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME);
@@ -584,8 +651,8 @@ public class DataNormalizerTest {
 
         testBuilder.add(outerContBuilder.toInstance());
 
-        Entry<InstanceIdentifier, NormalizedNode<?, ?>> normalizedNodeEntry = normalizer
-                .toNormalized(new AbstractMap.SimpleEntry<InstanceIdentifier, CompositeNode>(new InstanceIdentifier(
+        Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedNodeEntry = normalizer
+                .toNormalized(new AbstractMap.SimpleEntry<YangInstanceIdentifier, CompositeNode>(YangInstanceIdentifier.create(
                         ImmutableList.<PathArgument> of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance()));
 
         verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME);
@@ -596,8 +663,8 @@ public class DataNormalizerTest {
         verifyNormalizedNode(normalizedNodeEntry.getValue(),
                 expectContainerNode(TEST_QNAME, expectContainerNode(OUTER_CONTAINER_QNAME, expAugmentation)));
 
-        normalizedNodeEntry = normalizer.toNormalized(new AbstractMap.SimpleEntry<InstanceIdentifier, CompositeNode>(
-                new InstanceIdentifier(Lists.newArrayList(new NodeIdentifier(TEST_QNAME), new NodeIdentifier(
+        normalizedNodeEntry = normalizer.toNormalized(new AbstractMap.SimpleEntry<YangInstanceIdentifier, CompositeNode>(
+                YangInstanceIdentifier.create(Lists.newArrayList(new NodeIdentifier(TEST_QNAME), new NodeIdentifier(
                         OUTER_CONTAINER_QNAME))), outerContBuilder.toInstance()));
 
         verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME, OUTER_CONTAINER_QNAME,
@@ -622,8 +689,8 @@ public class DataNormalizerTest {
             testBuilder.addLeaf(ORDERED_LEAF_LIST_QNAME, "ordered-value" + i);
         }
 
-        Entry<InstanceIdentifier, NormalizedNode<?, ?>> normalizedNodeEntry = normalizer
-                .toNormalized(new AbstractMap.SimpleEntry<InstanceIdentifier, CompositeNode>(new InstanceIdentifier(
+        Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedNodeEntry = normalizer
+                .toNormalized(new AbstractMap.SimpleEntry<YangInstanceIdentifier, CompositeNode>(YangInstanceIdentifier.create(
                         ImmutableList.<PathArgument> of(new NodeIdentifier(TEST_QNAME))), testBuilder.toInstance()));
 
         verifyNormalizedInstanceIdentifier(normalizedNodeEntry.getKey(), TEST_QNAME);
@@ -636,14 +703,14 @@ public class DataNormalizerTest {
                                 expectLeafSetEntryNode(UNORDERED_LEAF_LIST_QNAME, "unordered-value1"),
                                 expectLeafSetEntryNode(UNORDERED_LEAF_LIST_QNAME, "unordered-value2"),
                                 expectLeafSetEntryNode(UNORDERED_LEAF_LIST_QNAME, "unordered-value3")),
-                        expectOrderedLeafSetNode(ORDERED_LEAF_LIST_QNAME,
-                                expectLeafSetEntryNode(ORDERED_LEAF_LIST_QNAME, "ordered-value3"),
-                                expectLeafSetEntryNode(ORDERED_LEAF_LIST_QNAME, "ordered-value2"),
-                                expectLeafSetEntryNode(ORDERED_LEAF_LIST_QNAME, "ordered-value1"))));
+                                expectOrderedLeafSetNode(ORDERED_LEAF_LIST_QNAME,
+                                        expectLeafSetEntryNode(ORDERED_LEAF_LIST_QNAME, "ordered-value3"),
+                                        expectLeafSetEntryNode(ORDERED_LEAF_LIST_QNAME, "ordered-value2"),
+                                        expectLeafSetEntryNode(ORDERED_LEAF_LIST_QNAME, "ordered-value1"))));
     }
 
     @SuppressWarnings("unchecked")
-    private void verifyNormalizedNode(NormalizedNode<?, ?> actual, NormalizedNodeData expNodeData) {
+    private void verifyNormalizedNode(final NormalizedNode<?, ?> actual, final NormalizedNodeData expNodeData) {
 
         Class<?> expNodeClass = expNodeData.nodeClass;
         PathArgument expNodeID = expNodeData.nodeID;
@@ -679,18 +746,18 @@ public class DataNormalizerTest {
                 NormalizedNodeData expChildData = expNodeClass.equals(UnkeyedListNode.class) ? expChildDataList
                         .remove(0) : expChildDataMap.remove(actualChild.getIdentifier());
 
-                assertNotNull(
-                        "Unexpected child node " + actualChild.getClass() + " with identifier "
-                                + actualChild.getIdentifier() + " for parent node " + actual.getClass()
-                                + " with identifier " + actual.getIdentifier(), expChildData);
+                        assertNotNull(
+                                "Unexpected child node " + actualChild.getClass() + " with identifier "
+                                        + actualChild.getIdentifier() + " for parent node " + actual.getClass()
+                                        + " with identifier " + actual.getIdentifier(), expChildData);
 
-                if (orderingMap != null) {
-                    assertEquals("Order index for child node " + actualChild.getIdentifier(),
-                            orderingMap.get(actualChild.getIdentifier()), Integer.valueOf(i));
-                }
+                        if (orderingMap != null) {
+                            assertEquals("Order index for child node " + actualChild.getIdentifier(),
+                                    orderingMap.get(actualChild.getIdentifier()), Integer.valueOf(i));
+                        }
 
-                verifyNormalizedNode(actualChild, expChildData);
-                i++;
+                        verifyNormalizedNode(actualChild, expChildData);
+                        i++;
             }
 
             if (expNodeClass.equals(UnkeyedListNode.class)) {
@@ -707,62 +774,62 @@ public class DataNormalizerTest {
         }
     }
 
-    private NormalizedNodeData expectOrderedLeafSetNode(QName nodeName, NormalizedNodeData... childData) {
+    private NormalizedNodeData expectOrderedLeafSetNode(final QName nodeName, final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new NodeIdentifier(nodeName), OrderedLeafSetNode.class,
                 Lists.newArrayList(childData));
     }
 
-    private NormalizedNodeData expectLeafSetNode(QName nodeName, NormalizedNodeData... childData) {
+    private NormalizedNodeData expectLeafSetNode(final QName nodeName, final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new NodeIdentifier(nodeName), LeafSetNode.class, Lists.newArrayList(childData));
     }
 
-    private NormalizedNodeData expectLeafSetEntryNode(QName nodeName, Object value) {
+    private NormalizedNodeData expectLeafSetEntryNode(final QName nodeName, final Object value) {
         return new NormalizedNodeData(new NodeWithValue(nodeName, value), LeafSetEntryNode.class, value);
     }
 
-    private NormalizedNodeData expectUnkeyedListNode(QName nodeName, NormalizedNodeData... childData) {
+    private NormalizedNodeData expectUnkeyedListNode(final QName nodeName, final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new NodeIdentifier(nodeName), UnkeyedListNode.class,
                 Lists.newArrayList(childData));
     }
 
-    private NormalizedNodeData expectUnkeyedListEntryNode(QName nodeName, NormalizedNodeData... childData) {
+    private NormalizedNodeData expectUnkeyedListEntryNode(final QName nodeName, final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new NodeIdentifier(nodeName), UnkeyedListEntryNode.class,
                 Lists.newArrayList(childData));
     }
 
-    private NormalizedNodeData expectAugmentation(QName augmentedNodeName, NormalizedNodeData... childData) {
+    private NormalizedNodeData expectAugmentation(final QName augmentedNodeName, final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new AugmentationIdentifier(Sets.newHashSet(augmentedNodeName)),
                 AugmentationNode.class, Lists.newArrayList(childData));
     }
 
-    private NormalizedNodeData expectAnyXmlNode(QName nodeName, Object value) {
+    private NormalizedNodeData expectAnyXmlNode(final QName nodeName, final Object value) {
         return new NormalizedNodeData(new NodeIdentifier(nodeName), AnyXmlNode.class, value);
     }
 
-    private NormalizedNodeData expectContainerNode(QName nodeName, NormalizedNodeData... childData) {
+    private NormalizedNodeData expectContainerNode(final QName nodeName, final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new NodeIdentifier(nodeName), ContainerNode.class, Lists.newArrayList(childData));
     }
 
-    private NormalizedNodeData expectChoiceNode(QName nodeName, NormalizedNodeData... childData) {
+    private NormalizedNodeData expectChoiceNode(final QName nodeName, final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new NodeIdentifier(nodeName), ChoiceNode.class, Lists.newArrayList(childData));
     }
 
-    private NormalizedNodeData expectLeafNode(QName nodeName, Object value) {
+    private NormalizedNodeData expectLeafNode(final QName nodeName, final Object value) {
         return new NormalizedNodeData(new NodeIdentifier(nodeName), LeafNode.class, value);
 
     }
 
-    private NormalizedNodeData expectMapEntryNode(QName nodeName, QName key, Object value,
-            NormalizedNodeData... childData) {
+    private NormalizedNodeData expectMapEntryNode(final QName nodeName, final QName key, final Object value,
+            final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new NodeIdentifierWithPredicates(nodeName, key, value), MapEntryNode.class,
                 Lists.newArrayList(childData));
     }
 
-    private NormalizedNodeData expectMapNode(QName key, NormalizedNodeData... childData) {
+    private NormalizedNodeData expectMapNode(final QName key, final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new NodeIdentifier(key), MapNode.class, Lists.newArrayList(childData));
     }
 
-    private NormalizedNodeData expectOrderedMapNode(QName key, NormalizedNodeData... childData) {
+    private NormalizedNodeData expectOrderedMapNode(final QName key, final NormalizedNodeData... childData) {
         return new NormalizedNodeData(new NodeIdentifier(key), OrderedMapNode.class, Lists.newArrayList(childData));
     }
 }