Migrate messagebus-impl to MDSAL APIs 06/79206/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 3 Jan 2019 20:31:11 +0000 (21:31 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 3 Jan 2019 20:31:11 +0000 (21:31 +0100)
This removes yet another user of long-deprecated APIs, migrating
it over to MD-SAL.

Change-Id: I51f2ce0e01ed3078dbd2fa4ad6eb91081d692fa3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/messagebus-impl/pom.xml
opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopic.java
opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java
opendaylight/md-sal/messagebus-impl/src/main/resources/org/opendaylight/blueprint/messagebus.xml
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java
opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java

index 56beed9..2d0a6f9 100644 (file)
@@ -26,20 +26,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 
     <dependencies>
         <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-binding-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-core-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-common-util</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-data-impl</artifactId>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-binding-api</artifactId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
@@ -53,19 +41,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>messagebus-spi</artifactId>
         </dependency>
-
-        <!-- Testing Dependencies -->
-        <dependency>
-              <groupId>org.glassfish.jersey.test-framework.providers</groupId>
-              <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
-              <version>2.4</version>
-              <scope>test</scope>
-        </dependency>
-        <dependency>
-              <groupId>org.mockito</groupId>
-              <artifactId>mockito-core</artifactId>
-              <scope>test</scope>
-        </dependency>
     </dependencies>
 
 </project>
index a84f260..f2ac8d5 100644 (file)
@@ -5,10 +5,8 @@
  * 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.messagebus.app.impl;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -16,17 +14,18 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
 import java.util.UUID;
 import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.ExecutionException;
 import java.util.regex.Pattern;
 import javax.annotation.Nonnull;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.DisJoinTopicInput;
@@ -117,7 +116,7 @@ public final class EventSourceTopic implements DataTreeChangeListener<Node>, Aut
         LOG.debug("Notify existing nodes");
         final Pattern nodeRegex = this.nodeIdPattern;
 
-        final ReadOnlyTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction();
+        final ReadTransaction tx = eventSourceTopology.getDataBroker().newReadOnlyTransaction();
         final ListenableFuture<Optional<Topology>> future =
                 tx.read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
 
@@ -171,11 +170,9 @@ public final class EventSourceTopic implements DataTreeChangeListener<Node>, Aut
     }
 
     private void registerListner(final EventSourceTopology eventSourceTopology) {
-        this.listenerRegistration =
-                eventSourceTopology.getDataBroker().registerDataTreeChangeListener(new DataTreeIdentifier<>(
-                        LogicalDatastoreType.OPERATIONAL,
-                        EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class)),
-                        this);
+        this.listenerRegistration = eventSourceTopology.getDataBroker().registerDataTreeChangeListener(
+            DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+                EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class)), this);
     }
 
     @Override
index 50b8e4f..7f53a53 100644 (file)
@@ -5,26 +5,25 @@
  * 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.messagebus.app.impl;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.messagebus.app.util.Util;
 import org.opendaylight.controller.messagebus.spi.EventSource;
 import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
 import org.opendaylight.controller.messagebus.spi.EventSourceRegistry;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicInput;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicOutput;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicOutputBuilder;
@@ -41,7 +40,6 @@ import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.even
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.TopologyTypes1Builder;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.topology.event.source.type.TopologyEventSource;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.topology.event.source.type.TopologyEventSourceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
@@ -50,6 +48,8 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
@@ -65,29 +65,26 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR
     private static final LogicalDatastoreType OPERATIONAL = LogicalDatastoreType.OPERATIONAL;
 
     static final InstanceIdentifier<Topology> EVENT_SOURCE_TOPOLOGY_PATH =
-            InstanceIdentifier.create(NetworkTopology.class)
-                    .child(Topology.class, EVENT_SOURCE_TOPOLOGY_KEY);
+            InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, EVENT_SOURCE_TOPOLOGY_KEY);
 
-    private static final InstanceIdentifier<TopologyTypes1> TOPOLOGY_TYPE_PATH =
-            EVENT_SOURCE_TOPOLOGY_PATH
-                    .child(TopologyTypes.class)
-                    .augmentation(TopologyTypes1.class);
+    private static final InstanceIdentifier<TopologyTypes1> TOPOLOGY_TYPE_PATH = EVENT_SOURCE_TOPOLOGY_PATH
+            .child(TopologyTypes.class).augmentation(TopologyTypes1.class);
 
-    private final Map<TopicId,EventSourceTopic> eventSourceTopicMap = new ConcurrentHashMap<>();
-    private final Map<NodeKey, RoutedRpcRegistration<EventSourceService>> routedRpcRegistrations =
-            new ConcurrentHashMap<>();
+    private final Map<TopicId, EventSourceTopic> eventSourceTopicMap = new ConcurrentHashMap<>();
+    private final Map<NodeKey, Registration> routedRpcRegistrations = new ConcurrentHashMap<>();
 
     private final DataBroker dataBroker;
-    private final RpcRegistration<EventAggregatorService> aggregatorRpcReg;
+    private final ObjectRegistration<EventSourceTopology> aggregatorRpcReg;
     private final EventSourceService eventSourceService;
-    private final RpcProviderRegistry rpcRegistry;
+    private final RpcProviderService rpcRegistry;
 
-    public EventSourceTopology(final DataBroker dataBroker, final RpcProviderRegistry rpcRegistry) {
+    public EventSourceTopology(final DataBroker dataBroker, final RpcProviderService providerService,
+            RpcConsumerRegistry rpcService) {
 
         this.dataBroker = dataBroker;
-        this.rpcRegistry = rpcRegistry;
-        aggregatorRpcReg = rpcRegistry.addRpcImplementation(EventAggregatorService.class, this);
-        eventSourceService = rpcRegistry.getRpcService(EventSourceService.class);
+        this.rpcRegistry = providerService;
+        aggregatorRpcReg = providerService.registerRpcImplementation(EventAggregatorService.class, this);
+        eventSourceService = rpcService.getRpcService(EventSourceService.class);
 
         final TopologyEventSource topologySource = new TopologyEventSourceBuilder().build();
         final TopologyTypes1 topologyTypeAugment =
@@ -96,15 +93,15 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR
         LOG.info("EventSourceRegistry has been initialized");
     }
 
-    private <T extends DataObject>  void putData(final LogicalDatastoreType store,
+    private <T extends DataObject> void putData(final LogicalDatastoreType store,
                                                  final InstanceIdentifier<T> path,
                                                  final T data) {
 
         final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
-        tx.put(store, path, data, true);
-        Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+        tx.mergeParentStructurePut(store, path, data);
+        tx.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.trace("Data has put into datastore {} {}", store, path);
             }
 
@@ -119,9 +116,9 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR
             final InstanceIdentifier<T> path) {
         final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
         tx.delete(OPERATIONAL, path);
-        Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
+        tx.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
-            public void onSuccess(final Void result) {
+            public void onSuccess(final CommitInfo result) {
                 LOG.trace("Data has deleted from datastore {} {}", store, path);
             }
 
@@ -185,21 +182,18 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR
     }
 
     public void register(final EventSource eventSource) {
-
         final NodeKey nodeKey = eventSource.getSourceNodeKey();
         final KeyedInstanceIdentifier<Node, NodeKey> sourcePath = EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey);
-        final RoutedRpcRegistration<EventSourceService> reg = rpcRegistry.addRoutedRpcImplementation(
-                EventSourceService.class, eventSource);
-        reg.registerPath(NodeContext.class, sourcePath);
-        routedRpcRegistrations.put(nodeKey,reg);
+        final Registration reg = rpcRegistry.registerRpcImplementation(EventSourceService.class, eventSource,
+            Collections.singleton(sourcePath));
+        routedRpcRegistrations.put(nodeKey, reg);
         insert(sourcePath);
-
     }
 
     public void unRegister(final EventSource eventSource) {
         final NodeKey nodeKey = eventSource.getSourceNodeKey();
         final KeyedInstanceIdentifier<Node, NodeKey> sourcePath = EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey);
-        final RoutedRpcRegistration<EventSourceService> removeRegistration = routedRpcRegistrations.remove(nodeKey);
+        final Registration removeRegistration = routedRpcRegistrations.remove(nodeKey);
         if (removeRegistration != null) {
             removeRegistration.close();
             remove(sourcePath);
@@ -222,7 +216,7 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR
     }
 
     @VisibleForTesting
-    Map<NodeKey, RoutedRpcRegistration<EventSourceService>> getRoutedRpcRegistrations() {
+    Map<NodeKey, Registration> getRoutedRpcRegistrations() {
         return routedRpcRegistrations;
     }
 
index b24d648..24a2013 100644 (file)
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
            odl:use-default-for-reference-types="true">
 
-  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
-  <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+  <reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
+  <reference id="consumerRegistry" interface="org.opendaylight.mdsal.binding.api.RpcConsumerRegistry"/>
+  <reference id="providerRegistry" interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
 
   <bean id="eventSourceTopology" class="org.opendaylight.controller.messagebus.app.impl.EventSourceTopology"
           destroy-method="close">
     <argument ref="dataBroker"/>
-    <argument ref="rpcRegistry"/>
+    <argument ref="providerRegistry"/>
+    <argument ref="consumerRegistry"/>
   </bean>
 
   <service ref="eventSourceTopology"
index 3c3b2b5..d785287 100644 (file)
@@ -8,26 +8,25 @@
 package org.opendaylight.controller.messagebus.app.impl;
 
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.Collections;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.NotificationPattern;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.JoinTopicInput;
@@ -65,14 +64,14 @@ public class EventSourceTopicTest {
 
         WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
         doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
-        doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class),
-                any(InstanceIdentifier.class), any(DataObject.class),eq(true));
-        CheckedFuture checkedFutureWriteMock = mock(CheckedFuture.class);
-        doReturn(checkedFutureWriteMock).when(writeTransactionMock).submit();
+        doNothing().when(writeTransactionMock).mergeParentStructurePut(any(LogicalDatastoreType.class),
+                any(InstanceIdentifier.class), any(DataObject.class));
+        FluentFuture checkedFutureWriteMock = mock(FluentFuture.class);
+        doReturn(checkedFutureWriteMock).when(writeTransactionMock).commit();
 
-        ReadOnlyTransaction readOnlyTransactionMock = mock(ReadOnlyTransaction.class);
+        ReadTransaction readOnlyTransactionMock = mock(ReadTransaction.class);
         doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
-        CheckedFuture checkedFutureReadMock = mock(CheckedFuture.class);
+        FluentFuture checkedFutureReadMock = mock(FluentFuture.class);
         doReturn(checkedFutureReadMock).when(readOnlyTransactionMock).read(LogicalDatastoreType.OPERATIONAL,
                 EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
         eventSourceTopic = EventSourceTopic.create(notificationPattern, "nodeIdPattern1", eventSourceTopologyMock);
@@ -95,7 +94,7 @@ public class EventSourceTopicTest {
         DataTreeModification<Node> mockDataTreeModification = mock(DataTreeModification.class);
         DataObjectModification<Node> mockModification = mock(DataObjectModification.class);
         doReturn(mockModification).when(mockDataTreeModification).getRootNode();
-        doReturn(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, instanceIdentifierMock))
+        doReturn(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, instanceIdentifierMock))
                 .when(mockDataTreeModification).getRootPath();
         doReturn(DataObjectModification.ModificationType.WRITE).when(mockModification).getModificationType();
 
index 8eb46e1..79a7a55 100644 (file)
@@ -8,30 +8,31 @@
 package org.opendaylight.controller.messagebus.app.impl;
 
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.messagebus.spi.EventSource;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.CreateTopicInput;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInput;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.DestroyTopicInputBuilder;
@@ -40,51 +41,53 @@ import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.even
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.Pattern;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventaggregator.rev141202.TopicId;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.EventSourceService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
 public class EventSourceTopologyTest {
 
     EventSourceTopology eventSourceTopology;
     DataBroker dataBrokerMock;
-    RpcProviderRegistry rpcProviderRegistryMock;
+    RpcProviderService rpcProviderRegistryMock;
+    RpcConsumerRegistry rpcServiceMock;
     CreateTopicInput createTopicInputMock;
     ListenerRegistration<?> listenerRegistrationMock;
     NodeKey nodeKey;
-    RpcRegistration<EventAggregatorService> aggregatorRpcReg;
+    ObjectRegistration<EventAggregatorService> aggregatorRpcReg;
 
     @Before
     public void setUp() {
         dataBrokerMock = mock(DataBroker.class);
-        rpcProviderRegistryMock = mock(RpcProviderRegistry.class);
+        rpcProviderRegistryMock = mock(RpcProviderService.class);
+        rpcServiceMock = mock(RpcConsumerRegistry.class);
     }
 
     @Test
     public void constructorTest() {
         constructorTestHelper();
-        eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock);
+        eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock, rpcServiceMock);
         assertNotNull("Instance has not been created correctly.", eventSourceTopology);
     }
 
     private void constructorTestHelper() {
-        aggregatorRpcReg = mock(RpcRegistration.class);
+        aggregatorRpcReg = mock(ObjectRegistration.class);
         EventSourceService eventSourceService = mock(EventSourceService.class);
-        doReturn(aggregatorRpcReg).when(rpcProviderRegistryMock).addRpcImplementation(eq(EventAggregatorService.class),
-                any(EventSourceTopology.class));
-        doReturn(eventSourceService).when(rpcProviderRegistryMock).getRpcService(EventSourceService.class);
+        doReturn(aggregatorRpcReg).when(rpcProviderRegistryMock).registerRpcImplementation(
+            eq(EventAggregatorService.class), any(EventSourceTopology.class));
+        doReturn(eventSourceService).when(rpcServiceMock).getRpcService(EventSourceService.class);
         WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
         doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
-        doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class),
-                any(DataObject.class),eq(true));
-        CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
-        doReturn(checkedFutureMock).when(writeTransactionMock).submit();
+        doNothing().when(writeTransactionMock).mergeParentStructurePut(any(LogicalDatastoreType.class),
+            any(InstanceIdentifier.class), any(DataObject.class));
+        FluentFuture checkedFutureMock = mock(FluentFuture.class);
+        doReturn(checkedFutureMock).when(writeTransactionMock).commit();
     }
 
     @Test
