Cleanup DataTree interfaces and InMemmoryDataTreeFactory
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / Bug2690Test.java
index 39ad37f2c538e822d028f3cb3ac83c5b18697dd9..f4fcdfd6222190fa5985b27aaa28506d3e832a1a 100644 (file)
@@ -20,29 +20,31 @@ 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.NormalizedNodeContainer;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug2690Test {
     private static final String ODL_DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
     private SchemaContext schemaContext;
-    private InMemoryDataTree inMemoryDataTree;
+    private DataTree inMemoryDataTree;
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
-        inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
-        inMemoryDataTree.setSchemaContext(schemaContext);
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+            schemaContext);
     }
 
-    public static SchemaContext createTestContext() throws ReactorException {
+    public static SchemaContext createTestContext() {
         return YangParserTestUtils.parseYangResource(ODL_DATASTORE_TEST_YANG);
     }
 
@@ -65,7 +67,7 @@ public class Bug2690Test {
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
                 .withChild(mapNode2).build();
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, cont1);
         modificationTree.merge(TestModel.TEST_PATH, cont2);
         modificationTree.ready();
@@ -74,8 +76,8 @@ public class Bug2690Test {
         final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
         inMemoryDataTree.commit(prepare);
 
-        final InMemoryDataTreeSnapshot snapshotAfterTx = inMemoryDataTree.takeSnapshot();
-        final InMemoryDataTreeModification modificationAfterTx = snapshotAfterTx.newModification();
+        final DataTreeSnapshot snapshotAfterTx = inMemoryDataTree.takeSnapshot();
+        final DataTreeModification modificationAfterTx = snapshotAfterTx.newModification();
         final Optional<NormalizedNode<?, ?>> readNode = modificationAfterTx.readNode(TestModel.OUTER_LIST_PATH);
         assertTrue(readNode.isPresent());
         assertEquals(2, ((NormalizedNodeContainer<?,?,?>)readNode.get()).getValue().size());