Remove YangModeledAnyxmlSchemaNode
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / schema / BuilderTest.java
index 4af3852aad68860210f1a98afff7ef87ba26a1f5..800912dd710dbd637c3e3c6f235efa9a323169a6 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.mock;
 
 import java.io.File;
@@ -19,7 +20,6 @@ import java.util.LinkedList;
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.yangtools.odlext.model.api.YangModeledAnyXmlSchemaNode;
 import org.opendaylight.yangtools.util.UnmodifiableCollection;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -30,12 +30,13 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
@@ -49,13 +50,12 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLe
 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.ImmutableMapNodeSchemaAwareBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeSchemaAwareBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeSchemaAwareBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableYangModeledAnyXmlNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUserLeafSetNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUserLeafSetNodeSchemaAwareBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUserMapNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUserMapNodeSchemaAwareBuilder;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
@@ -106,59 +106,59 @@ public class BuilderTest {
         mapEntryNodeColl.add(LIST_MAIN_CHILD_3);
         final Map<QName, Object> keys = new HashMap<>();
         keys.put(LIST_MAIN_CHILD_QNAME_1, 1);
-        final NodeIdentifierWithPredicates mapEntryPath = new NodeIdentifierWithPredicates(LIST_MAIN, keys);
-        final OrderedMapNode orderedMapNodeCreateNull = ImmutableOrderedMapNodeBuilder.create()
+        final NodeIdentifierWithPredicates mapEntryPath = NodeIdentifierWithPredicates.of(LIST_MAIN, keys);
+        final UserMapNode orderedMapNodeCreateNull = ImmutableUserMapNodeBuilder.create()
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .withChild(LIST_MAIN_CHILD_1)
                 .addChild(LIST_MAIN_CHILD_2)
                 .withValue(mapEntryNodeColl)
                 .build();
-        final OrderedMapNode orderedMapNodeCreateSize = ImmutableOrderedMapNodeBuilder.create(SIZE)
+        final UserMapNode orderedMapNodeCreateSize = ImmutableUserMapNodeBuilder.create(SIZE)
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .build();
-        final OrderedMapNode orderedMapNodeCreateNode = ImmutableOrderedMapNodeBuilder.create(orderedMapNodeCreateNull)
+        final UserMapNode orderedMapNodeCreateNode = ImmutableUserMapNodeBuilder.create(orderedMapNodeCreateNull)
                 .removeChild(mapEntryPath)
                 .build();
-        final OrderedMapNode orderedMapNodeSchemaAware = ImmutableOrderedMapNodeSchemaAwareBuilder.create(list)
+        final UserMapNode orderedMapNodeSchemaAware = ImmutableUserMapNodeSchemaAwareBuilder.create(list)
                 .withChild(LIST_MAIN_CHILD_1)
                 .build();
-        final OrderedMapNode orderedMapNodeSchemaAwareMapNodeConst = ImmutableOrderedMapNodeSchemaAwareBuilder.create(
-                list, getImmutableOrderedMapNode())
+        final UserMapNode orderedMapNodeSchemaAwareMapNodeConst = ImmutableUserMapNodeSchemaAwareBuilder.create(
+                list, getImmutableUserMapNode())
                 .build();
 
         assertNotNull(Builders.orderedMapBuilder(list));
-        assertEquals(SIZE, orderedMapNodeCreateNull.getSize());
-        assertEquals(orderedMapNodeCreateNode.getSize(), orderedMapNodeCreateNull.getSize() - 1);
+        assertEquals(SIZE, orderedMapNodeCreateNull.size());
+        assertEquals(orderedMapNodeCreateNode.size(), orderedMapNodeCreateNull.size() - 1);
         assertEquals(NODE_IDENTIFIER_LIST, orderedMapNodeCreateSize.getIdentifier());
         assertEquals(LIST_MAIN_CHILD_1, orderedMapNodeCreateNull.getChild(0));
-        assertEquals(SIZE, orderedMapNodeCreateNull.getValue().size());
+        assertEquals(SIZE, orderedMapNodeCreateNull.size());
         assertEquals(orderedMapNodeSchemaAware.getChild(0), orderedMapNodeSchemaAwareMapNodeConst.getChild(0));
     }
 
     @Test
