Clean up NormalizedNodeSerializeDeserializeTest
[mdsal.git] / binding / mdsal-binding-dom-codec / src / test / java / org / opendaylight / mdsal / binding / dom / codec / impl / NormalizedNodeSerializeDeserializeTest.java
index fee017b0366cae4017b7dbadcbf71ecb42d46e72..e79e3b7725554716eb1eac2335a3d8c16f04efc6 100644 (file)
@@ -7,41 +7,39 @@
  */
 package org.opendaylight.mdsal.binding.dom.codec.impl;
 
-import static java.util.Collections.singleton;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.top;
 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList;
 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.augmentationBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.leafSetBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.leafSetEntryBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.mapBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.orderedLeafSetBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.orderedMapBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment2;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment2Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugmentBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.AugmentChoice1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.Case1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.Case11Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.case11.Case11ChoiceCaseContainerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment1.AugmentChoice1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment1.augment.choice1.Case1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment2.augment.choice2.Case11Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment2.augment.choice2.case11.Case11ChoiceCaseContainerBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.ChoiceContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.ChoiceContainerBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
@@ -55,7 +53,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.te
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListKey;
 import org.opendaylight.yang.gen.v1.urn.test.foo4798.rev160101.Root;
@@ -72,20 +69,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
 
 public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodecTest {
-
     public static final String TOP_LEVEL_LIST_FOO_KEY_VALUE = "foo";
     public static final TopLevelListKey TOP_LEVEL_LIST_FOO_KEY = new TopLevelListKey(TOP_LEVEL_LIST_FOO_KEY_VALUE);
 
@@ -121,7 +106,7 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
 
     @Test
     public void containerToNormalized() {
-        final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = codecContext.toNormalizedNode(
+        final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
             InstanceIdentifier.create(Top.class), top());
         final ContainerNode topNormalized = getEmptyTop();
         assertEquals(topNormalized, entry.getValue());
@@ -136,9 +121,7 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
     }
 
     private static ContainerNode getEmptyTop() {
-        return ImmutableContainerNodeBuilder.create()
-                    .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
-                    .build();
+        return containerBuilder().withNodeIdentifier(new NodeIdentifier(TOP_QNAME)).build();
     }
 
     private static final QName AGUMENT_STRING_Q = QName.create(TOP_QNAME, "augmented-string");
@@ -148,11 +131,10 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
 
     @Test
     public void equalsWithAugment() {
-        final ContainerNode topNormalizedWithAugments = getNormalizedTopWithAugments(
-            augmentationBuilder()
-                .withNodeIdentifier(new AugmentationIdentifier(singleton(AGUMENT_STRING_Q)))
-                .withChild(ImmutableNodes.leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE))
-                .build());
+        final ContainerNode topNormalizedWithAugments = getNormalizedTopWithAugments(augmentationBuilder()
+            .withNodeIdentifier(new AugmentationIdentifier(Set.of(AGUMENT_STRING_Q)))
+            .withChild(leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE))
+            .build());
         final ContainerNode topNormalized = getEmptyTop();
 
         final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH,
@@ -169,8 +151,8 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
         // Equals on other(lazy, reversed) with no augmentation should be false
         assertNotEquals(entryWithAugments.getValue(), entry.getValue());
 
-        final Top topWithAugments = topWithAugments(Collections.<Class<? extends Augmentation<Top>>, Augmentation<Top>>
-            singletonMap(Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build()));
+        final Top topWithAugments = topWithAugments(
+            Map.of(Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build()));
         // Equals other with same augment should be true
         assertEquals(topWithAugments, entryWithAugments.getValue());
         // Equals other with same augment should be true
@@ -179,8 +161,7 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
         assertEquals(entryWithAugments.getValue(), entryWithAugments.getValue());
 
         final Top topWithAugmentsDiffValue = topWithAugments(
-            Collections.<Class<? extends Augmentation<Top>>, Augmentation<Top>>singletonMap(Top1.class,
-                new Top1Builder().setAugmentedString("differentValue").build()));
+            Map.of(Top1.class, new Top1Builder().setAugmentedString("differentValue").build()));
         assertNotEquals(topWithAugmentsDiffValue, entryWithAugments.getValue());
         assertNotEquals(entryWithAugments.getValue(), topWithAugmentsDiffValue);
     }
