23c01582b326ba8c98d63d337a34b9aefe597903
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / statistics / StatisticsContextImpMockInitiation.java
1 /*
2  *
3  *  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
4  *  *
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
8  *
9  *
10  */
11
12 package org.opendaylight.openflowplugin.impl.statistics;
13
14 import static org.mockito.Mockito.mock;
15 import static org.mockito.Mockito.when;
16
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.inventory.rev130819.Nodes;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
31 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
32
33
34 public class StatisticsContextImpMockInitiation {
35     protected boolean isTable = false;
36     protected boolean isFlow = false;
37     protected boolean isGroup = false;
38     protected boolean isMeter = false;
39     protected boolean isPort = false;
40     protected boolean isQueue = false;
41
42     protected DeviceContext mockedDeviceContext;
43     protected StatisticsGatheringService mockedStatisticsGatheringService;
44     protected StatisticsGatheringOnTheFlyService mockedStatisticsOnFlyGatheringService;
45     protected ConnectionContext mockedConnectionContext;
46     protected FeaturesReply mockedFeatures;
47     protected DeviceState mockedDeviceState;
48     protected MessageSpy mockedMessageSpy;
49     protected OutboundQueue mockedOutboundQueue;
50
51     protected static final KeyedInstanceIdentifier<Node, NodeKey> dummyNodeII = InstanceIdentifier.create(Nodes.class)
52             .child(Node.class, new NodeKey(new NodeId("dummyNodeId")));
53
54     @Before
55     public void initialize() {
56         mockedDeviceContext = mock(DeviceContext.class);
57         mockedStatisticsGatheringService = mock(StatisticsGatheringService.class);
58         mockedStatisticsOnFlyGatheringService = mock(StatisticsGatheringOnTheFlyService.class);
59         mockedConnectionContext = mock(ConnectionContext.class);
60         mockedFeatures = mock(FeaturesReply.class);
61         mockedDeviceState = mock(DeviceState.class);
62         mockedMessageSpy = mock(MessageSpy.class);
63         mockedOutboundQueue = mock(OutboundQueue.class);
64
65         when(mockedDeviceState.isTableStatisticsAvailable()).thenReturn(isTable);
66         when(mockedDeviceState.isFlowStatisticsAvailable()).thenReturn(isFlow);
67         when(mockedDeviceState.isGroupAvailable()).thenReturn(isGroup);
68         when(mockedDeviceState.isMetersAvailable()).thenReturn(isMeter);
69         when(mockedDeviceState.isPortStatisticsAvailable()).thenReturn(isPort);
70         when(mockedDeviceState.isQueueStatisticsAvailable()).thenReturn(isQueue);
71         when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(dummyNodeII);
72         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
73         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
74         when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessageSpy);
75
76         when(mockedConnectionContext.getNodeId()).thenReturn(dummyNodeII.getKey().getId());
77         when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures);
78         when(mockedConnectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
79         when(mockedConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue);
80
81     }
82 }