@@ -109,7 +112,7 @@ public class EventSourceTopologyTest {
     private void topicTestHelper() throws Exception {
         constructorTestHelper();
         createTopicInputMock = mock(CreateTopicInput.class);
-        eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock);
+        eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock, rpcServiceMock);
 
         NotificationPattern notificationPattern = new NotificationPattern("value1");
         doReturn(notificationPattern).when(createTopicInputMock).getNotificationPattern();
@@ -120,18 +123,15 @@ public class EventSourceTopologyTest {
         doReturn(listenerRegistrationMock).when(dataBrokerMock).registerDataTreeChangeListener(
                 any(DataTreeIdentifier.class), any(EventSourceTopic.class));
 
-        ReadOnlyTransaction readOnlyTransactionMock = mock(ReadOnlyTransaction.class);
+        ReadTransaction readOnlyTransactionMock = mock(ReadTransaction.class);
         doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
 
-        CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
+        FluentFuture checkedFutureMock = mock(FluentFuture.class);
         doReturn(checkedFutureMock).when(readOnlyTransactionMock).read(eq(LogicalDatastoreType.OPERATIONAL),
                 any(InstanceIdentifier.class));
-        Optional optionalMock = mock(Optional.class);
-        doReturn(optionalMock).when(checkedFutureMock).checkedGet();
-        doReturn(true).when(optionalMock).isPresent();
-
         Topology topologyMock = mock(Topology.class);
-        doReturn(topologyMock).when(optionalMock).get();
+        doReturn(Optional.of(topologyMock)).when(checkedFutureMock).get();
+
         Node nodeMock = mock(Node.class);
         List<Node> nodeList = new ArrayList<>();
         nodeList.add(nodeMock);
@@ -164,15 +164,12 @@ public class EventSourceTopologyTest {
         nodeKey = new NodeKey(nodeId);
         doReturn(nodeKey).when(nodeMock).key();
         doReturn(nodeKey).when(eventSourceMock).getSourceNodeKey();
-        BindingAwareBroker.RoutedRpcRegistration routedRpcRegistrationMock = mock(
-                BindingAwareBroker.RoutedRpcRegistration.class);
-        doReturn(routedRpcRegistrationMock).when(rpcProviderRegistryMock)
-                .addRoutedRpcImplementation(EventSourceService.class, eventSourceMock);
-        doNothing().when(routedRpcRegistrationMock).registerPath(eq(NodeContext.class),
-                any(KeyedInstanceIdentifier.class));
+        ObjectRegistration routedRpcRegistrationMock = mock(ObjectRegistration.class);
+        doReturn(routedRpcRegistrationMock).when(rpcProviderRegistryMock).registerRpcImplementation(
+            eq(EventSourceService.class), eq(eventSourceMock), any(Set.class));
         eventSourceTopology.register(eventSourceMock);
-        verify(routedRpcRegistrationMock, times(1)).registerPath(eq(NodeContext.class),
-                any(KeyedInstanceIdentifier.class));
+        verify(rpcProviderRegistryMock, times(1)).registerRpcImplementation(eq(EventSourceService.class),
+            eq(eventSourceMock), any(Set.class));
     }
 
     @Test
@@ -181,8 +178,7 @@ public class EventSourceTopologyTest {
         EventSource eventSourceMock = mock(EventSource.class);
         NodeId nodeId = new NodeId("nodeIdValue1");
         nodeKey = new NodeKey(nodeId);
-        Map<NodeKey, BindingAwareBroker.RoutedRpcRegistration<EventSourceService>> localMap = eventSourceTopology
-                .getRoutedRpcRegistrations();
+        Map<NodeKey, Registration> localMap = eventSourceTopology.getRoutedRpcRegistrations();
         NodeKey nodeKeyMock = mock(NodeKey.class);
         doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey();
         BindingAwareBroker.RoutedRpcRegistration<EventSourceService> routedRpcRegistrationMock =
@@ -201,12 +197,9 @@ public class EventSourceTopologyTest {
         nodeKey = new NodeKey(nodeId);
         doReturn(nodeKey).when(nodeMock).key();
         doReturn(nodeKey).when(eventSourceMock).getSourceNodeKey();
-        BindingAwareBroker.RoutedRpcRegistration routedRpcRegistrationMock = mock(
-                BindingAwareBroker.RoutedRpcRegistration.class);
+        ObjectRegistration routedRpcRegistrationMock = mock(ObjectRegistration.class);
         doReturn(routedRpcRegistrationMock).when(rpcProviderRegistryMock)
-                .addRoutedRpcImplementation(EventSourceService.class, eventSourceMock);
-        doNothing().when(routedRpcRegistrationMock).registerPath(eq(NodeContext.class),
-                any(KeyedInstanceIdentifier.class));
+                .registerRpcImplementation(eq(EventSourceService.class), eq(eventSourceMock), any(Set.class));
         assertNotNull("Return value has not been created correctly.",
                 eventSourceTopology.registerEventSource(eventSourceMock));
     }

©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.