Do not use ShardDataTree in PruningDataTreeModificationTest
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / utils / PruningDataTreeModificationTest.java
index 5e7c1cadff8f14b14d56e01929c9a74405202412..7bf7d500866feca453330b922c54f8958b5f6cfb 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModificationCursor;
@@ -180,21 +181,23 @@ public class PruningDataTreeModificationTest {
     }
 
     @Test
-    public void testWriteRootNode() throws Exception{
-        ShardDataTree shardDataTree = new ShardDataTree(SCHEMA_CONTEXT, TreeType.CONFIGURATION);
-        DataTreeModification mod = shardDataTree.newModification();
+    public void testWriteRootNode() throws Exception {
+        final DataTree localDataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION);
+        localDataTree.setSchemaContext(SCHEMA_CONTEXT);
 
+        DataTreeModification mod = localDataTree.takeSnapshot().newModification();
         mod.write(CarsModel.BASE_PATH, CarsModel.create());
-        shardDataTree.commit(mod);
+        mod.ready();
+        localDataTree.validate(mod);
+        localDataTree.commit(localDataTree.prepare(mod));
 
-        NormalizedNode<?, ?> normalizedNode = shardDataTree.readNode(YangInstanceIdentifier.EMPTY).get();
+        NormalizedNode<?, ?> normalizedNode = dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY).get();
         pruningDataTreeModification.write(YangInstanceIdentifier.EMPTY, normalizedNode);
         dataTree.commit(getCandidate());
 
         Optional<NormalizedNode<?, ?>> actual = dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY);
         assertEquals("Root present", true, actual.isPresent());
         assertEquals("Root node", normalizedNode, actual.get());
-
     }
 
     @Test
@@ -292,4 +295,4 @@ public class PruningDataTreeModificationTest {
         DataTreeCandidateTip candidate = dataTree.prepare(mod);
         return candidate;
     }
-}
\ No newline at end of file
+}