-    public void immutableOrderedLeafSetNodeBuilderTest() {
-        final NormalizedNode<?, ?> orderedLeafSet = ImmutableOrderedLeafSetNodeBuilder.<String>create()
+    public void immutableUserLeafSetNodeBuilderTest() {
+        final UserLeafSetNode<String> orderedLeafSet = ImmutableUserLeafSetNodeBuilder.<String>create()
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .withChild(LEAF_SET_ENTRY_NODE)
                 .withChildValue("baz")
                 .removeChild(BAR_PATH)
                 .build();
         final LinkedList<LeafSetNode<?>> mapEntryNodeColl = new LinkedList<>();
-        mapEntryNodeColl.add((LeafSetNode<?>)orderedLeafSet);
-        final UnmodifiableCollection<?> leafSetCollection = (UnmodifiableCollection<?>)orderedLeafSet.getValue();
-        final NormalizedNode<?, ?> orderedMapNodeSchemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(
+        mapEntryNodeColl.add(orderedLeafSet);
+        final UnmodifiableCollection<?> leafSetCollection = (UnmodifiableCollection<?>)orderedLeafSet.body();
+        final NormalizedNode orderedMapNodeSchemaAware = ImmutableUserLeafSetNodeSchemaAwareBuilder.create(
             leafList).withChildValue("baz").build();
         final UnmodifiableCollection<?> SchemaAwareleafSetCollection =
-                (UnmodifiableCollection<?>)orderedMapNodeSchemaAware.getValue();
-        final NormalizedNode<?, ?> orderedLeafSetShemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(
-            leafList,(LeafSetNode<?>)orderedLeafSet).build();
+                (UnmodifiableCollection<?>) orderedMapNodeSchemaAware.body();
+        final NormalizedNode orderedLeafSetShemaAware = ImmutableUserLeafSetNodeSchemaAwareBuilder.create(
+            leafList, (UserLeafSetNode<?>) orderedLeafSet).build();
 
         assertNotNull(Builders.orderedLeafSetBuilder(leafList));
         assertNotNull(Builders.anyXmlBuilder());
         assertNotNull(orderedLeafSetShemaAware);
-        assertEquals(1, ((OrderedLeafSetNode<?>)orderedLeafSet).getSize());
-        assertEquals("baz", ((OrderedLeafSetNode<?>)orderedLeafSet).getChild(0).getValue());
-        assertNotNull(((OrderedLeafSetNode<?>)orderedLeafSet).getChild(BAR_PATH));
+        assertEquals(1, ((UserLeafSetNode<?>)orderedLeafSet).size());
+        assertEquals("baz", orderedLeafSet.getChild(0).body());
+        assertNull(orderedLeafSet.childByArg(BAR_PATH));
         assertEquals(1, leafSetCollection.size());
         assertEquals(1, SchemaAwareleafSetCollection.size());
     }
@@ -167,13 +167,14 @@ public class BuilderTest {
     public void immutableMapNodeBuilderTest() {
         final LinkedList<MapEntryNode> mapEntryNodeColl = new LinkedList<>();
         mapEntryNodeColl.add(LIST_MAIN_CHILD_3);
-        final CollectionNodeBuilder<MapEntryNode, MapNode> collectionNodeBuilder = ImmutableMapNodeBuilder.create(1);
+        final CollectionNodeBuilder<MapEntryNode, SystemMapNode> collectionNodeBuilder =
+            ImmutableMapNodeBuilder.create(1);
         assertNotNull(collectionNodeBuilder);
         collectionNodeBuilder.withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST);
         collectionNodeBuilder.withValue(mapEntryNodeColl);
-        final MapNode mapNode = collectionNodeBuilder.build();
-        final MapNode mapNodeSchemaAware = ImmutableMapNodeSchemaAwareBuilder.create(list, getImmutableMapNode())
-                .build();
+        final SystemMapNode mapNode = collectionNodeBuilder.build();
+        final SystemMapNode mapNodeSchemaAware = ImmutableMapNodeSchemaAwareBuilder.create(list,
+            getImmutableMapNode()).build();
         assertNotNull(mapNodeSchemaAware);
         assertNotNull(Builders.mapBuilder(mapNode));
     }
@@ -216,7 +217,7 @@ public class BuilderTest {
             // Ignored on purpose
         }
 
-        assertNotNull(unkeyedListNodeSize.getValue());
+        assertNotNull(unkeyedListNodeSize.body());
         assertEquals(unkeyedListEntryNode, unkeyedListNodeCreated.getChild(0));
         assertEquals(unkeyedListNode.getNodeType().getLocalName(), unkeyedListNodeSize.getNodeType()
                 .getLocalName());
@@ -251,7 +252,7 @@ public class BuilderTest {
 
     @Test(expected = NullPointerException.class)
     public void immutableLeafSetNodeBuilderExceptionTest() {
-        final LeafSetNode<?> leafSetNode = ImmutableLeafSetNodeBuilder.create(1)
+        final SystemLeafSetNode<Object> leafSetNode = ImmutableLeafSetNodeBuilder.create(1)
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST).build();
         assertNotNull(leafSetNode);
         ImmutableLeafSetNodeSchemaAwareBuilder.create(mock(LeafListSchemaNode.class), leafSetNode).build();
@@ -268,22 +269,12 @@ public class BuilderTest {
         ImmutableMapEntryNodeBuilder.create(1).build();
     }
 
-    @Test(expected = NullPointerException.class)
-    public void immutableYangModeledAnyXmlNodeBuilderExceptionTest() {
-        ImmutableYangModeledAnyXmlNodeBuilder.create(mock(YangModeledAnyXmlSchemaNode.class), 1);
-    }
-
     @Test(expected = UnsupportedOperationException.class)
     public void immutableUnkeyedListNodeBuilderExceptionTest() {
         ImmutableUnkeyedListNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LEAF)
                 .removeChild(NODE_IDENTIFIER_LIST).build();
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void immutableOrderedMapNotSchemaAwareExceptionTest1() {
-        ImmutableOrderedMapNodeBuilder.create(getImmutableMapNode()).build();
-    }
-
     @Test(expected = UnsupportedOperationException.class)
     public void immutableMapNodeSchemaAwareExceptionTest() {
         ImmutableMapNodeSchemaAwareBuilder.create(list, getImmutableMapNode()).withNodeIdentifier(NODE_IDENTIFIER_LIST)
@@ -292,39 +283,29 @@ public class BuilderTest {
 
     @Test(expected = UnsupportedOperationException.class)
     public void immutableOrderedMapSchemaAwareExceptionTest1() {
-        ImmutableOrderedMapNodeSchemaAwareBuilder.create(list).withNodeIdentifier(NODE_IDENTIFIER_LIST).build();
-    }
-
-    @Test(expected = UnsupportedOperationException.class)
-    public void immutableOrderedMapSchemaAwareExceptionTest2() {
-        ImmutableOrderedMapNodeSchemaAwareBuilder.create(list, getImmutableMapNode()).build();
-    }
-
-    @Test(expected = UnsupportedOperationException.class)
-    public void immutableOrderedLeafSetNodeExceptionTest1() {
-        ImmutableOrderedLeafSetNodeBuilder.create(getImmutableLeafSetNode()).build();
+        ImmutableUserMapNodeSchemaAwareBuilder.create(list).withNodeIdentifier(NODE_IDENTIFIER_LIST).build();
     }
 
     @Test(expected = UnsupportedOperationException.class)
-    public void immutableOrderedLeafSetNodeSchemaAwareExceptionTest1() {
-        ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList).withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
+    public void immutableUserLeafSetNodeSchemaAwareExceptionTest1() {
+        ImmutableUserLeafSetNodeSchemaAwareBuilder.create(leafList).withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
         .build();
     }
 
-    private static LeafSetNode<?> getImmutableLeafSetNode() {
-        final ListNodeBuilder<String, LeafSetEntryNode<String>> leafSetBuilder = Builders.leafSetBuilder();
+    private static SystemLeafSetNode<String> getImmutableLeafSetNode() {
+        final ListNodeBuilder<String, SystemLeafSetNode<String>> leafSetBuilder = Builders.leafSetBuilder();
         leafSetBuilder.withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST);
         leafSetBuilder.addChild(LEAF_SET_ENTRY_NODE);
         return leafSetBuilder.build();
     }
 
-    private static MapNode getImmutableMapNode() {
+    private static SystemMapNode getImmutableMapNode() {
         return ImmutableMapNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LIST).withChild(LIST_MAIN_CHILD_1)
                 .build();
     }
 
-    private static MapNode getImmutableOrderedMapNode() {
-        return ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LIST)
+    private static UserMapNode getImmutableUserMapNode() {
+        return ImmutableUserMapNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .withChild(LIST_MAIN_CHILD_1).build();
     }
 }