@@ -189,35 +170,33 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
     public void equalsWithMultipleAugments() {
         final ContainerNode topNormalizedWithAugments = getNormalizedTopWithAugments(
             augmentationBuilder()
-                .withNodeIdentifier(new AugmentationIdentifier(singleton(AGUMENT_STRING_Q)))
-                .withChild(ImmutableNodes.leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE))
+                .withNodeIdentifier(new AugmentationIdentifier(Set.of(AGUMENT_STRING_Q)))
+                .withChild(leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE))
                 .build(),
             augmentationBuilder()
-                .withNodeIdentifier(new AugmentationIdentifier(singleton(AUGMENT_INT_Q)))
-                .withChild(ImmutableNodes.leafNode(AUGMENT_INT_Q, AUGMENT_INT_VALUE))
+                .withNodeIdentifier(new AugmentationIdentifier(Set.of(AUGMENT_INT_Q)))
+                .withChild(leafNode(AUGMENT_INT_Q, AUGMENT_INT_VALUE))
                 .build());
 
         final Entry<InstanceIdentifier<?>, DataObject> entryWithAugments = codecContext.fromNormalizedNode(BI_TOP_PATH,
             topNormalizedWithAugments);
-        Map<Class<? extends Augmentation<Top>>, Augmentation<Top>> augments = new HashMap<>();
-        augments.put(Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build());
-        augments.put(Top2.class, new Top2Builder().setAugmentedInt(AUGMENT_INT_VALUE).build());
-        Top topWithAugments = topWithAugments(augments);
+        Top topWithAugments = topWithAugments(Map.of(
+            Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build(),
+            Top2.class, new Top2Builder().setAugmentedInt(AUGMENT_INT_VALUE).build()));
 
         assertEquals(topWithAugments, entryWithAugments.getValue());
         assertEquals(entryWithAugments.getValue(), topWithAugments);
 
-        augments = new HashMap<>();
-        augments.put(Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build());
-        augments.put(Top2.class, new Top2Builder().setAugmentedInt(999).build());
-        topWithAugments = topWithAugments(augments);
+        topWithAugments = topWithAugments(Map.of(
+            Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build(),
+            Top2.class, new Top2Builder().setAugmentedInt(999).build()));
 
         assertNotEquals(topWithAugments, entryWithAugments.getValue());
         assertNotEquals(entryWithAugments.getValue(), topWithAugments);
     }
 
     private static ContainerNode getNormalizedTopWithAugments(final AugmentationNode... augChild) {
-        final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder = ImmutableContainerNodeBuilder.create();
+        final var builder = containerBuilder();
 
         for (AugmentationNode augmentationNode : augChild) {
             builder.withChild(augmentationNode);
@@ -229,31 +208,31 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
     private static Top topWithAugments(
             final Map<Class<? extends Augmentation<Top>>, ? extends Augmentation<Top>> augments) {
         final TopBuilder topBuilder = new TopBuilder();
-        for (Entry<Class<? extends Augmentation<Top>>, ? extends Augmentation<Top>> augment : augments.entrySet()) {
-            topBuilder.addAugmentation(augment.getKey(), augment.getValue());
+        for (Augmentation<Top> augment : augments.values()) {
+            topBuilder.addAugmentation(augment);
         }
-        return topBuilder.setTopLevelList(Collections.emptyMap()).build();
+        return topBuilder.build();
     }
 
     @Test
     public void listWithKeysToNormalized() {
-        final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = codecContext.toNormalizedNode(
+        final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
             BA_TOP_LEVEL_LIST, topLevelList(TOP_LEVEL_LIST_FOO_KEY));
-        final MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
-                .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
-                    TOP_LEVEL_LIST_FOO_KEY_VALUE))
-                .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
-                .build();
+        final MapEntryNode topLevelListNormalized = mapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
+                TOP_LEVEL_LIST_FOO_KEY_VALUE))
+            .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+            .build();
         assertEquals(topLevelListNormalized, entry.getValue());
     }
 
     @Test
     public void listWithKeysFromNormalized() {
-        final MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
-                .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
-                    TOP_LEVEL_LIST_FOO_KEY_VALUE))
-                .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
-                .build();
+        final MapEntryNode topLevelListNormalized = mapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
+                TOP_LEVEL_LIST_FOO_KEY_VALUE))
+            .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+            .build();
         final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(
             BI_TOP_LEVEL_LIST_FOO_PATH, topLevelListNormalized);
         assertEquals(topLevelList(TOP_LEVEL_LIST_FOO_KEY), entry.getValue());
