Merge "Changed NetconfDeviceDatastoreAdapter and NetconfDeviceTopologyAdapter to...
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / TestUtils.java
index 7d6da6a94f3f41a89a8b107f9743297f3ff8f3e3..f89e2ccb60cac8ff9fda0caff166bc6d66842f65 100644 (file)
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.io.BufferedReader;
@@ -47,10 +46,13 @@ import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
 import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
+import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
 import org.opendaylight.controller.sal.restconf.impl.NodeWrapper;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
 import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.controller.sal.restconf.impl.RestconfError;
 import org.opendaylight.controller.sal.restconf.impl.RestconfError.ErrorTag;
@@ -165,17 +167,26 @@ public final class TestUtils {
     }
 
     /**
+     * @deprecated method will be removed in Lithium release
+     *      we don't wish to use Node and CompositeNode anywhere -
      *
      * Fill missing data (namespaces) and build correct data type in {@code compositeNode} according to
      * {@code dataSchemaNode}. The method {@link RestconfImpl#createConfigurationData createConfigurationData} is used
      * because it contains calling of method {code normalizeNode}
      */
+    @Deprecated
     public static void normalizeCompositeNode(final Node<?> node, final Set<Module> modules, final String schemaNodePath) {
         final RestconfImpl restconf = RestconfImpl.getInstance();
         ControllerContext.getInstance().setSchemas(TestUtils.loadSchemaContext(modules));
-
         prepareMocksForRestconf(modules, restconf);
-        restconf.updateConfigurationData(schemaNodePath, node);
+
+        final InstanceIdentifierContext iiContext = ControllerContext.getInstance().toInstanceIdentifier(schemaNodePath);
+        final DOMMountPoint mountPoint = iiContext.getMountPoint();
+        final CompositeNode value = RestconfImpl.getInstance().normalizeNode(node, (DataSchemaNode) iiContext.getSchemaNode(), mountPoint);
+        final NormalizedNode<?, ?> normNodePayload = compositeNodeToDatastoreNormalizedNode(value, (DataSchemaNode) iiContext.getSchemaNode());
+        final NormalizedNodeContext normlNodeContext = new NormalizedNodeContext(iiContext, normNodePayload);
+
+        restconf.updateConfigurationData(schemaNodePath, normlNodeContext);
     }
 
     /**
@@ -393,6 +404,11 @@ public final class TestUtils {
                 predicate);
     }
 
+    /**
+     * @deprecated method has to be removed for Lithium release
+     *          so please use prepareNormalizedNodeWithIetfInterfacesInterfacesData method
+     */
+    @Deprecated
     public static CompositeNode prepareCompositeNodeWithIetfInterfacesInterfacesData() {
         final CompositeNodeBuilder<ImmutableCompositeNode> interfaceBuilder = ImmutableCompositeNode.builder();
         interfaceBuilder.addLeaf(buildQName("name", "dummy", "2014-07-29"), "eth0");