Clean up use of Augmentation generics
[yangtools.git] / data / yang-data-tree-ri / src / test / java / org / opendaylight / yangtools / yang / data / tree / impl / Bug5968Test.java
index 104e7b84dcb83dc3a59f5f0edd8fc9233b420882..867a5abe504ace08698b30c07691c5af7e1649ee 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.fail;
 
-import com.google.common.collect.ImmutableMap;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
@@ -20,12 +19,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -77,18 +74,19 @@ class Bug5968Test {
     }
 
     private static DataTree initDataTree(final EffectiveModelContext schemaContext, final boolean withMapNode)
-            throws DataValidationFailedException {
+            throws Exception {
         final var inMemoryDataTree = new InMemoryDataTreeFactory().create(
                 DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
 
-        final var root = Builders.containerBuilder()
+        final var root = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT));
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
-        modificationTree.write(
-                YangInstanceIdentifier.of(ROOT),
-                withMapNode ? root.withChild(
-                        Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST)).build()).build() : root
-                        .build());
+        modificationTree.write(YangInstanceIdentifier.of(ROOT), withMapNode
+            ? root.withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(MY_LIST))
+                .build())
+                .build()
+                : root.build());
         modificationTree.ready();
 
         inMemoryDataTree.validate(modificationTree);
@@ -103,11 +101,11 @@ class Bug5968Test {
     }
 
     @Test
-    void writeInvalidContainerTest() throws DataValidationFailedException {
+    void writeInvalidContainerTest() throws Exception {
         final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
 
         final var myList = createMap(true);
-        final var root = Builders.containerBuilder()
+        final var root = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
@@ -126,7 +124,7 @@ class Bug5968Test {
     }
 
     @Test
-    void writeInvalidMapTest() throws DataValidationFailedException {
+    void writeInvalidMapTest() throws Exception {
         final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         writeMap(modificationTree, true);
@@ -144,7 +142,7 @@ class Bug5968Test {
     }
 
     @Test
-    void writeInvalidMapEntryTest() throws DataValidationFailedException {
+    void writeInvalidMapEntryTest() throws Exception {
         final var inMemoryDataTree = initDataTree(SCHEMA_CONTEXT, true);
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
@@ -163,11 +161,11 @@ class Bug5968Test {
     }
 
     private static void writeMap(final DataTreeModification modificationTree, final boolean mandatoryDataMissing) {
-        modificationTree.write(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMap(mandatoryDataMissing));
+        modificationTree.write(YangInstanceIdentifier.of(ROOTMY_LIST), createMap(mandatoryDataMissing));
     }
 
     private static SystemMapNode createMap(final boolean mandatoryDataMissing) {
-        return Builders.mapBuilder()
+        return ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MY_LIST))
             .withChild(mandatoryDataMissing ? createMapEntry("1", "common-value")
                 : createMapEntry("1", "mandatory-value", "common-value"))
@@ -175,38 +173,40 @@ class Bug5968Test {
     }
 
     private static void writeMapEntry(final DataTreeModification modificationTree, final Object listIdValue,
-            final Object mandatoryLeafValue, final Object commonLeafValue) throws DataValidationFailedException {
+            final Object mandatoryLeafValue, final Object commonLeafValue) {
         final var taskEntryNode = mandatoryLeafValue == null ? createMapEntry(listIdValue, commonLeafValue)
                 : createMapEntry(listIdValue, mandatoryLeafValue, commonLeafValue);
 
         modificationTree.write(
-                YangInstanceIdentifier.of(ROOT).node(MY_LIST)
-                        .node(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue))),
-                taskEntryNode);
+            YangInstanceIdentifier.of(ROOT, MY_LIST)
+                .node(NodeIdentifierWithPredicates.of(MY_LIST, LIST_ID, listIdValue)),
+            taskEntryNode);
     }
 
     private static MapEntryNode createMapEntry(final Object listIdValue, final Object mandatoryLeafValue,
             final Object commonLeafValue) {
-        return Builders.mapEntryBuilder()
-                .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
-                .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
-                .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue))
-                .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, LIST_ID, listIdValue))
+            .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
+            .withChild(ImmutableNodes.leafNode(MANDATORY_LEAF, mandatoryLeafValue))
+            .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue))
+            .build();
     }
 
     private static MapEntryNode createMapEntry(final Object listIdValue, final Object commonLeafValue) {
-        return Builders.mapEntryBuilder()
-                .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
-                .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
-                .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(MY_LIST, LIST_ID, listIdValue))
+            .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
+            .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue))
+            .build();
     }
 
     @Test
-    void writeValidContainerTest() throws DataValidationFailedException {
+    void writeValidContainerTest() throws Exception {
         final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
 
         final var myList = createMap(false);
-        final var root = Builders.containerBuilder()
+        final var root = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
@@ -218,7 +218,7 @@ class Bug5968Test {
     }
 
     @Test
-    void writeValidMapTest() throws DataValidationFailedException {
+    void writeValidMapTest() throws Exception {
         final var inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         writeMap(modificationTree, false);
@@ -230,7 +230,7 @@ class Bug5968Test {
     }
 
     @Test
-    void writeValidMapEntryTest() throws DataValidationFailedException {
+    void writeValidMapEntryTest() throws Exception {
         final var inMemoryDataTree = initDataTree(SCHEMA_CONTEXT, true);
         final var modificationTree = inMemoryDataTree.takeSnapshot().newModification();