@@ -261,108 +240,96 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
 
     @Test
     public void leafOnlyAugmentationToNormalized() {
-        final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = codecContext.toNormalizedNode(
+        final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
             BA_TREE_LEAF_ONLY, new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build());
-        final Set<QName> augmentationChildren = new HashSet<>();
-        augmentationChildren.add(SIMPLE_VALUE_QNAME);
-        final AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
-                .withNodeIdentifier(new AugmentationIdentifier(augmentationChildren))
-                .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
-                .build();
+        final AugmentationNode augmentationNode = augmentationBuilder()
+            .withNodeIdentifier(new AugmentationIdentifier(Set.of(SIMPLE_VALUE_QNAME)))
+            .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
+            .build();
         assertEquals(augmentationNode, entry.getValue());
     }
 
     @Test
     public void leafOnlyAugmentationFromNormalized() {
-        final Set<QName> augmentationChildren = new HashSet<>();
-        augmentationChildren.add(SIMPLE_VALUE_QNAME);
-        final AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
-                .withNodeIdentifier(new AugmentationIdentifier(augmentationChildren))
-                .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
-                .build();
+        final AugmentationIdentifier augmentationId = new AugmentationIdentifier(Set.of(SIMPLE_VALUE_QNAME));
+        final AugmentationNode augmentationNode = augmentationBuilder()
+            .withNodeIdentifier(augmentationId)
+            .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
+            .build();
         final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(
-            BI_TOP_LEVEL_LIST_FOO_PATH.node(new AugmentationIdentifier(augmentationChildren)),
-            augmentationNode);
+            BI_TOP_LEVEL_LIST_FOO_PATH.node(augmentationId), augmentationNode);
         assertEquals(new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build(), entry.getValue());
     }
 
     @Test
     public void orderedleafListToNormalized() {
-        List<String> topLevelLeafList = new ArrayList<>();
-        topLevelLeafList.add("foo");
-        Top top = new TopBuilder().setTopLevelOrderedLeafList(topLevelLeafList).build();
+        Top top = new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build();
 
-        Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = codecContext.toNormalizedNode(
+        Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
             InstanceIdentifier.create(Top.class), top);
-        ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
-                .withChild(ImmutableOrderedLeafSetNodeBuilder.create()
-                        .withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
-                        .withChild(
-                                ImmutableLeafSetEntryNodeBuilder.create()
-                                        .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME,
-                                                "foo"))
-                                        .withValue("foo")
-                                        .build())
-                        .build())
-                .build();
+        ContainerNode containerNode = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
+            .withChild(orderedLeafSetBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
+                .withChild(leafSetEntryBuilder()
+                    .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo"))
+                    .withValue("foo")
+                    .build())
+                .build())
+            .build();
         assertEquals(containerNode, entry.getValue());
     }
 
     @Test
     public void leafListToNormalized() {
-        final List<String> topLevelLeafList = new ArrayList<>();
-        topLevelLeafList.add("foo");
-        final Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
+        final Top top = new TopBuilder().setTopLevelLeafList(Set.of("foo")).build();
 
-        final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = codecContext.toNormalizedNode(
+        final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
             InstanceIdentifier.create(Top.class), top);
-        final ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
-                .withChild(ImmutableLeafSetNodeBuilder.create()
-                        .withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
-                        .withChild(
-                                ImmutableLeafSetEntryNodeBuilder.create()
-                                        .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
-                                        .withValue("foo")
-                                        .build())
-                        .build())
-                .build();
+        final ContainerNode containerNode = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
+            .withChild(leafSetBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
+                .withChild(leafSetEntryBuilder()
+                    .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
+                    .withValue("foo")
+                    .build())
+                .build())
+            .build();
         assertEquals(containerNode, entry.getValue());
     }
 
     @Test
     public void leafListFromNormalized() {
-        final ContainerNode topWithLeafList = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
-                .withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(
-                    TOP_LEVEL_LEAF_LIST_QNAME))
-                    .withChild(ImmutableLeafSetEntryNodeBuilder.create()
-                        .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
-                        .withValue("foo").build()).build())
-                .build();
+        final ContainerNode topWithLeafList = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
+            .withChild(leafSetBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
+                .withChild(leafSetEntryBuilder()
+                    .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
+                    .withValue("foo")
+                    .build())
+                .build())
+            .build();
         final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH,
             topWithLeafList);
