Search in sources :

Example 16 with DataTree

use of org.opendaylight.yangtools.yang.data.tree.api.DataTree in project yangtools by opendaylight.

the class ConfigStatementValidationTest method testOnDataLeafFail.

@Test(expected = SchemaValidationFailedException.class)
public void testOnDataLeafFail() throws DataValidationFailedException {
    final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, SCHEMA_CONTEXT);
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.write(TestModel.TEST_PATH, createBarTestContainerNode());
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare);
}
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) InMemoryDataTreeFactory(org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory) Test(org.junit.Test)

Example 17 with DataTree

use of org.opendaylight.yangtools.yang.data.tree.api.DataTree in project yangtools by opendaylight.

the class Bug5830Test method testMandatoryDataLeafIsPresent.

private static void testMandatoryDataLeafIsPresent(final EffectiveModelContext schemaContext) throws DataValidationFailedException {
    final DataTree inMemoryDataTree = initDataTree(schemaContext);
    final MapEntryNode taskEntryNode = Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, ImmutableMap.of(TASK_ID, "123"))).withChild(ImmutableNodes.leafNode(TASK_ID, "123")).withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data")).withChild(createTaskDataContainer(true)).build();
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.write(YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK).node(NodeIdentifierWithPredicates.of(TASK, ImmutableMap.of(TASK_ID, "123"))), taskEntryNode);
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare);
}
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) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)

Example 18 with DataTree

use of org.opendaylight.yangtools.yang.data.tree.api.DataTree in project yangtools by opendaylight.

the class Bug5830Test method testContainerIsNotPresent.

private static void testContainerIsNotPresent(final EffectiveModelContext schemaContext) throws DataValidationFailedException {
    final DataTree inMemoryDataTree = initDataTree(schemaContext);
    final MapEntryNode taskEntryNode = Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, ImmutableMap.of(TASK_ID, "123"))).withChild(ImmutableNodes.leafNode(TASK_ID, "123")).withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data")).build();
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.write(YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK).node(NodeIdentifierWithPredicates.of(TASK, ImmutableMap.of(TASK_ID, "123"))), taskEntryNode);
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare);
}
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) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)

Example 19 with DataTree

use of org.opendaylight.yangtools.yang.data.tree.api.DataTree in project yangtools by opendaylight.

the class CaseAugmentTest method testWriteCase1All.

@Test
public void testWriteCase1All() throws DataValidationFailedException {
    final DataTree inMemoryDataTree = initDataTree();
    AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(AUGMENT_ID).withChild(leafNode(C1L2_QNAME, "leaf-value")).withChild(leafNode(C1L3_QNAME, "leaf-value")).build();
    final ContainerNode container = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).withChild(Builders.choiceBuilder().withNodeIdentifier(CHOICE_ID).withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value")).withChild(augmentationNode).build()).build();
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.write(TestModel.TEST_PATH, container);
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare);
}
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) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode) Test(org.junit.Test)

Example 20 with DataTree

use of org.opendaylight.yangtools.yang.data.tree.api.DataTree in project yangtools by opendaylight.

the class Bug5830Test method testContainerIsPresent.

private static void testContainerIsPresent(final EffectiveModelContext schemaContext) throws DataValidationFailedException {
    final DataTree inMemoryDataTree = initDataTree(schemaContext);
    final MapEntryNode taskEntryNode = Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(TASK, ImmutableMap.of(TASK_ID, "123"))).withChild(ImmutableNodes.leafNode(TASK_ID, "123")).withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data")).withChild(createTaskDataContainer(false)).build();
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.write(YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK).node(NodeIdentifierWithPredicates.of(TASK, ImmutableMap.of(TASK_ID, "123"))), taskEntryNode);
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare);
}
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) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)

Aggregations

DataTree (org.opendaylight.yangtools.yang.data.tree.api.DataTree)45 DataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)43 DataTreeCandidate (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate)41 Test (org.junit.Test)37 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)17 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)17 InMemoryDataTreeFactory (org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory)11 SystemMapNode (org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode)5 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)4 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)4 AugmentationNode (org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode)3 DataTreeConfiguration (org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration)2 LeafNode (org.opendaylight.yangtools.yang.data.api.schema.LeafNode)1 InMemoryDataTree (org.opendaylight.yangtools.yang.data.tree.impl.InMemoryDataTree)1 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)1