Search in sources :

Example 1 with InMemoryDataTreeFactory

use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.

the class Bug3674Test method setUp.

@Before
public void setUp() throws DataValidationFailedException {
    tree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
    // Create the top-level container
    final DataTreeModification mod = tree.takeSnapshot().newModification();
    mod.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
    mod.ready();
    tree.commit(tree.prepare(mod));
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) InMemoryDataTreeFactory(org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory) Before(org.junit.Before)

Example 2 with InMemoryDataTreeFactory

use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.

the class Bug4454Test method prepare.

@Before
public void prepare() throws DataValidationFailedException {
    inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, schemaContext);
    final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
    final DataTreeModification modificationTree = initialDataTreeSnapshot.newModification();
    modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.containerNode(MASTER_CONTAINER_QNAME));
    modificationTree.ready();
    inMemoryDataTree.commit(inMemoryDataTree.prepare(modificationTree));
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot) InMemoryDataTreeFactory(org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory) Before(org.junit.Before)

Example 3 with InMemoryDataTreeFactory

use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.

the class Bug5968MergeTest method initDataTree.

private static DataTree initDataTree(final EffectiveModelContext schemaContext, final boolean withMapNode) throws DataValidationFailedException {
    final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(ROOT));
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.merge(YangInstanceIdentifier.of(ROOT), withMapNode ? root.withChild(Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST)).build()).build() : root.build());
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare);
    return inMemoryDataTree;
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) DataTreeCandidate(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate) DataTree(org.opendaylight.yangtools.yang.data.tree.api.DataTree) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) InMemoryDataTreeFactory(org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory)

Example 4 with InMemoryDataTreeFactory

use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.

the class MapEntryRootTest method testMapEntryRoot.

@Test
public void testMapEntryRoot() {
    final DataTreeConfiguration treeConfig = DataTreeConfiguration.builder(TreeType.OPERATIONAL).setRootPath(TestModel.TEST_PATH.node(TestModel.OUTER_LIST_QNAME).node(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, (short) 12))).build();
    final DataTree dataTree = new InMemoryDataTreeFactory().create(treeConfig, SCHEMA_CONTEXT);
    assertTrue(dataTree instanceof InMemoryDataTree);
    final InMemoryDataTree imdt = (InMemoryDataTree) dataTree;
    final InMemoryDataTreeModification mod = imdt.takeSnapshot().newModification();
    final ModificationApplyOperation strategy = mod.getStrategy();
    assertThat(strategy, instanceOf(MapEntryModificationStrategy.class));
}
Also used : DataTree(org.opendaylight.yangtools.yang.data.tree.api.DataTree) DataTreeConfiguration(org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration) InMemoryDataTreeFactory(org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory) Test(org.junit.Test)

Example 5 with InMemoryDataTreeFactory

use of org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory in project yangtools by opendaylight.

the class DataTreeCandidatesTest method setUp.

@Before
public void setUp() throws Exception {
    dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
    final ContainerNode testContainer = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).withChild(ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME)).build()).build();
    final InMemoryDataTreeModification modification = (InMemoryDataTreeModification) dataTree.takeSnapshot().newModification();
    final DataTreeModificationCursor cursor = modification.openCursor();
    cursor.write(TestModel.TEST_PATH.getLastPathArgument(), testContainer);
    modification.ready();
    dataTree.validate(modification);
    final DataTreeCandidate candidate = dataTree.prepare(modification);
    dataTree.commit(candidate);
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) DataTreeModificationCursor(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModificationCursor) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) InMemoryDataTreeFactory(org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory) Before(org.junit.Before)

Aggregations

InMemoryDataTreeFactory (org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory)21 DataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)17 DataTreeCandidate (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate)13 DataTree (org.opendaylight.yangtools.yang.data.tree.api.DataTree)11 Test (org.junit.Test)8 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)8 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)6 Before (org.junit.Before)5 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)5 BeforeClass (org.junit.BeforeClass)3 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)3 Module (org.opendaylight.yangtools.yang.model.api.Module)3 DataTreeConfiguration (org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration)2 DataTreeSnapshot (org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot)2 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)2 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)1 LeafNode (org.opendaylight.yangtools.yang.data.api.schema.LeafNode)1 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)1 SystemMapNode (org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode)1 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.CursorAwareDataTreeModification)1