X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fservices%2FServiceMocking.java;h=92180d798ab28ea05c0d2e527b9bcd72f292d368;hb=0ac8877c3539d82e55ffe49dc0a2c8bcb0c82b19;hp=d6edde72994d8f0a5e04ff2bc29c229e9926b131;hpb=329e9c0de4ceb8186602f728eddfb3be610265d0;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java index d6edde7299..92180d798a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java @@ -1,22 +1,28 @@ +/* + * 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.openflowplugin.impl.services; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import io.netty.util.HashedWheelTimer; import java.math.BigInteger; -import java.util.List; import org.junit.Before; import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; +import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.DeviceState; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; @@ -32,7 +38,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -49,7 +54,6 @@ public abstract class ServiceMocking { private static final KeyedInstanceIdentifier NODE_II = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(DUMMY_NODE_ID))); - @Mock protected RequestContextStack mockedRequestContextStack; @Mock @@ -67,6 +71,8 @@ public abstract class ServiceMocking { @Mock protected DeviceState mockedDeviceState; @Mock + protected DeviceInfo mockedDeviceInfo; + @Mock protected DeviceInitializationPhaseHandler mockedDevicePhaseHandler; @Mock protected RequestContext mockedRequestContext; @@ -74,11 +80,14 @@ public abstract class ServiceMocking { protected OutboundQueue mockedOutboundQueue; @Mock protected MultiMsgCollector multiMessageCollector; + @Mock + protected DataBroker dataBroker; @Before public void initialization() { when(mockedRequestContextStack.createRequestContext()).thenReturn(mockedRequestContext); when(mockedRequestContext.getXid()).thenReturn(DUMMY_XID); + when(mockedRequestContext.getFuture()).thenReturn(Futures.immediateFuture(null)); when(mockedFeatures.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID); when(mockedFeatures.getVersion()).thenReturn(DUMMY_VERSION); @@ -91,14 +100,16 @@ public abstract class ServiceMocking { when(mockedPrimConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING); when(mockedPrimConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue); - when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_II); - when(mockedDeviceState.getFeatures()).thenReturn(mockedFeaturesOutput); + when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_II); + when(mockedDeviceInfo.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID); + when(mockedDeviceInfo.getVersion()).thenReturn(DUMMY_VERSION); when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext); when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy); - when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl()); + when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl(DUMMY_VERSION, dataBroker, NODE_II)); when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState); - when(mockedDeviceContext.getMultiMsgCollector(Matchers.>>any())).thenReturn(multiMessageCollector); + when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo); + when(mockedDeviceContext.getMultiMsgCollector(Matchers.any())).thenReturn(multiMessageCollector); setup(); }