Search in sources :

Example 16 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project controller by opendaylight.

the class CompositeModel method createFamily.

public static ContainerNode createFamily() {
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> familyContainerBuilder = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(FAMILY_QNAME));
    final CollectionNodeBuilder<MapEntryNode, SystemMapNode> childrenBuilder = mapNodeBuilder(CHILDREN_QNAME);
    final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> firstChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
    final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> secondChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
    final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> firstGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, FIRST_GRAND_CHILD_ID);
    final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> secondGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID);
    firstGrandChildBuilder.withChild(ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, FIRST_GRAND_CHILD_ID)).withChild(ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, FIRST_GRAND_CHILD_NAME));
    secondGrandChildBuilder.withChild(ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID)).withChild(ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, SECOND_GRAND_CHILD_NAME));
    firstChildBuilder.withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)).withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)).withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(firstGrandChildBuilder.build()).build());
    secondChildBuilder.withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)).withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)).withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(firstGrandChildBuilder.build()).build());
    childrenBuilder.withChild(firstChildBuilder.build());
    childrenBuilder.withChild(secondChildBuilder.build());
    return familyContainerBuilder.withChild(childrenBuilder.build()).build();
}
Also used : SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Example 17 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project yangtools by opendaylight.

the class Bug5830Test method initDataTree.

private static DataTree initDataTree(final EffectiveModelContext schemaContext) throws DataValidationFailedException {
    DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
    final SystemMapNode taskNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(TASK)).build();
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.write(YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK), taskNode);
    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) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) DataTree(org.opendaylight.yangtools.yang.data.tree.api.DataTree) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) InMemoryDataTreeFactory(org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory)

Example 18 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project yangtools by opendaylight.

the class Bug5968Test method writeInvalidContainerTest.

@Test
public void writeInvalidContainerTest() throws DataValidationFailedException {
    final DataTree inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
    final SystemMapNode myList = createMap(true);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.write(YangInstanceIdentifier.of(ROOT), root.build());
    try {
        modificationTree.ready();
        inMemoryDataTree.validate(modificationTree);
        final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
        inMemoryDataTree.commit(prepare);
        fail("Should fail due to missing mandatory leaf.");
    } catch (final IllegalArgumentException e) {
        assertEquals("Node (bug5968?revision=2016-07-28)my-list[{(bug5968?revision=2016-07-28)list-id=1}] is " + "missing mandatory descendant /(bug5968?revision=2016-07-28)mandatory-leaf", e.getMessage());
    }
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) DataTreeCandidate(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) 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) Test(org.junit.Test)

Example 19 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project yangtools by opendaylight.

the class Bug5968Test method writeValidContainerTest.

@Test
public void writeValidContainerTest() throws DataValidationFailedException {
    final DataTree inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
    final SystemMapNode myList = createMap(false);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.write(YangInstanceIdentifier.of(ROOT), root.build());
    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) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) 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) Test(org.junit.Test)

Example 20 with SystemMapNode

use of org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode in project yangtools by opendaylight.

the class Bug5968MergeTest method mergeValidContainerTest.

@Test
public void mergeValidContainerTest() throws DataValidationFailedException {
    final DataTree inMemoryDataTree = emptyDataTree(SCHEMA_CONTEXT);
    final SystemMapNode myList = createMap(false);
    final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    modificationTree.merge(YangInstanceIdentifier.of(ROOT), root.build());
    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) SystemMapNode(org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode) 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) Test(org.junit.Test)

Aggregations

SystemMapNode (org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode)34 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)23 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)21 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)21 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)12 Test (org.junit.Test)11 DataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)9 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)8 UserMapNode (org.opendaylight.yangtools.yang.data.api.schema.UserMapNode)8 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)8 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)7 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)7 LeafNode (org.opendaylight.yangtools.yang.data.api.schema.LeafNode)6 DataTreeCandidate (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate)6 CollectionNodeBuilder (org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder)5 DataTree (org.opendaylight.yangtools.yang.data.tree.api.DataTree)5 QName (org.opendaylight.yangtools.yang.common.QName)4 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)4 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)4 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)4