BUG 2970 : Create a utility class which can prune a normalized node based on the... 01/21201/2
authorMoiz Raja <moraja@cisco.com>
Fri, 22 May 2015 11:03:00 +0000 (04:03 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 27 May 2015 18:27:02 +0000 (18:27 +0000)
This will be used when a data modification operation fails because of a missing schema
failure.

Change-Id: I6e07763051cc2181c0c786a0762cbf6a3c5c4eed
Signed-off-by: Moiz Raja <moraja@cisco.com>
(cherry picked from commit 9055581e2aabac7478102c6b05f9118b443a9d64)

opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodeBuilderWrapper.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java

diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodeBuilderWrapper.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodeBuilderWrapper.java
new file mode 100644 (file)
index 0000000..5295c88
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.cluster.datastore.node.utils.transformer;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
+
+public class NormalizedNodeBuilderWrapper {
+    private final NormalizedNodeContainerBuilder<?,?,?,?> builder;
+    private final YangInstanceIdentifier.PathArgument identifier;
+
+
+    NormalizedNodeBuilderWrapper(NormalizedNodeContainerBuilder<?,?,?,?> builder, YangInstanceIdentifier.PathArgument identifier) {
+        this.builder = builder;
+        this.identifier = identifier;
+    }
+
+    public NormalizedNodeContainerBuilder builder(){
+        return builder;
+    }
+
+    public QName nodeType(){
+        return identifier.getNodeType();
+    }
+
+    public YangInstanceIdentifier.PathArgument identifier(){
+        return identifier;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java
new file mode 100644 (file)
index 0000000..861f113
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.cluster.datastore.node.utils.transformer;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import javax.xml.transform.dom.DOMSource;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+/**
+ * The NormalizedNodePruner removes all nodes from the input NormalizedNode that do not have a corresponding
+ * schema element in the passed in SchemaContext
+ *
+ */
+public class NormalizedNodePruner implements NormalizedNodeStreamWriter {
+
+    private final SimpleStack<NormalizedNodeBuilderWrapper> stack = new SimpleStack<>();
+    private NormalizedNode<?,?> normalizedNode;
+    private final Set<URI> validNamespaces;
+    private boolean sealed = false;
+
+    public NormalizedNodePruner(SchemaContext schemaContext) {
+        validNamespaces = new HashSet<>(schemaContext.getModules().size());
+        for(org.opendaylight.yangtools.yang.model.api.Module module : schemaContext.getModules()){
+            validNamespaces.add(module.getNamespace());
+        }
+    }
+    @Override
+    public void leafNode(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, Object o) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        if(!isValidNamespace(nodeIdentifier)){
+            return;
+        }
+        NormalizedNodeBuilderWrapper parent = stack.peek();
+        Preconditions.checkState(parent != null, "leafNode has no parent");
+        parent.builder()
+                .addChild(Builders.leafBuilder()
+                        .withNodeIdentifier(nodeIdentifier)
+                        .withValue(o)
+                        .build());
+    }
+
+    @Override
+    public void startLeafSet(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, int i) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        addBuilder(Builders.leafSetBuilder().withNodeIdentifier(nodeIdentifier), nodeIdentifier);
+    }
+
+    @Override
+    public void leafSetEntryNode(Object o) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        NormalizedNodeBuilderWrapper parent = stack.peek();
+        Preconditions.checkState(parent != null, "leafSetEntryNode has no parent");
+        if(!isValidNamespace(parent.identifier())){
+            return;
+        }
+
+        parent.builder()
+                .addChild(Builders.leafSetEntryBuilder()
+                        .withValue(o)
+                        .withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue(parent.nodeType(), o))
+                        .build());
+    }
+
+    @Override
+    public void startContainerNode(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, int i) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        addBuilder(Builders.containerBuilder().withNodeIdentifier(nodeIdentifier), nodeIdentifier);
+    }
+
+    @Override
+    public void startUnkeyedList(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, int i) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        addBuilder(Builders.unkeyedListBuilder().withNodeIdentifier(nodeIdentifier), nodeIdentifier);
+    }
+
+    @Override
+    public void startUnkeyedListItem(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, int i) throws IOException, IllegalStateException {
+
+        checkNotSealed();
+
+        addBuilder(Builders.unkeyedListEntryBuilder().withNodeIdentifier(nodeIdentifier), nodeIdentifier);
+    }
+
+    @Override
+    public void startMapNode(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, int i) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        addBuilder(Builders.mapBuilder().withNodeIdentifier(nodeIdentifier), nodeIdentifier);
+    }
+
+    @Override
+    public void startMapEntryNode(YangInstanceIdentifier.NodeIdentifierWithPredicates nodeIdentifierWithPredicates, int i) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        addBuilder(Builders.mapEntryBuilder().withNodeIdentifier(nodeIdentifierWithPredicates), nodeIdentifierWithPredicates);
+    }
+
+    @Override
+    public void startOrderedMapNode(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, int i) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        addBuilder(Builders.orderedMapBuilder().withNodeIdentifier(nodeIdentifier), nodeIdentifier);
+    }
+
+    @Override
+    public void startChoiceNode(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, int i) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        addBuilder(Builders.choiceBuilder().withNodeIdentifier(nodeIdentifier), nodeIdentifier);
+    }
+
+    @Override
+    public void startAugmentationNode(YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        addBuilder(Builders.augmentationBuilder().withNodeIdentifier(augmentationIdentifier), augmentationIdentifier);
+    }
+
+    @Override
+    public void anyxmlNode(YangInstanceIdentifier.NodeIdentifier nodeIdentifier, Object o) throws IOException, IllegalArgumentException {
+
+        checkNotSealed();
+
+        if(!isValidNamespace(nodeIdentifier)){
+            return;
+        }
+        NormalizedNodeBuilderWrapper parent = stack.peek();
+        Preconditions.checkState(parent != null, "anyxmlNode has no parent");
+        parent.builder().addChild(Builders.anyXmlBuilder().withNodeIdentifier(nodeIdentifier).withValue((DOMSource) o).build());
+    }
+
+    @Override
+    public void endNode() throws IOException, IllegalStateException {
+
+        checkNotSealed();
+
+        NormalizedNodeBuilderWrapper child = stack.pop();
+
+        Preconditions.checkState(child != null, "endNode called on an empty stack");
+
+        if(!isValidNamespace(child.identifier())){
+            return;
+        }
+        NormalizedNode<?,?> normalizedNode = child.builder().build();
+
+        if(stack.size() > 0){
+            NormalizedNodeBuilderWrapper parent = stack.peek();
+            parent.builder().addChild(normalizedNode);
+        } else {
+            this.normalizedNode = normalizedNode;
+            sealed = true;
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        sealed = true;
+    }
+
+    @Override
+    public void flush() throws IOException {
+
+    }
+
+    public NormalizedNode<?,?> normalizedNode(){
+        return normalizedNode;
+    }
+
+    private void checkNotSealed(){
+        Preconditions.checkState(!sealed, "Pruner can be used only once");
+    }
+
+    private boolean isValidNamespace(QName qName){
+        return validNamespaces.contains(qName.getNamespace());
+    }
+
+    private boolean isValidNamespace(YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier){
+        Set<QName> possibleChildNames = augmentationIdentifier.getPossibleChildNames();
+
+        for(QName qName : possibleChildNames){
+            if(isValidNamespace(qName)){
+                return true;
+            }
+        }
+        return false;
+
+    }
+
+    private boolean isValidNamespace(YangInstanceIdentifier.PathArgument identifier){
+        if(identifier instanceof YangInstanceIdentifier.AugmentationIdentifier){
+            return isValidNamespace((YangInstanceIdentifier.AugmentationIdentifier) identifier);
+        }
+
+        return isValidNamespace(identifier.getNodeType());
+    }
+
+    private NormalizedNodeBuilderWrapper addBuilder(NormalizedNodeContainerBuilder<?,?,?,?> builder, YangInstanceIdentifier.PathArgument identifier){
+        NormalizedNodeBuilderWrapper wrapper = new NormalizedNodeBuilderWrapper(builder, identifier);
+        stack.push(wrapper);
+        return wrapper;
+    }
+
+    @VisibleForTesting
+    static class SimpleStack<E> {
+        List<E> stack = new LinkedList<>();
+
+        void push(E element){
+            stack.add(element);
+        }
+
+        E pop(){
+            if(size() == 0){
+                return null;
+            }
+            return stack.remove(stack.size() - 1);
+        }
+
+        E peek(){
+            if(size() == 0){
+                return null;
+            }
+
+            return stack.get(stack.size() - 1);
+        }
+
+        int size(){
+            return stack.size();
+        }
+    }
+
+    @VisibleForTesting
+    SimpleStack<NormalizedNodeBuilderWrapper> stack(){
+        return stack;
+    }
+
+
+}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java
new file mode 100644 (file)
index 0000000..20b58ee
--- /dev/null
@@ -0,0 +1,402 @@
+package org.opendaylight.controller.cluster.datastore.node.utils.transformer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.xml.transform.dom.DOMSource;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeNavigator;
+import org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeVisitor;
+import org.opendaylight.controller.cluster.datastore.util.TestModel;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
+
+public class NormalizedNodePrunerTest {
+
+    private NormalizedNodePruner prunerFullSchema;
+
+    private NormalizedNodePruner prunerNoAugSchema;
+
+    @Mock
+    private NormalizedNodeBuilderWrapper normalizedNodeBuilderWrapper;
+
+    @Mock
+    private NormalizedNodeContainerBuilder normalizedNodeContainerBuilder;
+
+    @Mock
+    private NormalizedNode<?,?> normalizedNode;
+
+    @Before
+    public void setUp(){
+        MockitoAnnotations.initMocks(this);
+        prunerFullSchema = new NormalizedNodePruner(TestModel.createTestContext());
+        prunerNoAugSchema = new NormalizedNodePruner(TestModel.createTestContextWithoutAugmentationSchema());
+        doReturn(normalizedNodeContainerBuilder).when(normalizedNodeBuilderWrapper).builder();
+        doReturn(TestModel.BOOLEAN_LEAF_QNAME).when(normalizedNodeBuilderWrapper).nodeType();
+        doReturn(normalizedNode).when(normalizedNodeContainerBuilder).build();
+        doReturn(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME)).when(normalizedNodeBuilderWrapper).identifier();
+    }
+
+    @Test
+    public void testNodesNotPrunedWhenSchemaPresent() throws IOException {
+        NormalizedNodePruner pruner = prunerFullSchema;
+
+        NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
+
+        NormalizedNode<?, ?> expected = createTestContainer();
+
+        normalizedNodeWriter.write(expected);
+
+        NormalizedNode actual = pruner.normalizedNode();
+
+        assertEquals(expected, actual);
+
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testReusePruner() throws IOException {
+        NormalizedNodePruner pruner = prunerFullSchema;
+
+        NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
+
+        NormalizedNode<?, ?> expected = createTestContainer();
+
+        normalizedNodeWriter.write(expected);
+
+        NormalizedNode actual = pruner.normalizedNode();
+
+        assertEquals(expected, actual);
+
+        NormalizedNodeWriter.forStreamWriter(pruner).write(expected);
+
+    }
+
+
+    @Test
+    public void testNodesPrunedWhenAugmentationSchemaNotPresent() throws IOException {
+        NormalizedNodePruner pruner = prunerNoAugSchema;
+
+        NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
+
+        NormalizedNode<?, ?> expected = createTestContainer();
+
+        normalizedNodeWriter.write(expected);
+
+        NormalizedNode actual = pruner.normalizedNode();
+
+        Assert.assertNotEquals(expected, actual);
+
+        // Asserting true here instead of checking actual value because I don't want this assertion to be fragile
+        assertTrue(countNodes(expected, "store:aug") > 0);
+
+        // All nodes from the augmentation module are gone from the resulting node
+        assertEquals(0, countNodes(actual, "store:aug"));
+    }
+
+    @Test
+    public void testNodesPrunedWhenTestSchemaNotPresent() throws IOException {
+        NormalizedNodePruner pruner = new NormalizedNodePruner(TestModel.createTestContextWithoutTestSchema());
+
+        NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(pruner);
+
+        NormalizedNode<?, ?> expected = createTestContainer();
+
+        normalizedNodeWriter.write(expected);
+
+        NormalizedNode actual = pruner.normalizedNode();
+
+        // Since top level schema is missing null is returned
+        assertNull(actual);
+
+        // Asserting true here instead of checking actual value because I don't want this assertion to be fragile
+        assertTrue(countNodes(expected, "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test") > 0);
+
+    }
+
+
+    private int countNodes(NormalizedNode<?,?> normalizedNode, final String namespaceFilter){
+        if(normalizedNode == null){
+            return 0;
+        }
+        final AtomicInteger count = new AtomicInteger();
+        new NormalizedNodeNavigator(new NormalizedNodeVisitor() {
+
+            @Override
+            public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) {
+                if(!(normalizedNode.getIdentifier() instanceof YangInstanceIdentifier.AugmentationIdentifier)) {
+                    if (normalizedNode.getIdentifier().getNodeType().getNamespace().toString().contains(namespaceFilter)) {
+                        count.incrementAndGet();
+                    }
+                }
+            }
+        }).navigate(YangInstanceIdentifier.builder().build().toString(), normalizedNode);
+
+        return count.get();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testLeafNodeHasNoParent() throws IOException {
+        prunerFullSchema.leafNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), mock(Object.class));
+    }
+
+    @Test
+    public void testLeafNodeHasParent() throws IOException {
+        prunerFullSchema.stack().push(normalizedNodeBuilderWrapper);
+        Object o = mock(Object.class);
+        prunerFullSchema.leafNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), o);
+
+        ArgumentCaptor<NormalizedNode> captor = ArgumentCaptor.forClass(NormalizedNode.class);
+
+        verify(normalizedNodeContainerBuilder).addChild(captor.capture());
+
+        NormalizedNode value = captor.getValue();
+        assertEquals(normalizedNodeBuilderWrapper.identifier().getNodeType(), value.getNodeType());
+        assertEquals(normalizedNodeBuilderWrapper.identifier(), value.getIdentifier());
+        assertEquals(o, value.getValue());
+
+    }
+
+    @Test
+    public void testLeafNodeSchemaMissing() throws IOException {
+        prunerNoAugSchema.stack().push(normalizedNodeBuilderWrapper);
+        prunerNoAugSchema.leafNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.AUG_CONT_QNAME), mock(Object.class));
+        verify(normalizedNodeContainerBuilder, never()).addChild(any(NormalizedNode.class));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testLeafSetEntryNodeHasNoParent() throws IOException {
+        prunerFullSchema.leafSetEntryNode(mock(Object.class));
+    }
+
+    @Test
+    public void testLeafSetEntryNodeHasParent() throws IOException {
+        prunerFullSchema.stack().push(normalizedNodeBuilderWrapper);
+        Object o = mock(Object.class);
+        YangInstanceIdentifier.PathArgument nodeIdentifier
+                = new YangInstanceIdentifier.NodeWithValue(normalizedNodeBuilderWrapper.identifier().getNodeType(), o);
+        prunerFullSchema.leafSetEntryNode(o);
+
+        ArgumentCaptor<NormalizedNode> captor = ArgumentCaptor.forClass(NormalizedNode.class);
+
+        verify(normalizedNodeContainerBuilder).addChild(captor.capture());
+
+        NormalizedNode value = captor.getValue();
+        assertEquals(nodeIdentifier.getNodeType(), value.getNodeType());
+        assertEquals(nodeIdentifier, value.getIdentifier());
+        assertEquals(o, value.getValue());
+
+    }
+
+    @Test
+    public void testLeafSetEntryNodeSchemaMissing() throws IOException {
+        doReturn(new YangInstanceIdentifier.NodeIdentifier(TestModel.AUG_CONT_QNAME)).when(normalizedNodeBuilderWrapper).identifier();
+
+        prunerNoAugSchema.stack().push(normalizedNodeBuilderWrapper);
+        prunerNoAugSchema.leafSetEntryNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.AUG_CONT_QNAME));
+
+        verify(normalizedNodeContainerBuilder, never()).addChild(any(NormalizedNode.class));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testAnyXMLNodeHasNoParent() throws IOException {
+        prunerFullSchema.anyxmlNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), mock(Object.class));
+    }
+
+    @Test
+    public void testAnyXMLNodeHasParent() throws IOException {
+        prunerFullSchema.stack().push(normalizedNodeBuilderWrapper);
+        YangInstanceIdentifier.NodeIdentifier nodeIdentifier = new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME);
+        DOMSource o = mock(DOMSource.class);
+        prunerFullSchema.anyxmlNode(nodeIdentifier, o);
+
+        ArgumentCaptor<NormalizedNode> captor = ArgumentCaptor.forClass(NormalizedNode.class);
+
+        verify(normalizedNodeContainerBuilder).addChild(captor.capture());
+
+        NormalizedNode value = captor.getValue();
+        assertEquals(nodeIdentifier.getNodeType(), value.getNodeType());
+        assertEquals(nodeIdentifier, value.getIdentifier());
+        assertEquals(o, value.getValue());
+    }
+
+    @Test
+    public void testAnyXmlNodeSchemaMissing() throws IOException {
+        prunerNoAugSchema.stack().push(normalizedNodeBuilderWrapper);
+        prunerNoAugSchema.anyxmlNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.AUG_CONT_QNAME), mock(DOMSource.class));
+
+        verify(normalizedNodeContainerBuilder, never()).addChild(any(NormalizedNode.class));
+
+
+    }
+
+
+    @Test
+    public void testLeafSetPushesBuilderToStack() throws IOException {
+        prunerFullSchema.startLeafSet(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), 10);
+
+        assertEquals(1, prunerFullSchema.stack().size());
+        assertTrue(prunerFullSchema.stack().peek().toString(), prunerFullSchema.stack().peek() instanceof NormalizedNodeBuilderWrapper);
+        assertTrue(prunerFullSchema.stack().peek().builder().toString(), prunerFullSchema.stack().peek().builder() instanceof ListNodeBuilder);
+    }
+
+    @Test
+    public void testStartContainerNodePushesBuilderToStack() throws IOException {
+        prunerFullSchema.startContainerNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), 10);
+
+        assertEquals(1, prunerFullSchema.stack().size());
+        assertTrue(prunerFullSchema.stack().peek().toString(), prunerFullSchema.stack().peek() instanceof NormalizedNodeBuilderWrapper);
+        assertTrue(prunerFullSchema.stack().peek().builder().toString(), prunerFullSchema.stack().peek().builder() instanceof DataContainerNodeAttrBuilder);
+    }
+
+    @Test
+    public void testStartUnkeyedListPushesBuilderToStack() throws IOException {
+        prunerFullSchema.startUnkeyedList(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), 10);
+
+        assertEquals(1, prunerFullSchema.stack().size());
+        assertTrue(prunerFullSchema.stack().peek().toString(), prunerFullSchema.stack().peek() instanceof NormalizedNodeBuilderWrapper);
+        assertTrue(prunerFullSchema.stack().peek().builder().toString(), prunerFullSchema.stack().peek().builder() instanceof CollectionNodeBuilder);
+    }
+
+    @Test
+    public void testStartUnkeyedListItemPushesBuilderToStack() throws IOException {
+        prunerFullSchema.startUnkeyedListItem(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), 10);
+
+        assertEquals(1, prunerFullSchema.stack().size());
+        assertTrue(prunerFullSchema.stack().peek().toString(), prunerFullSchema.stack().peek() instanceof NormalizedNodeBuilderWrapper);
+        assertTrue(prunerFullSchema.stack().peek().builder().toString(), prunerFullSchema.stack().peek().builder() instanceof DataContainerNodeAttrBuilder);
+    }
+
+    @Test
+    public void testStartMapNodePushesBuilderToStack() throws IOException {
+        prunerFullSchema.startMapNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), 10);
+
+        assertEquals(1, prunerFullSchema.stack().size());
+        assertTrue(prunerFullSchema.stack().peek().toString(), prunerFullSchema.stack().peek() instanceof NormalizedNodeBuilderWrapper);
+        assertTrue(prunerFullSchema.stack().peek().builder().toString(), prunerFullSchema.stack().peek().builder() instanceof CollectionNodeBuilder);
+    }
+
+    @Test
+    public void testStartMapEntryNodePushesBuilderToStack() throws IOException {
+        prunerFullSchema.startMapEntryNode(
+                new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.BOOLEAN_LEAF_QNAME,
+                        ImmutableMap.<QName, Object>of(TestModel.BOOLEAN_LEAF_QNAME, "value")), 10);
+
+        assertEquals(1, prunerFullSchema.stack().size());
+        assertTrue(prunerFullSchema.stack().peek().toString(), prunerFullSchema.stack().peek() instanceof NormalizedNodeBuilderWrapper);
+        assertTrue(prunerFullSchema.stack().peek().builder().toString(), prunerFullSchema.stack().peek().builder() instanceof DataContainerNodeAttrBuilder);
+    }
+
+    @Test
+    public void testStartOrderedMapNodePushesBuilderToStack() throws IOException {
+        prunerFullSchema.startOrderedMapNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), 10);
+
+        assertEquals(1, prunerFullSchema.stack().size());
+        assertTrue(prunerFullSchema.stack().peek().toString(), prunerFullSchema.stack().peek() instanceof NormalizedNodeBuilderWrapper);
+        assertTrue(prunerFullSchema.stack().peek().builder().toString(), prunerFullSchema.stack().peek().builder() instanceof CollectionNodeBuilder);
+    }
+
+    @Test
+    public void testStartChoiceNodePushesBuilderToStack() throws IOException {
+        prunerFullSchema.startChoiceNode(new YangInstanceIdentifier.NodeIdentifier(TestModel.BOOLEAN_LEAF_QNAME), 10);
+
+        assertEquals(1, prunerFullSchema.stack().size());
+        assertTrue(prunerFullSchema.stack().peek().toString(), prunerFullSchema.stack().peek() instanceof NormalizedNodeBuilderWrapper);
+        assertTrue(prunerFullSchema.stack().peek().builder().toString(), prunerFullSchema.stack().peek().builder() instanceof DataContainerNodeBuilder);
+    }
+
+    @Test
+    public void testStartAugmentationPushesBuilderToStack() throws IOException {
+        prunerFullSchema.startAugmentationNode(new YangInstanceIdentifier.AugmentationIdentifier(ImmutableSet.of(TestModel.AUG_CONT_QNAME)));
+
+        assertEquals(1, prunerFullSchema.stack().size());
+        assertTrue(prunerFullSchema.stack().peek().toString(), prunerFullSchema.stack().peek() instanceof NormalizedNodeBuilderWrapper);
+        assertTrue(prunerFullSchema.stack().peek().builder().toString(), prunerFullSchema.stack().peek().builder() instanceof DataContainerNodeBuilder);
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testEndNodeWhenNoBuildersOnStack() throws IOException {
+        prunerFullSchema.endNode();
+    }
+
+    @Test
+    public void testEndNodeWhenOneBuildersOnStack() throws IOException {
+        prunerFullSchema.stack().push(normalizedNodeBuilderWrapper);
+        prunerFullSchema.endNode();
+        assertEquals(normalizedNode, prunerFullSchema.normalizedNode());
+    }
+
+    @Test
+    public void testEndNodeSchemaMissing() throws IOException {
+        doReturn(new YangInstanceIdentifier.NodeIdentifier(TestModel.AUG_CONT_QNAME)).when(normalizedNodeBuilderWrapper).identifier();
+
+        prunerNoAugSchema.stack().push(normalizedNodeBuilderWrapper);
+        prunerNoAugSchema.endNode();
+
+        assertEquals(null, prunerNoAugSchema.normalizedNode());
+    }
+
+    @Test
+    public void testEndNodeWhenMoreThanOneBuilderOnStack() throws IOException {
+        // A little lazy in adding the "parent" builder
+        prunerFullSchema.stack().push(normalizedNodeBuilderWrapper);
+        prunerFullSchema.stack().push(normalizedNodeBuilderWrapper);
+        prunerFullSchema.endNode();
+        assertEquals(null, prunerFullSchema.normalizedNode());
+
+        verify(normalizedNodeContainerBuilder).addChild(any(NormalizedNode.class));
+    }
+
+    private NormalizedNode<?, ?> createTestContainer() {
+        byte[] bytes1 = {1,2,3};
+        LeafSetEntryNode<Object> entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).
+                withValue(bytes1).build();
+
+        byte[] bytes2 = {};
+        LeafSetEntryNode<Object> entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).
+                withValue(bytes2).build();
+
+        LeafSetEntryNode<Object> entry3 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeWithValue(TestModel.BINARY_LEAF_LIST_QNAME, null)).
+                withValue(null).build();
+
+
+        return TestModel.createBaseTestContainerBuilder().
+                withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(
+                        new YangInstanceIdentifier.NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME)).
+                        withChild(entry1).withChild(entry2).withChild(entry3).build()).
+                withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1, 2, 3, 4})).
+                withChild(Builders.orderedMapBuilder().
+                        withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.ORDERED_LIST_QNAME)).
+                        withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME,
+                                TestModel.ID_QNAME, 11)).build()).
+                build();
+    }
+}
\ No newline at end of file
index d27d650..0b410ac 100644 (file)
@@ -52,400 +52,421 @@ import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class TestModel {
 
-  public static final QName TEST_QNAME = QName.create(
-      "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test",
-      "2014-03-13", "test");
-
-  public static final QName AUG_NAME_QNAME = QName.create(
-      "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
-      "2014-03-13", "name");
-
-  public static final QName AUG_CONT_QNAME = QName.create(
-      "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
-      "2014-03-13", "cont");
-
-
-  public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc");
-  public static final QName POINTER_QNAME = QName.create(TEST_QNAME, "pointer");
-  public static final QName SOME_BINARY_DATA_QNAME = QName.create(TEST_QNAME, "some-binary-data");
-  public static final QName BINARY_LEAF_LIST_QNAME = QName.create(TEST_QNAME, "binary_leaf_list");
-  public static final QName SOME_REF_QNAME = QName.create(TEST_QNAME,
-      "some-ref");
-  public static final QName MYIDENTITY_QNAME = QName.create(TEST_QNAME,
-      "myidentity");
-  public static final QName SWITCH_FEATURES_QNAME = QName.create(TEST_QNAME,
-      "switch-features");
-
-  public static final QName AUGMENTED_LIST_QNAME = QName.create(TEST_QNAME, "augmented-list");
-  public static final QName AUGMENTED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "augmented-list-entry");
-
-  public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME,
-      "outer-list");
-  public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME,
-      "inner-list");
-  public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME,
-      "outer-choice");
-  public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
-  public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
-  public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
-  public static final QName BOOLEAN_LEAF_QNAME = QName.create(TEST_QNAME, "boolean-leaf");
-  public static final QName SHORT_LEAF_QNAME = QName.create(TEST_QNAME, "short-leaf");
-  public static final QName BYTE_LEAF_QNAME = QName.create(TEST_QNAME, "byte-leaf");
-  public static final QName BIGINTEGER_LEAF_QNAME = QName.create(TEST_QNAME, "biginteger-leaf");
-  public static final QName BIGDECIMAL_LEAF_QNAME = QName.create(TEST_QNAME, "bigdecimal-leaf");
-  public static final QName ORDERED_LIST_QNAME = QName.create(TEST_QNAME, "ordered-list");
-  public static final QName ORDERED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "ordered-list-entry");
-  public static final QName UNKEYED_LIST_QNAME = QName.create(TEST_QNAME, "unkeyed-list");
-  public static final QName UNKEYED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "unkeyed-list-entry");
-  public static final QName CHOICE_QNAME = QName.create(TEST_QNAME, "choice");
-  private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
-  private static final String DATASTORE_AUG_YANG =
-      "/odl-datastore-augmentation.yang";
-  private static final String DATASTORE_TEST_NOTIFICATION_YANG =
-      "/odl-datastore-test-notification.yang";
-
-
-  public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier
-      .of(TEST_QNAME);
-  public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier
-      .builder(TEST_PATH).node(DESC_QNAME).build();
-  public static final YangInstanceIdentifier OUTER_LIST_PATH =
-      YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
-  public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
-  public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
-
-  private static final Integer ONE_ID = 1;
-  private static final Integer TWO_ID = 2;
-  private static final String TWO_ONE_NAME = "one";
-  private static final String TWO_TWO_NAME = "two";
-  private static final String DESC = "Hello there";
-  private static final Long LONG_ID = 1L;
-  private static final Boolean ENABLED = true;
-  private static final Short SHORT_ID = 1;
-  private static final Byte BYTE_ID = 1;
-  // Family specific constants
-  public static final QName FAMILY_QNAME =
-      QName
-          .create(
-              "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test",
-              "2014-04-17", "family");
-  public static final QName CHILDREN_QNAME = QName.create(FAMILY_QNAME,
-      "children");
-  public static final QName GRAND_CHILDREN_QNAME = QName.create(FAMILY_QNAME,
-      "grand-children");
-  public static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME,
-      "child-number");
-  public static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME,
-      "child-name");
-  public static final QName GRAND_CHILD_NUMBER_QNAME = QName.create(
-      FAMILY_QNAME, "grand-child-number");
-  public static final QName GRAND_CHILD_NAME_QNAME = QName.create(FAMILY_QNAME,
-      "grand-child-name");
-
-  public static final YangInstanceIdentifier FAMILY_PATH =
-      YangInstanceIdentifier.of(FAMILY_QNAME);
-  public static final YangInstanceIdentifier FAMILY_DESC_PATH =
-      YangInstanceIdentifier.builder(FAMILY_PATH).node(DESC_QNAME).build();
-  public static final YangInstanceIdentifier CHILDREN_PATH =
-      YangInstanceIdentifier.builder(FAMILY_PATH).node(CHILDREN_QNAME).build();
-
-  private static final Integer FIRST_CHILD_ID = 1;
-  private static final Integer SECOND_CHILD_ID = 2;
-
-  private static final String FIRST_CHILD_NAME = "first child";
-  private static final String SECOND_CHILD_NAME = "second child";
-
-  private static final Integer FIRST_GRAND_CHILD_ID = 1;
-  private static final Integer SECOND_GRAND_CHILD_ID = 2;
-
-  private static final String FIRST_GRAND_CHILD_NAME = "first grand child";
-  private static final String SECOND_GRAND_CHILD_NAME = "second grand child";
-
-
-  private static final MapEntryNode BAR_NODE = mapEntryBuilder(
-      OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
-      .withChild(mapNodeBuilder(INNER_LIST_QNAME) //
-          .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) //
-          .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) //
-          .build()) //
-      .build();
-
-  public static final InputStream getDatastoreTestInputStream() {
-    return getInputStream(DATASTORE_TEST_YANG);
-  }
-
-  public static final InputStream getDatastoreAugInputStream() {
-    return getInputStream(DATASTORE_AUG_YANG);
-  }
-
-  public static final InputStream getDatastoreTestNotificationInputStream() {
-    return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG);
-  }
-
-  private static InputStream getInputStream(final String resourceName) {
-    return TestModel.class.getResourceAsStream(resourceName);
-  }
-
-  public static SchemaContext createTestContext() {
-    List<InputStream> inputStreams = new ArrayList<>();
-    inputStreams.add(getDatastoreTestInputStream());
-    inputStreams.add(getDatastoreAugInputStream());
-    inputStreams.add(getDatastoreTestNotificationInputStream());
-
-    YangParserImpl parser = new YangParserImpl();
-    Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
-    return parser.resolveSchemaContext(modules);
-  }
-
-  /**
-   * Returns a test document
-   * <p/>
-   *
-   * <pre>
-   * test
-   *     outer-list
-   *          id 1
-   *     outer-list
-   *          id 2
-   *          inner-list
-   *                  name "one"
-   *          inner-list
-   *                  name "two"
-   *
-   * </pre>
-   *
-   * @return
-   */
-  public static NormalizedNode<?, ?> createDocumentOne(
-      SchemaContext schemaContext) {
-    return ImmutableContainerNodeBuilder
-        .create()
-        .withNodeIdentifier(
-            new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName()))
-        .withChild(createTestContainer()).build();
-
-  }
-
-  public static DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
-      // Create a list of shoes
-      // This is to test leaf list entry
-      final LeafSetEntryNode<Object> nike =
-              ImmutableLeafSetEntryNodeBuilder
-                      .create()
-                      .withNodeIdentifier(
-                              new YangInstanceIdentifier.NodeWithValue(QName.create(
-                                      TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
-
-      final LeafSetEntryNode<Object> puma =
-              ImmutableLeafSetEntryNodeBuilder
-                      .create()
-                      .withNodeIdentifier(
-                              new YangInstanceIdentifier.NodeWithValue(QName.create(
-                                      TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
-
-      final LeafSetNode<Object> shoes =
-              ImmutableLeafSetNodeBuilder
-                      .create()
-                      .withNodeIdentifier(
-                              new YangInstanceIdentifier.NodeIdentifier(QName.create(
-                                      TEST_QNAME, "shoe"))).withChild(nike).withChild(puma)
-                      .build();
-
-
-      // Test a leaf-list where each entry contains an identity
-      final LeafSetEntryNode<Object> cap1 =
-              ImmutableLeafSetEntryNodeBuilder
-                      .create()
-                      .withNodeIdentifier(
-                              new YangInstanceIdentifier.NodeWithValue(QName.create(
-                                      TEST_QNAME, "capability"), DESC_QNAME))
-                      .withValue(DESC_QNAME).build();
-
-      final LeafSetNode<Object> capabilities =
-              ImmutableLeafSetNodeBuilder
-                      .create()
-                      .withNodeIdentifier(
-                              new YangInstanceIdentifier.NodeIdentifier(QName.create(
-                                      TEST_QNAME, "capability"))).withChild(cap1).build();
-
-      ContainerNode switchFeatures =
-              ImmutableContainerNodeBuilder
-                      .create()
-                      .withNodeIdentifier(
-                              new YangInstanceIdentifier.NodeIdentifier(SWITCH_FEATURES_QNAME))
-                      .withChild(capabilities).build();
-
-      // Create a leaf list with numbers
-      final LeafSetEntryNode<Object> five =
-              ImmutableLeafSetEntryNodeBuilder
-                      .create()
-                      .withNodeIdentifier(
-                              (new YangInstanceIdentifier.NodeWithValue(QName.create(
-                                      TEST_QNAME, "number"), 5))).withValue(5).build();
-      final LeafSetEntryNode<Object> fifteen =
-              ImmutableLeafSetEntryNodeBuilder
-                      .create()
-                      .withNodeIdentifier(
-                              (new YangInstanceIdentifier.NodeWithValue(QName.create(
-                                      TEST_QNAME, "number"), 15))).withValue(15).build();
-      final LeafSetNode<Object> numbers =
-              ImmutableLeafSetNodeBuilder
-                      .create()
-                      .withNodeIdentifier(
-                              new YangInstanceIdentifier.NodeIdentifier(QName.create(
-                                      TEST_QNAME, "number"))).withChild(five).withChild(fifteen)
-                      .build();
-
-
-      // Create augmentations
-      MapEntryNode augMapEntry = createAugmentedListEntry(1, "First Test");
-
-      // Create a bits leaf
-      NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
-              myBits = Builders.leafBuilder().withNodeIdentifier(
-              new YangInstanceIdentifier.NodeIdentifier(
-                      QName.create(TEST_QNAME, "my-bits"))).withValue(
-              ImmutableSet.of("foo", "bar"));
-
-      // Create unkeyed list entry
-      UnkeyedListEntryNode unkeyedListEntry =
-          Builders.unkeyedListEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_ENTRY_QNAME)).
-              withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed-entry-name")).build();
-
-      // Create YangInstanceIdentifier with all path arg types.
-      YangInstanceIdentifier instanceID = YangInstanceIdentifier.create(
-              new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "qname")),
-              new YangInstanceIdentifier.NodeIdentifierWithPredicates(QName.create(TEST_QNAME, "list-entry"),
-                      QName.create(TEST_QNAME, "key"), 10),
-              new YangInstanceIdentifier.AugmentationIdentifier(ImmutableSet.of(
-                      QName.create(TEST_QNAME, "aug1"), QName.create(TEST_QNAME, "aug2"))),
-              new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, "leaf-list-entry"), "foo"));
-
-      Map<QName, Object> keyValues = new HashMap<>();
-      keyValues.put(CHILDREN_QNAME, FIRST_CHILD_NAME);
-
-
-      // Create the document
-      return ImmutableContainerNodeBuilder
-              .create()
-              .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
-              .withChild(myBits.build())
-              .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
-              .withChild(ImmutableNodes.leafNode(BOOLEAN_LEAF_QNAME, ENABLED))
-              .withChild(ImmutableNodes.leafNode(SHORT_LEAF_QNAME, SHORT_ID))
-              .withChild(ImmutableNodes.leafNode(BYTE_LEAF_QNAME, BYTE_ID))
-              .withChild(ImmutableNodes.leafNode(TestModel.BIGINTEGER_LEAF_QNAME, BigInteger.valueOf(100)))
-              .withChild(ImmutableNodes.leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, BigDecimal.valueOf(1.2)))
-              .withChild(ImmutableNodes.leafNode(SOME_REF_QNAME, instanceID))
-              .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
-              .withChild(Builders.unkeyedListBuilder()
-                   .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME))
-                   .withChild(unkeyedListEntry).build())
-              .withChild(Builders.choiceBuilder()
-                   .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_QNAME))
-                   .withChild(ImmutableNodes.leafNode(DESC_QNAME, LONG_ID)).build())
-                   .withChild(Builders.orderedMapBuilder().
-                       withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(DESC_QNAME)).
-                       withValue(ImmutableList.<MapEntryNode>builder().add(augMapEntry).build()).build())
-                      // .withChild(augmentationNode)
-              .withChild(shoes)
-              .withChild(numbers)
-              .withChild(switchFeatures)
-              .withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(augMapEntry).build())
-              .withChild(mapNodeBuilder(OUTER_LIST_QNAME)
-                   .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
-                   .withChild(BAR_NODE).build()
-              );
-  }
-
-  public static ContainerNode createTestContainer() {
-      return createBaseTestContainerBuilder().build();
-  }
-
-  public static MapEntryNode createAugmentedListEntry(int id, String name) {
-
-    Set<QName> childAugmentations = new HashSet<>();
-    childAugmentations.add(AUG_CONT_QNAME);
-
-    ContainerNode augCont =
-        ImmutableContainerNodeBuilder
-            .create()
-            .withNodeIdentifier(
-                new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME))
-            .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build();
-
-
-    final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier =
-        new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
-
-    final AugmentationNode augmentationNode =
-        Builders.augmentationBuilder()
-            .withNodeIdentifier(augmentationIdentifier).withChild(augCont)
+    public static final QName TEST_QNAME = QName.create(
+            "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test",
+            "2014-03-13", "test");
+
+    public static final QName AUG_NAME_QNAME = QName.create(
+            "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
+            "2014-03-13", "name");
+
+    public static final QName AUG_CONT_QNAME = QName.create(
+            "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug",
+            "2014-03-13", "cont");
+
+
+    public static final QName DESC_QNAME = QName.create(TEST_QNAME, "desc");
+    public static final QName POINTER_QNAME = QName.create(TEST_QNAME, "pointer");
+    public static final QName SOME_BINARY_DATA_QNAME = QName.create(TEST_QNAME, "some-binary-data");
+    public static final QName BINARY_LEAF_LIST_QNAME = QName.create(TEST_QNAME, "binary_leaf_list");
+    public static final QName SOME_REF_QNAME = QName.create(TEST_QNAME,
+            "some-ref");
+    public static final QName MYIDENTITY_QNAME = QName.create(TEST_QNAME,
+            "myidentity");
+    public static final QName SWITCH_FEATURES_QNAME = QName.create(TEST_QNAME,
+            "switch-features");
+
+    public static final QName AUGMENTED_LIST_QNAME = QName.create(TEST_QNAME, "augmented-list");
+    public static final QName AUGMENTED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "augmented-list-entry");
+
+    public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME,
+            "outer-list");
+    public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME,
+            "inner-list");
+    public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME,
+            "outer-choice");
+    public static final QName ID_QNAME = QName.create(TEST_QNAME, "id");
+    public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name");
+    public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value");
+    public static final QName BOOLEAN_LEAF_QNAME = QName.create(TEST_QNAME, "boolean-leaf");
+    public static final QName SHORT_LEAF_QNAME = QName.create(TEST_QNAME, "short-leaf");
+    public static final QName BYTE_LEAF_QNAME = QName.create(TEST_QNAME, "byte-leaf");
+    public static final QName BIGINTEGER_LEAF_QNAME = QName.create(TEST_QNAME, "biginteger-leaf");
+    public static final QName BIGDECIMAL_LEAF_QNAME = QName.create(TEST_QNAME, "bigdecimal-leaf");
+    public static final QName ORDERED_LIST_QNAME = QName.create(TEST_QNAME, "ordered-list");
+    public static final QName ORDERED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "ordered-list-entry");
+    public static final QName UNKEYED_LIST_QNAME = QName.create(TEST_QNAME, "unkeyed-list");
+    public static final QName UNKEYED_LIST_ENTRY_QNAME = QName.create(TEST_QNAME, "unkeyed-list-entry");
+    public static final QName CHOICE_QNAME = QName.create(TEST_QNAME, "choice");
+    private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
+    private static final String DATASTORE_AUG_YANG =
+            "/odl-datastore-augmentation.yang";
+    private static final String DATASTORE_TEST_NOTIFICATION_YANG =
+            "/odl-datastore-test-notification.yang";
+
+
+    public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier
+            .of(TEST_QNAME);
+    public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier
+            .builder(TEST_PATH).node(DESC_QNAME).build();
+    public static final YangInstanceIdentifier OUTER_LIST_PATH =
+            YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
+    public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
+    public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");
+
+    private static final Integer ONE_ID = 1;
+    private static final Integer TWO_ID = 2;
+    private static final String TWO_ONE_NAME = "one";
+    private static final String TWO_TWO_NAME = "two";
+    private static final String DESC = "Hello there";
+    private static final Long LONG_ID = 1L;
+    private static final Boolean ENABLED = true;
+    private static final Short SHORT_ID = 1;
+    private static final Byte BYTE_ID = 1;
+    // Family specific constants
+    public static final QName FAMILY_QNAME =
+            QName
+                    .create(
+                            "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:notification-test",
+                            "2014-04-17", "family");
+    public static final QName CHILDREN_QNAME = QName.create(FAMILY_QNAME,
+            "children");
+    public static final QName GRAND_CHILDREN_QNAME = QName.create(FAMILY_QNAME,
+            "grand-children");
+    public static final QName CHILD_NUMBER_QNAME = QName.create(FAMILY_QNAME,
+            "child-number");
+    public static final QName CHILD_NAME_QNAME = QName.create(FAMILY_QNAME,
+            "child-name");
+    public static final QName GRAND_CHILD_NUMBER_QNAME = QName.create(
+            FAMILY_QNAME, "grand-child-number");
+    public static final QName GRAND_CHILD_NAME_QNAME = QName.create(FAMILY_QNAME,
+            "grand-child-name");
+
+    public static final YangInstanceIdentifier FAMILY_PATH =
+            YangInstanceIdentifier.of(FAMILY_QNAME);
+    public static final YangInstanceIdentifier FAMILY_DESC_PATH =
+            YangInstanceIdentifier.builder(FAMILY_PATH).node(DESC_QNAME).build();
+    public static final YangInstanceIdentifier CHILDREN_PATH =
+            YangInstanceIdentifier.builder(FAMILY_PATH).node(CHILDREN_QNAME).build();
+
+    private static final Integer FIRST_CHILD_ID = 1;
+    private static final Integer SECOND_CHILD_ID = 2;
+
+    private static final String FIRST_CHILD_NAME = "first child";
+    private static final String SECOND_CHILD_NAME = "second child";
+
+    private static final Integer FIRST_GRAND_CHILD_ID = 1;
+    private static final Integer SECOND_GRAND_CHILD_ID = 2;
+
+    private static final String FIRST_GRAND_CHILD_NAME = "first grand child";
+    private static final String SECOND_GRAND_CHILD_NAME = "second grand child";
+
+
+    private static final MapEntryNode BAR_NODE = mapEntryBuilder(
+            OUTER_LIST_QNAME, ID_QNAME, TWO_ID) //
+            .withChild(mapNodeBuilder(INNER_LIST_QNAME) //
+                    .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) //
+                    .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) //
+                    .build()) //
             .build();
 