-        final List<String> topLevelLeafList = new ArrayList<>();
-        topLevelLeafList.add("foo");
-        final Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
+        final Top top = new TopBuilder().setTopLevelLeafList(Set.of("foo")).build();
         assertEquals(top, entry.getValue());
     }
 
     @Test
     public void orderedLeafListFromNormalized() {
-        ContainerNode topWithLeafList = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
-                .withChild(ImmutableOrderedLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(
-                    TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
-                    .withChild(ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
-                        new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo")).withValue("foo").build())
-                    .build())
-                .build();
+        ContainerNode topWithLeafList = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
+            .withChild(orderedLeafSetBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
+                .withChild(leafSetEntryBuilder()
+                    .withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo"))
+                    .withValue("foo").build())
+                .build())
+            .build();
         Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH, topWithLeafList);
-        List<String> topLevelLeafList = new ArrayList<>();
-        topLevelLeafList.add("foo");
-        Top top = new TopBuilder().setTopLevelOrderedLeafList(topLevelLeafList).build();
+        Top top = new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build();
         assertEquals(top, entry.getValue());
     }
 
@@ -370,16 +337,18 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
     public void choiceToNormalized() {
         final ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder()
             .setExtendedId(new ExtendedIdBuilder().setId("identifier_value").build()).build()).build();
-        final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = codecContext.toNormalizedNode(
+        final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
             InstanceIdentifier.create(ChoiceContainer.class), choiceContainerBA);
-        final ContainerNode choiceContainer = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new NodeIdentifier(CHOICE_CONTAINER_QNAME))
-                .withChild(ImmutableChoiceNodeBuilder.create()
-                    .withNodeIdentifier(new NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
-                        .withChild(ImmutableContainerNodeBuilder.create()
-                            .withNodeIdentifier(new NodeIdentifier(EXTENDED_ID_QNAME))
-                            .withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value")).build()).build())
-                .build();
+        final ContainerNode choiceContainer = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(CHOICE_CONTAINER_QNAME))
+            .withChild(choiceBuilder()
+                .withNodeIdentifier(new NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
+                .withChild(containerBuilder()
+                    .withNodeIdentifier(new NodeIdentifier(EXTENDED_ID_QNAME))
+                    .withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value"))
+                    .build())
+                .build())
+            .build();
         assertEquals(choiceContainer, entry.getValue());
     }
 
@@ -396,13 +365,13 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
 
         final YangInstanceIdentifier yangInstanceIdentifierOuter = YangInstanceIdentifier.of(
             containerIdentifierQname4798);
-        final ContainerNode containerNodeOuter = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new NodeIdentifier(containerIdentifierQname4798))
-                .withChild(ImmutableContainerNodeBuilder.create()
-                        .withNodeIdentifier(new NodeIdentifier(nestedContainerOuterQname))
-                        .withChild(leafNode(nestedContainerLeafOuterQname, "bar"))
-                        .build())
-                .build();
+        final ContainerNode containerNodeOuter = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(containerIdentifierQname4798))
+            .withChild(containerBuilder()
+                .withNodeIdentifier(new NodeIdentifier(nestedContainerOuterQname))
+                .withChild(leafNode(nestedContainerLeafOuterQname, "bar"))
+                .build())
+            .build();
         final Entry<InstanceIdentifier<?>, DataObject> entryContainer = codecContext.fromNormalizedNode(
             yangInstanceIdentifierOuter, containerNodeOuter);
         assertNotNull(entryContainer.getValue());
@@ -422,56 +391,56 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
                 .node(nestedContainerValidQname)
                 .node(nestedListQname4798)
                 .node(nodeIdentifierWithPredicates4798);
-        final ContainerNode containerNodeValid = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new NodeIdentifier(containerIdentifierQname4798))
-                .withChild(ImmutableChoiceNodeBuilder.create()
-                        .withNodeIdentifier(new NodeIdentifier(choiceIdentifierQname4798))
-                        .withChild(ImmutableContainerNodeBuilder.create()
-                                .withNodeIdentifier(new NodeIdentifier(nestedContainerValidQname))
-                                .withChild(ImmutableMapNodeBuilder.create()
-                                    .withNodeIdentifier(new NodeIdentifier(nestedListQname4798))
-                                        .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "foo"))
-                                        .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "bar"))
-                                        .build())
-                                .build())
+        final ContainerNode containerNodeValid = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(containerIdentifierQname4798))
+            .withChild(choiceBuilder()
+                .withNodeIdentifier(new NodeIdentifier(choiceIdentifierQname4798))
+                .withChild(containerBuilder()
+                    .withNodeIdentifier(new NodeIdentifier(nestedContainerValidQname))
+                    .withChild(mapBuilder()
+                        .withNodeIdentifier(new NodeIdentifier(nestedListQname4798))
+                        .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "foo"))
+                        .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "bar"))
                         .build())
