Search in sources :

Example 1 with NormalizedNodeNavigator

use of org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator in project controller by opendaylight.

the class NormalizedNodePrunerTest method countNodes.

private static int countNodes(final NormalizedNode<?, ?> normalizedNode, final String namespaceFilter) {
    if (normalizedNode == null) {
        return 0;
    }
    final AtomicInteger count = new AtomicInteger();
    new NormalizedNodeNavigator((level, parentPath, normalizedNode1) -> {
        if (!(normalizedNode1.getIdentifier() instanceof AugmentationIdentifier)) {
            if (normalizedNode1.getIdentifier().getNodeType().getNamespace().toString().contains(namespaceFilter)) {
                count.incrementAndGet();
            }
        }
    }).navigate(YangInstanceIdentifier.EMPTY.toString(), normalizedNode);
    return count.get();
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) LeafSetEntryNode(org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) AnyXmlNode(org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode) MockitoAnnotations(org.mockito.MockitoAnnotations) TestModel(org.opendaylight.controller.cluster.datastore.util.TestModel) NormalizedNodeWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) ImmutableLeafSetNodeBuilder(org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder) ImmutableNodes.mapEntry(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) ImmutableLeafSetEntryNodeBuilder(org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder) NormalizedNodeNavigator(org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator) Builders(org.opendaylight.yangtools.yang.data.impl.schema.Builders) Before(org.junit.Before) LeafNode(org.opendaylight.yangtools.yang.data.api.schema.LeafNode) ImmutableNodes.mapNodeBuilder(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder) Assert.assertTrue(org.junit.Assert.assertTrue) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) IOException(java.io.IOException) Test(org.junit.Test) Sets(com.google.common.collect.Sets) ImmutableNodes.mapEntryBuilder(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder) Assert.assertNull(org.junit.Assert.assertNull) ImmutableNodes(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Mockito.mock(org.mockito.Mockito.mock) NormalizedNodeNavigator(org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator) AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

Sets (com.google.common.collect.Sets)1 IOException (java.io.IOException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 DOMSource (javax.xml.transform.dom.DOMSource)1 Assert (org.junit.Assert)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNull (org.junit.Assert.assertNull)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Mockito.mock (org.mockito.Mockito.mock)1 MockitoAnnotations (org.mockito.MockitoAnnotations)1 NormalizedNodeNavigator (org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator)1 TestModel (org.opendaylight.controller.cluster.datastore.util.TestModel)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1 AugmentationIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier)1 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)1 NodeWithValue (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue)1 AnyXmlNode (org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode)1 LeafNode (org.opendaylight.yangtools.yang.data.api.schema.LeafNode)1