From 745d7a11635b81af7b4e1f1303db071c6c6b198d Mon Sep 17 00:00:00 2001 From: Igor Bartak Date: Mon, 13 Apr 2015 13:52:07 +0200 Subject: [PATCH] Message-bus - removed trailing witespaces of new tests for messagebus-impl Change-Id: I0d3c23504ac2420e43d65a78abe50a761855e661 Signed-off-by: Igor Bartak --- .../MessageBusAppImplModuleFactoryTest.java | 2 +- .../app/impl/MessageBusAppImplModuleTest.java | 61 ++++++++++++++-- .../impl/EventSourceRegistrationImplTest.java | 54 ++++++++++++++ .../app/impl/EventSourceTopicTest.java | 4 +- .../app/impl/EventSourceTopologyTest.java | 73 +++++++++++++++++-- .../impl/NetconfEventSourceManagerTest.java | 14 ++-- .../app/impl/NetconfEventSourceTest.java | 54 +++++++------- .../app/impl/TopicDOMNotificationTest.java | 2 +- 8 files changed, 216 insertions(+), 48 deletions(-) create mode 100644 opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleFactoryTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleFactoryTest.java index 7db7dcc333..d06a1a8273 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleFactoryTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleFactoryTest.java @@ -49,4 +49,4 @@ public class MessageBusAppImplModuleFactoryTest { assertNotNull("Module has not been created correctly.", messageBusAppImplModuleFactory.createModule("instanceName1", dependencyResolverMock, dynamicMBeanWithInstanceMock, bundleContextMock)); } -} +} \ No newline at end of file diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleTest.java index 85d1a1b109..e26502f949 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleTest.java @@ -7,17 +7,37 @@ */ package org.opendaylight.controller.config.yang.messagebus.app.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; - import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.config.api.DependencyResolver; +import org.opendaylight.controller.config.api.JmxAttribute; import org.opendaylight.controller.config.api.ModuleIdentifier; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.MountPointService; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.controller.sal.core.api.Broker; +import org.opendaylight.controller.sal.core.api.Provider; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.osgi.framework.BundleContext; +import javax.management.ObjectName; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + public class MessageBusAppImplModuleTest { MessageBusAppImplModule messageBusAppImplModule; @@ -55,5 +75,34 @@ public class MessageBusAppImplModuleTest { assertEquals("Set and/or get method/s don't work correctly.", bundleContext, messageBusAppImplModule.getBundleContext()); } - //TODO: create MessageBusAppImplModule.createInstance test -} + @Test + public void createInstanceTest() throws Exception{ + org.opendaylight.controller.sal.binding.api.BindingAwareBroker bindingAwareBrokerMock = mock(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class); + Broker brokerMock = mock(Broker.class); + doReturn(brokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.core.api.Broker.class), any(ObjectName.class), any(JmxAttribute.class)); + doReturn(bindingAwareBrokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class)); + messageBusAppImplModule.resolveDependencies(); + + BindingAwareBroker.ProviderContext providerContext = mock(BindingAwareBroker.ProviderContext.class); + doReturn(providerContext).when(bindingAwareBrokerMock).registerProvider(any(BindingAwareProvider.class)); + Broker.ProviderSession providerSessionMock = mock(Broker.ProviderSession.class); + doReturn(providerSessionMock).when(brokerMock).registerProvider(any(Provider.class)); + DataBroker dataBrokerMock = mock(DataBroker.class); + doReturn(dataBrokerMock).when(providerContext).getSALService(eq(DataBroker.class)); + DOMNotificationPublishService domNotificationPublishServiceMock = mock(DOMNotificationPublishService.class); + doReturn(domNotificationPublishServiceMock).when(providerSessionMock).getService(DOMNotificationPublishService.class); + DOMMountPointService domMountPointServiceMock = mock(DOMMountPointService.class); + doReturn(domMountPointServiceMock).when(providerSessionMock).getService(DOMMountPointService.class); + MountPointService mountPointServiceMock = mock(MountPointService.class); + doReturn(mountPointServiceMock).when(providerContext).getSALService(eq(MountPointService.class)); + RpcProviderRegistry rpcProviderRegistryMock = mock(RpcProviderRegistry.class); + doReturn(rpcProviderRegistryMock).when(providerContext).getSALService(eq(RpcProviderRegistry.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)); + + assertNotNull("EventSourceRegistryWrapper has not been created correctly.", messageBusAppImplModule.createInstance()); + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java new file mode 100644 index 0000000000..9cce623523 --- /dev/null +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceRegistrationImplTest.java @@ -0,0 +1,54 @@ +/* + * 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.messagebus.app.impl; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.opendaylight.controller.messagebus.spi.EventSource; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +public class EventSourceRegistrationImplTest { + + EventSourceRegistrationImplLocal eventSourceRegistrationImplLocal; + EventSourceTopology eventSourceTopologyMock; + + @BeforeClass + public static void initTestClass() throws IllegalAccessException, InstantiationException { + } + + @Before + public void setUp() throws Exception { + EventSource eventSourceMock = mock(EventSource.class); + eventSourceTopologyMock = mock(EventSourceTopology.class); + eventSourceRegistrationImplLocal = new EventSourceRegistrationImplLocal(eventSourceMock, eventSourceTopologyMock); + } + + @Test + public void removeRegistrationTest() { + eventSourceRegistrationImplLocal.removeRegistration(); + verify(eventSourceTopologyMock, times(1)).unRegister(any(EventSource.class)); + } + + + private class EventSourceRegistrationImplLocal extends EventSourceRegistrationImpl{ + + /** + * @param instance of EventSource that has been registered by {@link EventSourceRegistryImpl#registerEventSource(Node, org.opendaylight.controller.messagebus.spi.EventSource)} + * @param eventSourceTopology + */ + public EventSourceRegistrationImplLocal(EventSource instance, EventSourceTopology eventSourceTopology) { + super(instance, eventSourceTopology); + } + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java index f369a128ad..9f513c464b 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopicTest.java @@ -74,7 +74,7 @@ public class EventSourceTopicTest { nodeIdMock = mock(NodeId.class); doReturn(nodeIdMock).when(dataObjectMock).getId(); - doReturn("0").when(nodeIdMock).getValue(); + doReturn("nodeIdPattern1").when(nodeIdMock).getValue(); } @Test @@ -84,4 +84,4 @@ public class EventSourceTopicTest { verify(eventSourceServiceMock, times(1)).joinTopic(any(JoinTopicInput.class)); } -} +} \ No newline at end of file diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java index ced2e1f01b..50ae4d9389 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopologyTest.java @@ -16,13 +16,16 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; +import java.util.Map; 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.DataChangeListener; 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; @@ -57,6 +60,7 @@ public class EventSourceTopologyTest { CreateTopicInput createTopicInputMock; ListenerRegistration listenerRegistrationMock; NodeKey nodeKey; + RpcRegistration aggregatorRpcReg; @BeforeClass public static void initTestClass() throws IllegalAccessException, InstantiationException { @@ -76,7 +80,7 @@ public class EventSourceTopologyTest { } private void constructorTestHelper(){ - RpcRegistration aggregatorRpcReg = mock(RpcRegistration.class); + aggregatorRpcReg = mock(RpcRegistration.class); EventSourceService eventSourceService = mock(EventSourceService.class); doReturn(aggregatorRpcReg).when(rpcProviderRegistryMock).addRpcImplementation(eq(EventAggregatorService.class), any(EventSourceTopology.class)); doReturn(eventSourceService).when(rpcProviderRegistryMock).getRpcService(EventSourceService.class); @@ -87,11 +91,11 @@ public class EventSourceTopologyTest { doReturn(checkedFutureMock).when(writeTransactionMock).submit(); } -//TODO: create test for createTopic -// public void createTopicTest() throws Exception{ -// createTopicTestHelper(); -// assertNotNull("Topic has not been created correctly.", eventSourceTopology.createTopic(createTopicInputMock)); -// } + @Test + public void createTopicTest() throws Exception{ + topicTestHelper(); + assertNotNull("Topic has not been created correctly.", eventSourceTopology.createTopic(createTopicInputMock)); + } private void topicTestHelper() throws Exception{ constructorTestHelper(); @@ -138,6 +142,19 @@ public class EventSourceTopologyTest { assertNotNull("Instance has not been created correctly.", eventSourceTopology.destroyTopic(destroyTopicInput)); } + @Test + public void closeTest() throws Exception{ + constructorTestHelper(); + topicTestHelper(); + Map> localMap = getTopicListenerRegistrations(); + DataChangeListener dataChangeListenerMock = mock(DataChangeListener.class); + ListenerRegistration listenerListenerRegistrationMock = (ListenerRegistration) mock(ListenerRegistration.class); + localMap.put(dataChangeListenerMock, listenerListenerRegistrationMock); + eventSourceTopology.close(); + verify(aggregatorRpcReg, times(1)).close(); + verify(listenerListenerRegistrationMock, times(1)).close(); + } + @Test public void registerTest() throws Exception { topicTestHelper(); @@ -154,4 +171,46 @@ public class EventSourceTopologyTest { verify(routedRpcRegistrationMock, times(1)).registerPath(eq(NodeContext.class), any(KeyedInstanceIdentifier.class)); } -} + @Test + public void unregisterTest() throws Exception { + topicTestHelper(); + EventSource eventSourceMock = mock(EventSource.class); + NodeId nodeId = new NodeId("nodeIdValue1"); + nodeKey = new NodeKey(nodeId); + Map> localMap = getRoutedRpcRegistrations(); + NodeKey nodeKeyMock = mock(NodeKey.class); + doReturn(nodeKeyMock).when(eventSourceMock).getSourceNodeKey(); + BindingAwareBroker.RoutedRpcRegistration routedRpcRegistrationMock = (BindingAwareBroker.RoutedRpcRegistration) mock(BindingAwareBroker.RoutedRpcRegistration.class); + localMap.put(nodeKeyMock, routedRpcRegistrationMock); + eventSourceTopology.unRegister(eventSourceMock); + verify(routedRpcRegistrationMock, times(1)).close(); + } + + @Test + public void registerEventSourceTest() throws Exception { + topicTestHelper(); + Node nodeMock = mock(Node.class); + EventSource eventSourceMock = mock(EventSource.class); + NodeId nodeId = new NodeId("nodeIdValue1"); + nodeKey = new NodeKey(nodeId); + doReturn(nodeKey).when(nodeMock).getKey(); + 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)); + assertNotNull("Return value has not been created correctly.", eventSourceTopology.registerEventSource(eventSourceMock)); + } + + private Map getTopicListenerRegistrations() throws Exception{ + Field nesField = EventSourceTopology.class.getDeclaredField("topicListenerRegistrations"); + nesField.setAccessible(true); + return (Map) nesField.get(eventSourceTopology); + } + + private Map getRoutedRpcRegistrations() throws Exception{ + Field nesField = EventSourceTopology.class.getDeclaredField("routedRpcRegistrations"); + nesField.setAccessible(true); + return (Map) nesField.get(eventSourceTopology); + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceManagerTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceManagerTest.java index 61fa30f40e..1d6b825c9f 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceManagerTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceManagerTest.java @@ -84,11 +84,11 @@ public class NetconfEventSourceManagerTest { netconfEventSourceManager = NetconfEventSourceManager.create(dataBrokerMock, - domNotificationPublishServiceMock, - domMountPointServiceMock, - mountPointServiceMock, - eventSourceRegistry, - namespaceToStreamList); + domNotificationPublishServiceMock, + domMountPointServiceMock, + mountPointServiceMock, + eventSourceRegistry, + namespaceToStreamList); } @Test @@ -125,12 +125,14 @@ public class NetconfEventSourceManagerTest { Map mapUpdate = new HashMap<>(); InstanceIdentifier instanceIdentifierMock = mock(InstanceIdentifier.class); Node dataObjectMock = mock(Node.class); + if(create){ mapCreate.put(instanceIdentifierMock, dataObjectMock); } if(update){ mapUpdate.put(instanceIdentifierMock, dataObjectMock); } + doReturn(mapCreate).when(asyncDataChangeEventMock).getCreatedData(); doReturn(mapUpdate).when(asyncDataChangeEventMock).getUpdatedData(); NetconfNode netconfNodeMock = mock(NetconfNode.class); @@ -171,4 +173,4 @@ public class NetconfEventSourceManagerTest { doReturn(esrMock).when(eventSourceRegistry).registerEventSource(any(EventSource.class)); } -} +} \ No newline at end of file diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceTest.java index 58da9e3eb1..ed9025780a 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/NetconfEventSourceTest.java @@ -7,22 +7,8 @@ */ package org.opendaylight.controller.messagebus.app.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; -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 java.lang.reflect.Field; -import java.net.URI; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - +import com.google.common.base.Optional; +import com.google.common.util.concurrent.CheckedFuture; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.md.sal.binding.api.BindingService; @@ -53,21 +39,32 @@ import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; +import java.lang.reflect.Field; +import java.net.URI; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; public class NetconfEventSourceTest { NetconfEventSource netconfEventSource; DOMMountPoint domMountPointMock; JoinTopicInput joinTopicInputMock; - AsyncDataChangeEvent asyncDataChangeEventMock; - Node dataObjectMock; @Before public void setUp() throws Exception { Map streamMap = new HashMap<>(); - streamMap.put("string1", "string2"); + streamMap.put("uriStr1", "string2"); domMountPointMock = mock(DOMMountPoint.class); DOMNotificationPublishService domNotificationPublishServiceMock = mock(DOMNotificationPublishService.class); MountPoint mountPointMock = mock(MountPoint.class); @@ -80,9 +77,9 @@ public class NetconfEventSourceTest { doReturn(rpcConsumerRegistryMock).when(onlyOptionalMock).get(); doReturn(notificationsServiceMock).when(rpcConsumerRegistryMock).getRpcService(NotificationsService.class); org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node node - = mock(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class); + = mock(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class); org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId nodeId - = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId("NodeId1"); + = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId("NodeId1"); doReturn(nodeId).when(node).getNodeId(); netconfEventSource = new NetconfEventSource(node, streamMap, domMountPointMock, domNotificationPublishServiceMock, mountPointMock); } @@ -143,7 +140,7 @@ public class NetconfEventSourceTest { doReturn(topicId).when(joinTopicInputMock).getTopicId(); NotificationPattern notificationPatternMock = mock(NotificationPattern.class); doReturn(notificationPatternMock).when(joinTopicInputMock).getNotificationPattern(); - doReturn("regexString1").when(notificationPatternMock).getValue(); + doReturn("uriStr1").when(notificationPatternMock).getValue(); SchemaContext schemaContextMock = mock(SchemaContext.class); doReturn(schemaContextMock).when(domMountPointMock).getSchemaContext(); @@ -165,6 +162,13 @@ public class NetconfEventSourceTest { doReturn(domNotificationServiceMock).when(domNotificationServiceOptionalMock).get(); ListenerRegistration listenerRegistrationMock = mock(ListenerRegistration.class); doReturn(listenerRegistrationMock).when(domNotificationServiceMock).registerNotificationListener(any(NetconfEventSource.class), any(List.class)); + + Optional optionalMock = (Optional) mock(Optional.class); + doReturn(optionalMock).when(domMountPointMock).getService(DOMRpcService.class); + DOMRpcService domRpcServiceMock = mock(DOMRpcService.class); + doReturn(domRpcServiceMock).when(optionalMock).get(); + CheckedFuture checkedFutureMock = mock(CheckedFuture.class); + doReturn(checkedFutureMock).when(domRpcServiceMock).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); } //TODO: create Test for NetConfEventSource#onNotification @@ -175,4 +179,4 @@ public class NetconfEventSourceTest { return (Set) nesField.get(netconfEventSource); } -} +} \ No newline at end of file diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/TopicDOMNotificationTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/TopicDOMNotificationTest.java index 6dacb9738a..b3f6438cc4 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/TopicDOMNotificationTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/TopicDOMNotificationTest.java @@ -57,4 +57,4 @@ public class TopicDOMNotificationTest { String bodyString = "TopicDOMNotification [body=" + containerNodeBodyMockToString + "]"; assertEquals("String has not been created correctly.", bodyString, topicDOMNotification.toString()); } -} +} \ No newline at end of file -- 2.36.6