-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.yang.data.impl;\r
-\r
-import java.net.URI;\r
-import java.util.Date;\r
-\r
-import junit.framework.Assert;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.yangtools.yang.common.QName;\r
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;\r
-import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;\r
-import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;\r
-import org.opendaylight.yangtools.yang.data.api.Node;\r
-import org.opendaylight.yangtools.yang.data.api.SimpleNode;\r
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.w3c.dom.Document;\r
-\r
-/**\r
- * @author michal.rehak\r
- *\r
- */\r
-public class NodeModificationBuilderImplTest {\r
-\r
- private static final Logger LOG = LoggerFactory\r
- .getLogger(NodeModificationBuilderImplTest.class);\r
-\r
- private SchemaContext schemaCtx;\r
- private QName qName;\r
- private CompositeNode network;\r
- private NodeModificationBuilderImpl nodeModificationBuilder;\r
-\r
- private String ns;\r
-\r
- /**\r
- * @throws Exception\r
- */\r
- private void dumpResult() throws Exception {\r
- CompositeNode diffTree = nodeModificationBuilder.buildDiffTree();\r
- CompositeNode diffTreeImmutable = NodeFactory.copyDeepAsImmutable(diffTree, null);\r
-\r
- Document diffShadow = NodeUtils.buildShadowDomTree(diffTreeImmutable);\r
- NodeHelper.dumpDoc(diffShadow, System.out);\r
- }\r
-\r
- /**\r
- * prepare schemaContext\r
- * @throws Exception\r
- */\r
- @Before\r
- public void setUp() throws Exception {\r
- schemaCtx = NodeHelper.loadSchemaContext();\r
-\r
- ns = "urn:opendaylight:controller:network";\r
- qName = new QName(\r
- new URI(ns),\r
- new Date(1369000800000L), "topos");\r
- network = NodeHelper.buildTestConfigTree(qName);\r
-\r
- nodeModificationBuilder = new NodeModificationBuilderImpl(network, schemaCtx);\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#getMutableEquivalent(org.opendaylight.yangtools.yang.data.api.Node)}\r
- * .\r
- */\r
- @Test\r
- public void testGetMutableEquivalent() {\r
- MutableCompositeNode rootMutable = (MutableCompositeNode)\r
- nodeModificationBuilder.getMutableEquivalent(network);\r
-\r
- CompositeNode topologies = network.getCompositesByName("topologies").iterator().next();\r
- Node<?> mutableEquivalent = nodeModificationBuilder.getMutableEquivalent(topologies);\r
- CompositeNode topologiesMutable = rootMutable.getCompositesByName("topologies").iterator().next();\r
-\r
- Assert.assertSame(topologiesMutable, mutableEquivalent);\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
- * .\r
- * @throws Exception\r
- */\r
- @Test\r
- public void testBuildDiffTreeAddSimple() throws Exception {\r
- LOG.debug("testBuildDiffTreeAddSimple");\r
- Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
- CompositeNode needle = NodeUtils.findNodeByXpath(networkShadow,\r
- NodeHelper.AddNamespaceToPattern(\r
- "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]", ns));\r
-\r
- MutableCompositeNode mutableParent = (MutableCompositeNode)\r
- nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
- MutableSimpleNode<String> newMutable = NodeFactory.createMutableSimpleNode(\r
- new QName(needle.getNodeType(), "anySubNode"), mutableParent, "42", null, null);\r
-\r
- nodeModificationBuilder.addNode(newMutable);\r
- dumpResult();\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
- * .\r
- * @throws Exception\r
- */\r
- @Test\r
- public void testBuildDiffTreeAddComposite() throws Exception {\r
- LOG.debug("testBuildDiffTreeAddComposite");\r
- Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
- CompositeNode needle = NodeUtils.findNodeByXpath(networkShadow,\r
- NodeHelper.AddNamespaceToPattern(\r
- "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]", ns));\r
-\r
- MutableCompositeNode mutableParent = (MutableCompositeNode)\r
- nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
- MutableSimpleNode<String> newMutable = NodeFactory.createMutableSimpleNode(\r
- new QName(needle.getNodeType(), "anySubNode"), null, "42", null, null);\r
-\r
- MutableCompositeNode newMutableCom = NodeFactory.createMutableCompositeNode(\r
- new QName(needle.getNodeType(), "anySubNode"), mutableParent,\r
- NodeUtils.buildChildrenList(newMutable), null, null);\r
- NodeUtils.fixChildrenRelation(newMutableCom);\r
- newMutableCom.init();\r
-\r
- nodeModificationBuilder.addNode(newMutableCom);\r
- dumpResult();\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
- * .\r
- * @throws Exception\r
- */\r
- @Test\r
- public void testBuildDiffTreeDeleteComposite() throws Exception {\r
- LOG.debug("testBuildDiffTreeDeleteComposite");\r
- Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
- SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
- NodeHelper.AddNamespaceToPattern(\r
- "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
- @SuppressWarnings("unchecked")\r
- MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
- nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
- nodeModificationBuilder.deleteNode(mutableNeedle.getParent().asMutable());\r
- dumpResult();\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
- * .\r
- * @throws Exception\r
- */\r
- @Test\r
- public void testBuildDiffTreeDeleteSimple() throws Exception {\r
- LOG.debug("testBuildDiffTreeDeleteSimple");\r
- Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
- SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
- NodeHelper.AddNamespaceToPattern(\r
- "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
- @SuppressWarnings("unchecked")\r
- MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
- nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
- nodeModificationBuilder.deleteNode(mutableNeedle);\r
- dumpResult();\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
- * .\r
- * @throws Exception\r
- */\r
- @Test\r
- public void testBuildDiffTreeMerge() throws Exception {\r
- LOG.debug("testBuildDiffTreeMerge");\r
- Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
- SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
- NodeHelper.AddNamespaceToPattern(\r
- "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
- @SuppressWarnings("unchecked")\r
- MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
- nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
- mutableNeedle.setValue("tpId_18x");\r
- nodeModificationBuilder.mergeNode(mutableNeedle.getParent().asMutable());\r
- dumpResult();\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
- * .\r
- * @throws Exception\r
- */\r
- @Test\r
- public void testBuildDiffTreeRemoveComposite() throws Exception {\r
- LOG.debug("testBuildDiffTreeRemoveComposite");\r
- Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
- SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
- NodeHelper.AddNamespaceToPattern(\r
- "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
- @SuppressWarnings("unchecked")\r
- MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
- nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
- nodeModificationBuilder.removeNode(mutableNeedle.getParent().asMutable());\r
- dumpResult();\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
- * .\r
- * @throws Exception\r
- */\r
- @Test\r
- public void testBuildDiffTreeRemoveSimple() throws Exception {\r
- LOG.debug("testBuildDiffTreeRemoveSimple");\r
- Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
- SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
- NodeHelper.AddNamespaceToPattern(\r
- "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
- @SuppressWarnings("unchecked")\r
- MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
- nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
- nodeModificationBuilder.removeNode(mutableNeedle);\r
- dumpResult();\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
- * .\r
- * @throws Exception\r
- */\r
- @Test\r
- public void testBuildDiffTreeReplaceComposite() throws Exception {\r
- LOG.debug("testBuildDiffTreeReplaceComposite");\r
- Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
- SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
- NodeHelper.AddNamespaceToPattern(\r
- "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
- @SuppressWarnings("unchecked")\r
- MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
- nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
- mutableNeedle.setValue("tpId_18x");\r
- nodeModificationBuilder.replaceNode(mutableNeedle.getParent().asMutable());\r
- dumpResult();\r
- }\r
-\r
- /**\r
- * Test method for\r
- * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}\r
- * .\r
- * @throws Exception\r
- */\r
- @Test\r
- public void testBuildDiffTreeReplaceSimple() throws Exception {\r
- LOG.debug("testBuildDiffTreeReplaceSimple");\r
- Document networkShadow = NodeUtils.buildShadowDomTree(network);\r
- SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow,\r
- NodeHelper.AddNamespaceToPattern(\r
- "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));\r
-\r
- @SuppressWarnings("unchecked")\r
- MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>)\r
- nodeModificationBuilder.getMutableEquivalent(needle);\r
-\r
- mutableNeedle.setValue("tpId_18x");\r
- nodeModificationBuilder.replaceNode(mutableNeedle);\r
- dumpResult();\r
- }\r
-\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 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.yangtools.yang.data.impl;
+
+import java.net.URI;
+import java.util.Date;
+
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;
+import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+
+/**
+ * @author michal.rehak
+ *
+ */
+public class NodeModificationBuilderImplTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NodeModificationBuilderImplTest.class);
+
+ private SchemaContext schemaCtx;
+ private QName qName;
+ private CompositeNode network;
+ private NodeModificationBuilderImpl nodeModificationBuilder;
+
+ private String ns;
+
+ /**
+ * @throws Exception
+ */
+ private void dumpResult() throws Exception {
+ CompositeNode diffTree = nodeModificationBuilder.buildDiffTree();
+ CompositeNode diffTreeImmutable = NodeFactory.copyDeepAsImmutable(diffTree, null);
+
+ Document diffShadow = NodeUtils.buildShadowDomTree(diffTreeImmutable);
+ NodeHelper.dumpDoc(diffShadow, System.out);
+ }
+
+ /**
+ * prepare schemaContext
+ *
+ * @throws Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ schemaCtx = NodeHelper.loadSchemaContext();
+
+ ns = "urn:opendaylight:controller:network";
+ qName = new QName(new URI(ns), new Date(1369000800000L), "topos");
+ network = NodeHelper.buildTestConfigTree(qName);
+
+ nodeModificationBuilder = new NodeModificationBuilderImpl(schemaCtx);
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#getMutableEquivalent(org.opendaylight.yangtools.yang.data.api.Node)}
+ * .
+ */
+ @Test
+ public void testGetMutableEquivalent() {
+ MutableCompositeNode rootMutable = (MutableCompositeNode) nodeModificationBuilder.getMutableEquivalent(network);
+
+ CompositeNode topologies = network.getCompositesByName("topologies").iterator().next();
+ Node<?> mutableEquivalent = nodeModificationBuilder.getMutableEquivalent(topologies);
+ CompositeNode topologiesMutable = rootMutable.getCompositesByName("topologies").iterator().next();
+
+ Assert.assertSame(topologiesMutable, mutableEquivalent);
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBuildDiffTreeAddSimple() throws Exception {
+ LOG.debug("testBuildDiffTreeAddSimple");
+ Document networkShadow = NodeUtils.buildShadowDomTree(network);
+ CompositeNode needle = NodeUtils.findNodeByXpath(networkShadow,
+ NodeHelper.AddNamespaceToPattern("//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]", ns));
+
+ MutableCompositeNode mutableParent = (MutableCompositeNode) nodeModificationBuilder
+ .getMutableEquivalent(needle);
+
+ MutableSimpleNode<String> newMutable = NodeFactory.createMutableSimpleNode(new QName(needle.getNodeType(),
+ "anySubNode"), mutableParent, "42", null, null);
+
+ nodeModificationBuilder.addNode(newMutable);
+ dumpResult();
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBuildDiffTreeAddComposite() throws Exception {
+ LOG.debug("testBuildDiffTreeAddComposite");
+ Document networkShadow = NodeUtils.buildShadowDomTree(network);
+ CompositeNode needle = NodeUtils.findNodeByXpath(networkShadow,
+ NodeHelper.AddNamespaceToPattern("//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]", ns));
+
+ MutableCompositeNode mutableParent = (MutableCompositeNode) nodeModificationBuilder
+ .getMutableEquivalent(needle);
+
+ MutableSimpleNode<String> newMutable = NodeFactory.createMutableSimpleNode(new QName(needle.getNodeType(),
+ "anySubNode"), null, "42", null, null);
+
+ MutableCompositeNode newMutableCom = NodeFactory.createMutableCompositeNode(new QName(needle.getNodeType(),
+ "anySubNode"), mutableParent, NodeUtils.buildChildrenList(newMutable), null, null);
+ NodeUtils.fixChildrenRelation(newMutableCom);
+ newMutableCom.init();
+
+ nodeModificationBuilder.addNode(newMutableCom);
+ dumpResult();
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBuildDiffTreeDeleteComposite() throws Exception {
+ LOG.debug("testBuildDiffTreeDeleteComposite");
+ Document networkShadow = NodeUtils.buildShadowDomTree(network);
+ SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+ "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+ @SuppressWarnings("unchecked")
+ MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+ .getMutableEquivalent(needle);
+
+ nodeModificationBuilder.deleteNode(mutableNeedle.getParent().asMutable());
+ dumpResult();
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBuildDiffTreeDeleteSimple() throws Exception {
+ LOG.debug("testBuildDiffTreeDeleteSimple");
+ Document networkShadow = NodeUtils.buildShadowDomTree(network);
+ SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+ "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+ @SuppressWarnings("unchecked")
+ MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+ .getMutableEquivalent(needle);
+
+ nodeModificationBuilder.deleteNode(mutableNeedle);
+ dumpResult();
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBuildDiffTreeMerge() throws Exception {
+ LOG.debug("testBuildDiffTreeMerge");
+ Document networkShadow = NodeUtils.buildShadowDomTree(network);
+ SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+ "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+ @SuppressWarnings("unchecked")
+ MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+ .getMutableEquivalent(needle);
+
+ mutableNeedle.setValue("tpId_18x");
+ nodeModificationBuilder.mergeNode(mutableNeedle.getParent().asMutable());
+ dumpResult();
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBuildDiffTreeRemoveComposite() throws Exception {
+ LOG.debug("testBuildDiffTreeRemoveComposite");
+ Document networkShadow = NodeUtils.buildShadowDomTree(network);
+ SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+ "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+ @SuppressWarnings("unchecked")
+ MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+ .getMutableEquivalent(needle);
+
+ nodeModificationBuilder.removeNode(mutableNeedle.getParent().asMutable());
+ dumpResult();
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBuildDiffTreeRemoveSimple() throws Exception {
+ LOG.debug("testBuildDiffTreeRemoveSimple");
+ Document networkShadow = NodeUtils.buildShadowDomTree(network);
+ SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+ "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+ @SuppressWarnings("unchecked")
+ MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+ .getMutableEquivalent(needle);
+
+ nodeModificationBuilder.removeNode(mutableNeedle);
+ dumpResult();
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBuildDiffTreeReplaceComposite() throws Exception {
+ LOG.debug("testBuildDiffTreeReplaceComposite");
+ Document networkShadow = NodeUtils.buildShadowDomTree(network);
+ SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+ "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+ @SuppressWarnings("unchecked")
+ MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+ .getMutableEquivalent(needle);
+
+ mutableNeedle.setValue("tpId_18x");
+ nodeModificationBuilder.replaceNode(mutableNeedle.getParent().asMutable());
+ dumpResult();
+ }
+
+ /**
+ * Test method for
+ * {@link org.opendaylight.yangtools.yang.data.impl.NodeModificationBuilderImpl#buildDiffTree()}
+ * .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBuildDiffTreeReplaceSimple() throws Exception {
+ LOG.debug("testBuildDiffTreeReplaceSimple");
+ Document networkShadow = NodeUtils.buildShadowDomTree(network);
+ SimpleNode<?> needle = NodeUtils.findNodeByXpath(networkShadow, NodeHelper.AddNamespaceToPattern(
+ "//{0}node[{0}node-id='nodeId_19']//{0}termination-point[2]/{0}tp-id", ns));
+
+ @SuppressWarnings("unchecked")
+ MutableSimpleNode<String> mutableNeedle = (MutableSimpleNode<String>) nodeModificationBuilder
+ .getMutableEquivalent(needle);
+
+ mutableNeedle.setValue("tpId_18x");
+ nodeModificationBuilder.replaceNode(mutableNeedle);
+ dumpResult();
+ }
+
+}