-                .build();
-        try {
-            codecContext.fromNormalizedNode(yangInstanceIdentifierValid, containerNodeValid);
-            fail("Incorect YangInstanceIdentifier should fail");
-        } catch (IllegalStateException e) {
-            // Expected
-        }
+                    .build())
+                .build())
+            .build();
+
+        var msg = assertThrows(IllegalArgumentException.class,
+            () -> codecContext.fromNormalizedNode(yangInstanceIdentifierValid, containerNodeValid))
+            .getMessage();
+        assertEquals("Expecting either a MapEntryNode or an UnkeyedListEntryNode, not ContainerNode", msg);
+
+        final ContainerNode containerNode4798 = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(containerIdentifierQname4798))
+            .withChild(choiceBuilder()
+                .withNodeIdentifier(new NodeIdentifier(choiceIdentifierQname4798))
+                .withChild(mapBuilder()
+                    .withNodeIdentifier(new NodeIdentifier(nestedListQname4798))
+                    .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "foo"))
+                    .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "bar"))
+                    .build())
+                .build())
+            .build();
 
-        final ContainerNode containerNode4798 = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new NodeIdentifier(containerIdentifierQname4798))
-                .withChild(ImmutableChoiceNodeBuilder.create()
-                        .withNodeIdentifier(new NodeIdentifier(choiceIdentifierQname4798))
-                        .withChild(ImmutableMapNodeBuilder.create()
-                            .withNodeIdentifier(new NodeIdentifier(nestedListQname4798))
-                            .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "foo"))
-                            .withChild(mapEntry(nestedListQname4798, nestedListKeyQname4798, "bar"))
-                            .build())
-                        .build())
-                .build();
-        try {
-            codecContext.fromNormalizedNode(yangInstanceIdentifier4798, containerNode4798);
-            fail("Incorect YangInstanceIdentifier should fail");
-        } catch (IllegalStateException e) {
-            // Expected
-        }
+        msg = assertThrows(IllegalArgumentException.class,
+            () -> codecContext.fromNormalizedNode(yangInstanceIdentifier4798, containerNode4798))
+            .getMessage();
+        assertEquals("Expecting either a MapEntryNode or an UnkeyedListEntryNode, not ContainerNode", msg);
     }
 
     @Test
     public void choiceFromNormalized() {
-        final ContainerNode choiceContainerBI = ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new NodeIdentifier(CHOICE_CONTAINER_QNAME))
-                .withChild(ImmutableChoiceNodeBuilder.create()
-                    .withNodeIdentifier(new NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
-                    .withChild(ImmutableContainerNodeBuilder.create()
-                        .withNodeIdentifier(new NodeIdentifier(EXTENDED_ID_QNAME))
-                        .withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value")).build()).build())
-                .build();
+        final ContainerNode choiceContainerBI = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(CHOICE_CONTAINER_QNAME))
+            .withChild(choiceBuilder()
+                .withNodeIdentifier(new NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
+                .withChild(containerBuilder()
+                    .withNodeIdentifier(new NodeIdentifier(EXTENDED_ID_QNAME))
+                    .withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value"))
+                    .build())
+                .build())
+            .build();
         final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_CHOICE_CONTAINER_PATH,
             choiceContainerBI);
         final ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder()
@@ -481,18 +450,18 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
 
     @Test
     public void orderedLisToNormalized() {
-        final InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
-        final List<NestedList> nestedLists = new ArrayList<>();
-        nestedLists.add(new NestedListBuilder().withKey(new NestedListKey("foo")).build());
-        nestedLists.add(new NestedListBuilder().withKey(new NestedListKey("bar")).build());
-        final TopLevelList topLevelList = new TopLevelListBuilder().withKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(
-            nestedLists).build();
-        final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = codecContext.toNormalizedNode(ii,
+        final TopLevelList topLevelList = new TopLevelListBuilder()
+            .withKey(TOP_LEVEL_LIST_FOO_KEY)
+            .setNestedList(List.of(
+                new NestedListBuilder().withKey(new NestedListKey("foo")).build(),
+                new NestedListBuilder().withKey(new NestedListKey("bar")).build()))
+            .build();
+        final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST,
             topLevelList);
         final MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(
                 TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
                 .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
-                .withChild(ImmutableOrderedMapNodeBuilder.create()
+                .withChild(orderedMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME))
                     .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
                     .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar")).build()).build();
@@ -501,20 +470,24 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
 
     @Test
     public void orderedLisFromNormalized() {
-        final MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(
+        final MapEntryNode foo = mapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(
                 TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
-                .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
-                .withChild(ImmutableOrderedMapNodeBuilder.create()
-                    .withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME))
-                    .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
-                    .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar")).build()).build();
+            .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+            .withChild(orderedMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME))
+                .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
+                .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar"))
+                .build())
+            .build();
         final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(
             BI_TOP_LEVEL_LIST_FOO_PATH, foo);
-        final List<NestedList> nestedLists = new ArrayList<>();
-        nestedLists.add(new NestedListBuilder().withKey(new NestedListKey("foo")).build());
-        nestedLists.add(new NestedListBuilder().withKey(new NestedListKey("bar")).build());
-        final TopLevelList topLevelList = new TopLevelListBuilder().withKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(
-            nestedLists).build();
+        final TopLevelList topLevelList = new TopLevelListBuilder()
+            .withKey(TOP_LEVEL_LIST_FOO_KEY)
+            .setNestedList(List.of(
+                new NestedListBuilder().withKey(new NestedListKey("foo")).build(),
+                new NestedListBuilder().withKey(new NestedListKey("bar")).build()))
+            .build();
         assertEquals(topLevelList, entry.getValue());
     }
 
@@ -525,8 +498,8 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
         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(Set.of(augmentChoice1QName));
+        final AugmentationIdentifier aug2Id = new AugmentationIdentifier(Set.of(augmentChoice2QName));
         final NodeIdentifier augmentChoice1Id = new NodeIdentifier(augmentChoice1QName);
         final NodeIdentifier augmentChoice2Id = new NodeIdentifier(augmentChoice2QName);
         final NodeIdentifier containerId = new NodeIdentifier(containerQName);
@@ -540,27 +513,28 @@ public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodec
         cccc1Builder.setCase11ChoiceCaseLeaf("leaf-value");
         c11Builder.setCase11ChoiceCaseContainer(cccc1Builder.build());
         tca2Builder.setAugmentChoice2(c11Builder.build());
-        c1Builder.addAugmentation(TopChoiceAugment2.class, tca2Builder.build());
+        c1Builder.addAugmentation(tca2Builder.build());
         tca1Builder.setAugmentChoice1(c1Builder.build());
-        tBuilder.addAugmentation(TopChoiceAugment1.class, tca1Builder.build());
+        tBuilder.addAugmentation(tca1Builder.build());
         final Top top = tBuilder.build();
 
-        final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> biResult = codecContext.toNormalizedNode(
+        final Entry<YangInstanceIdentifier, NormalizedNode> biResult = codecContext.toNormalizedNode(
             InstanceIdentifier.create(Top.class), top);
 
-        final NormalizedNode<?, ?> topNormalized =
-                containerBuilder().withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
-                .withChild(augmentationBuilder().withNodeIdentifier(aug1Id)
-                        .withChild(choiceBuilder().withNodeIdentifier(augmentChoice1Id)
-                                .withChild(augmentationBuilder().withNodeIdentifier(aug2Id)
-                                        .withChild(choiceBuilder().withNodeIdentifier(augmentChoice2Id)
-                                                .withChild(containerBuilder().withNodeIdentifier(containerId)
-                                                        .withChild(leafNode(leafQName, "leaf-value"))
-                                                        .build())
-                                                .build())
-                                        .build())
+        final NormalizedNode topNormalized = containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
+            .withChild(augmentationBuilder().withNodeIdentifier(aug1Id)
+                .withChild(choiceBuilder().withNodeIdentifier(augmentChoice1Id)
+                    .withChild(augmentationBuilder().withNodeIdentifier(aug2Id)
+                        .withChild(choiceBuilder().withNodeIdentifier(augmentChoice2Id)
+                            .withChild(containerBuilder().withNodeIdentifier(containerId)
+                                .withChild(leafNode(leafQName, "leaf-value"))
                                 .build())
-                        .build()).build();
+                            .build())
+                        .build())
+                    .build())
+                .build())
+            .build();
 
         assertEquals(BI_TOP_PATH, biResult.getKey());
         assertEquals(topNormalized, biResult.getValue());