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);
}
.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();
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());