<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>
<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>
* 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;
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;
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);
}
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
* 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;
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;
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;
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 =
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);
}
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);
}
}
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);
}
@VisibleForTesting
- Map<NodeKey, RoutedRpcRegistration<EventSourceService>> getRoutedRpcRegistrations() {
+ Map<NodeKey, Registration> getRoutedRpcRegistrations() {
return routedRpcRegistrations;
}
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"
*/
package org.opendaylight.controller.messagebus.app.impl;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
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;
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);
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();
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;
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
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();
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);
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
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 =
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));
}