X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2FStatisticsContextImpMockInitiation.java;h=3fdd2e054cd3c559c116fa7e7195beff551ca3cc;hb=b4f4b4b702e2ccd8a7c62fd2a5c184c5b1cbe665;hp=7c50f076e4b105381913c866473dff89468cf6df;hpb=7464aa6aa13a8ef90a722829bec9f250432cfa33;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java index 7c50f076e4..3fdd2e054c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java @@ -1,12 +1,9 @@ /* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * - * * 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 - * - * + * 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.statistics; @@ -14,14 +11,16 @@ package org.opendaylight.openflowplugin.impl.statistics; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.math.BigInteger; import org.junit.Before; -import org.mockito.Mockito; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; +import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager; import org.opendaylight.openflowplugin.api.openflow.device.DeviceState; -import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor; +import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMastershipWatcher; +import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy; import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringOnTheFlyService; import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringService; @@ -30,6 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; 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.MultipartReply; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; @@ -43,16 +43,17 @@ class StatisticsContextImpMockInitiation { Boolean isQueue = false; protected DeviceContext mockedDeviceContext; - StatisticsGatheringService mockedStatisticsGatheringService; - StatisticsGatheringOnTheFlyService mockedStatisticsOnFlyGatheringService; - ConnectionContext mockedConnectionContext; protected DeviceState mockedDeviceState; - static final KeyedInstanceIdentifier dummyNodeII = InstanceIdentifier.create(Nodes.class) + + StatisticsGatheringService mockedStatisticsGatheringService; + StatisticsGatheringOnTheFlyService mockedStatisticsOnFlyGatheringService; + ConnectionContext mockedConnectionContext; + DeviceInfo mockedDeviceInfo; + StatisticsManager mockedStatisticsManager; + ContextChainMastershipWatcher mockedMastershipWatcher; + + static final KeyedInstanceIdentifier DUMMY_NODE_ID = InstanceIdentifier.create(Nodes.class) .child(Node.class, new NodeKey(new NodeId("dummyNodeId"))); - protected MessageSpy mockedMessageSpy; - protected OutboundQueue mockedOutboundQueue; - protected DeviceManager mockedDeviceManager; - LifecycleConductor mockConductor; @Before public void initialize() { @@ -60,32 +61,38 @@ class StatisticsContextImpMockInitiation { mockedStatisticsGatheringService = mock(StatisticsGatheringService.class); mockedStatisticsOnFlyGatheringService = mock(StatisticsGatheringOnTheFlyService.class); mockedConnectionContext = mock(ConnectionContext.class); - final FeaturesReply mockedFeatures = mock(FeaturesReply.class); mockedDeviceState = mock(DeviceState.class); + mockedDeviceInfo = mock(DeviceInfo.class); + mockedStatisticsManager = mock(StatisticsManager.class); + mockedMastershipWatcher = mock(ContextChainMastershipWatcher.class); + + final FeaturesReply mockedFeatures = mock(FeaturesReply.class); final MessageSpy mockedMessageSpy = mock(MessageSpy.class); final OutboundQueue mockedOutboundQueue = mock(OutboundQueue.class); final DeviceManager mockedDeviceManager = mock(DeviceManager.class); - mockConductor = mock(LifecycleConductor.class); when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState); + when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo); when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext); when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy); + when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(isTable); when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(isFlow); when(mockedDeviceState.isGroupAvailable()).thenReturn(isGroup); when(mockedDeviceState.isMetersAvailable()).thenReturn(isMeter); when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(isPort); when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(isQueue); - when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(dummyNodeII); + when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_NODE_ID); + when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN); + + when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState); + when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo); + when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext); + when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy); + when(mockedDeviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID.getKey().getId()); - when(mockedConnectionContext.getNodeId()).thenReturn(dummyNodeII.getKey().getId()); when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures); when(mockedConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING); - when(mockedConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue); - - when(mockedDeviceManager.getDeviceContextFromNodeId(Mockito.any())).thenReturn(mockedDeviceContext); - mockConductor.setSafelyDeviceManager(mockedDeviceManager); - when(mockConductor.getDeviceContext(Mockito.any())).thenReturn(mockedDeviceContext); } }