-    return ImmutableMapEntryNodeBuilder
-        .create()
-        .withNodeIdentifier(
-            new YangInstanceIdentifier.NodeIdentifierWithPredicates(
-                    AUGMENTED_LIST_ENTRY_QNAME, ID_QNAME, id))
-        .withChild(ImmutableNodes.leafNode(ID_QNAME, id))
-        .withChild(augmentationNode).build();
-  }
-
-
-  public static ContainerNode createFamily() {
-    final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> familyContainerBuilder =
-        ImmutableContainerNodeBuilder.create().withNodeIdentifier(
-            new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME));
-
-    final CollectionNodeBuilder<MapEntryNode, MapNode> childrenBuilder =
-        mapNodeBuilder(CHILDREN_QNAME);
-
-    final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstChildBuilder =
-        mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
-    final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> secondChildBuilder =
-        mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
-
-    final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstGrandChildBuilder =
-        mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
-            FIRST_GRAND_CHILD_ID);
-    final DataContainerNodeBuilder<YangInstanceIdentifier.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();
-  }
+    public static final InputStream getDatastoreTestInputStream() {
+        return getInputStream(DATASTORE_TEST_YANG);
+    }
+
+    public static final InputStream getDatastoreAugInputStream() {
+        return getInputStream(DATASTORE_AUG_YANG);
+    }
+
+    public static final InputStream getDatastoreTestNotificationInputStream() {
+        return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG);
+    }
+
+    private static InputStream getInputStream(final String resourceName) {
+        return TestModel.class.getResourceAsStream(resourceName);
+    }
+
+    public static SchemaContext createTestContext() {
+        List<InputStream> inputStreams = new ArrayList<>();
+        inputStreams.add(getDatastoreTestInputStream());
+        inputStreams.add(getDatastoreAugInputStream());
+        inputStreams.add(getDatastoreTestNotificationInputStream());
+
+        YangParserImpl parser = new YangParserImpl();
+        Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
+        return parser.resolveSchemaContext(modules);
+    }
+
+    public static SchemaContext createTestContextWithoutTestSchema() {
+        List<InputStream> inputStreams = new ArrayList<>();
+        inputStreams.add(getDatastoreTestNotificationInputStream());
+
+        YangParserImpl parser = new YangParserImpl();
+        Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
+        return parser.resolveSchemaContext(modules);
+    }
+
+
+    public static SchemaContext createTestContextWithoutAugmentationSchema() {
+        List<InputStream> inputStreams = new ArrayList<>();
+        inputStreams.add(getDatastoreTestInputStream());
+        inputStreams.add(getDatastoreTestNotificationInputStream());
+
+        YangParserImpl parser = new YangParserImpl();
+        Set<Module> modules = parser.parseYangModelsFromStreams(inputStreams);
+        return parser.resolveSchemaContext(modules);
+    }
+
+
+    /**
+     * Returns a test document
+     * <p/>
+     * <p/>
+     * <pre>
+     * test
+     *     outer-list
+     *          id 1
+     *     outer-list
+     *          id 2
+     *          inner-list
+     *                  name "one"
+     *          inner-list
+     *                  name "two"
+     *
+     * </pre>
+     *
+     * @return
+     */
+    public static NormalizedNode<?, ?> createDocumentOne(
+            SchemaContext schemaContext) {
+        return ImmutableContainerNodeBuilder
+                .create()
+                .withNodeIdentifier(
+                        new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName()))
+                .withChild(createTestContainer()).build();
+
+    }
+
+    public static DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
+        // Create a list of shoes
+        // This is to test leaf list entry
+        final LeafSetEntryNode<Object> nike =
+                ImmutableLeafSetEntryNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                        TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
+
+        final LeafSetEntryNode<Object> puma =
+                ImmutableLeafSetEntryNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                        TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
+
+        final LeafSetNode<Object> shoes =
+                ImmutableLeafSetNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                new YangInstanceIdentifier.NodeIdentifier(QName.create(
+                                        TEST_QNAME, "shoe"))).withChild(nike).withChild(puma)
+                        .build();
+
+
+        // Test a leaf-list where each entry contains an identity
+        final LeafSetEntryNode<Object> cap1 =
+                ImmutableLeafSetEntryNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                        TEST_QNAME, "capability"), DESC_QNAME))
+                        .withValue(DESC_QNAME).build();
+
+        final LeafSetNode<Object> capabilities =
+                ImmutableLeafSetNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                new YangInstanceIdentifier.NodeIdentifier(QName.create(
+                                        TEST_QNAME, "capability"))).withChild(cap1).build();
+
+        ContainerNode switchFeatures =
+                ImmutableContainerNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                new YangInstanceIdentifier.NodeIdentifier(SWITCH_FEATURES_QNAME))
+                        .withChild(capabilities).build();
+
+        // Create a leaf list with numbers
+        final LeafSetEntryNode<Object> five =
+                ImmutableLeafSetEntryNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                (new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                        TEST_QNAME, "number"), 5))).withValue(5).build();
+        final LeafSetEntryNode<Object> fifteen =
+                ImmutableLeafSetEntryNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                (new YangInstanceIdentifier.NodeWithValue(QName.create(
+                                        TEST_QNAME, "number"), 15))).withValue(15).build();
+        final LeafSetNode<Object> numbers =
+                ImmutableLeafSetNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                new YangInstanceIdentifier.NodeIdentifier(QName.create(
+                                        TEST_QNAME, "number"))).withChild(five).withChild(fifteen)
+                        .build();
+
+
+        // Create augmentations
+        MapEntryNode augMapEntry = createAugmentedListEntry(1, "First Test");
+
+        // Create a bits leaf
+        NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>>
+                myBits = Builders.leafBuilder().withNodeIdentifier(
+                new YangInstanceIdentifier.NodeIdentifier(
+                        QName.create(TEST_QNAME, "my-bits"))).withValue(
+                ImmutableSet.of("foo", "bar"));
+
+        // Create unkeyed list entry
+        UnkeyedListEntryNode unkeyedListEntry =
+                Builders.unkeyedListEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_ENTRY_QNAME)).
+                        withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed-entry-name")).build();
+
+        // Create YangInstanceIdentifier with all path arg types.
+        YangInstanceIdentifier instanceID = YangInstanceIdentifier.create(
+                new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "qname")),
+                new YangInstanceIdentifier.NodeIdentifierWithPredicates(QName.create(TEST_QNAME, "list-entry"),
+                        QName.create(TEST_QNAME, "key"), 10),
+                new YangInstanceIdentifier.AugmentationIdentifier(ImmutableSet.of(
+                        QName.create(TEST_QNAME, "aug1"), QName.create(TEST_QNAME, "aug2"))),
+                new YangInstanceIdentifier.NodeWithValue(QName.create(TEST_QNAME, "leaf-list-entry"), "foo"));
+
+        Map<QName, Object> keyValues = new HashMap<>();
+        keyValues.put(CHILDREN_QNAME, FIRST_CHILD_NAME);
+
+
+        // Create the document
+        return ImmutableContainerNodeBuilder
+                .create()
+                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
+                .withChild(myBits.build())
+                .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
+                .withChild(ImmutableNodes.leafNode(BOOLEAN_LEAF_QNAME, ENABLED))
+                .withChild(ImmutableNodes.leafNode(SHORT_LEAF_QNAME, SHORT_ID))
+                .withChild(ImmutableNodes.leafNode(BYTE_LEAF_QNAME, BYTE_ID))
+                .withChild(ImmutableNodes.leafNode(TestModel.BIGINTEGER_LEAF_QNAME, BigInteger.valueOf(100)))
+                .withChild(ImmutableNodes.leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, BigDecimal.valueOf(1.2)))
+                .withChild(ImmutableNodes.leafNode(SOME_REF_QNAME, instanceID))
+                .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
+                .withChild(Builders.unkeyedListBuilder()
+                        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME))
+                        .withChild(unkeyedListEntry).build())
+                .withChild(Builders.choiceBuilder()
+                        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_QNAME))
+                        .withChild(ImmutableNodes.leafNode(DESC_QNAME, LONG_ID)).build())
+                .withChild(Builders.orderedMapBuilder().
+                        withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(DESC_QNAME)).
+                        withValue(ImmutableList.<MapEntryNode>builder().add(augMapEntry).build()).build())
+                        // .withChild(augmentationNode)
+                .withChild(shoes)
+                .withChild(numbers)
+                .withChild(switchFeatures)
+                .withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(augMapEntry).build())
+                .withChild(mapNodeBuilder(OUTER_LIST_QNAME)
+                                .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
+                                .withChild(BAR_NODE).build()
+                );
+    }
+
+    public static ContainerNode createTestContainer() {
+        return createBaseTestContainerBuilder().build();
+    }
+
+    public static MapEntryNode createAugmentedListEntry(int id, String name) {
+
+        Set<QName> childAugmentations = new HashSet<>();
+        childAugmentations.add(AUG_CONT_QNAME);
+
+        ContainerNode augCont =
+                ImmutableContainerNodeBuilder
+                        .create()
+                        .withNodeIdentifier(
+                                new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME))
+                        .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build();
+
+
+        final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier =
+                new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
+
+        final AugmentationNode augmentationNode =
+                Builders.augmentationBuilder()
+                        .withNodeIdentifier(augmentationIdentifier).withChild(augCont)
+                        .build();
+
+        return ImmutableMapEntryNodeBuilder
+                .create()
+                .withNodeIdentifier(
+                        new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+                                AUGMENTED_LIST_ENTRY_QNAME, ID_QNAME, id))
+                .withChild(ImmutableNodes.leafNode(ID_QNAME, id))
+                .withChild(augmentationNode).build();
+    }
+
+
+    public static ContainerNode createFamily() {
+        final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> familyContainerBuilder =
+                ImmutableContainerNodeBuilder.create().withNodeIdentifier(
+                        new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME));
+
+        final CollectionNodeBuilder<MapEntryNode, MapNode> childrenBuilder =
+                mapNodeBuilder(CHILDREN_QNAME);
+
+        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstChildBuilder =
+                mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
+        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> secondChildBuilder =
+                mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
+
+        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> firstGrandChildBuilder =
+                mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
+                        FIRST_GRAND_CHILD_ID);
+        final DataContainerNodeBuilder<YangInstanceIdentifier.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();
+    }
 
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.