3 * * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
5 * * This program and the accompanying materials are made available under the
6 * * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * * and is available at http://www.eclipse.org/legal/epl-v10.html
12 package org.opendaylight.openflowplugin.impl.statistics;
14 import static org.mockito.Mockito.mock;
15 import static org.mockito.Mockito.when;
17 import org.junit.Before;
18 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
19 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
20 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
21 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
22 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
23 import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringOnTheFlyService;
24 import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringService;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
29 public class StatisticsContextImpMockInitiation {
30 protected boolean isTable = false;
31 protected boolean isFlow = false;
32 protected boolean isGroup = false;
33 protected boolean isMeter = false;
34 protected boolean isPort = false;
35 protected boolean isQueue = false;
37 protected DeviceContext mockedDeviceContext;
38 protected StatisticsGatheringService mockedStatisticsGatheringService;
39 protected StatisticsGatheringOnTheFlyService mockedStatisticsOnFlyGatheringService;
40 protected ConnectionContext mockedConnectionContext;
41 protected FeaturesReply mockedFeatures;
42 protected DeviceState mockedDeviceState;
43 protected MessageSpy mockedMessageSpy;
44 protected OutboundQueue mockedOutboundQueue;
47 public void initialize() {
48 mockedDeviceContext = mock(DeviceContext.class);
49 mockedStatisticsGatheringService = mock(StatisticsGatheringService.class);
50 mockedStatisticsOnFlyGatheringService = mock(StatisticsGatheringOnTheFlyService.class);
51 mockedConnectionContext = mock(ConnectionContext.class);
52 mockedFeatures = mock(FeaturesReply.class);
53 mockedDeviceState = mock(DeviceState.class);
54 mockedMessageSpy = mock(MessageSpy.class);
55 mockedOutboundQueue = mock(OutboundQueue.class);
57 when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(isTable);
58 when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(isFlow);
59 when(mockedDeviceState.isGroupAvailable()).thenReturn(isGroup);
60 when(mockedDeviceState.isMetersAvailable()).thenReturn(isMeter);
61 when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(isPort);
62 when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(isQueue);
63 when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
64 when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
65 when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy);
67 when(mockedConnectionContext.getNodeId()).thenReturn(new NodeId("dummyNodeId"));
68 when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures);
69 when(mockedConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
70 when(mockedConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue);