82230c9862722fef02bcc90ca597dccd5cc6e40d
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / device / DeviceStateImplTest.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowplugin.impl.device;
10
11 import java.util.Arrays;
12 import java.util.List;
13 import org.junit.Assert;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.junit.runner.RunWith;
17 import org.mockito.Mock;
18 import org.mockito.Mockito;
19 import org.mockito.runners.MockitoJUnitRunner;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder;
26
27 /**
28  * openflowplugin-impl
29  * org.opendaylight.openflowplugin.impl.device
30  *
31  * test of {@link DeviceStateImpl} - lightweight version, using basic ways (TDD)
32  */
33 @RunWith(MockitoJUnitRunner.class)
34 public class DeviceStateImplTest {
35
36     @Mock
37     private FeaturesReply featuresReply;
38     private DeviceStateImpl deviceState;
39
40     private final short version = 13;
41     private final long portNr = 10L;
42     private final Long portBandwidth = 1024L;
43     private final List<PhyPort> pPort = Arrays.asList(new PhyPortBuilder()
44                     .setPortNo(portNr).setMaxSpeed(portBandwidth).build());
45
46     @Before
47     public void initialization() {
48         Mockito.when(featuresReply.getVersion()).thenReturn(version);
49         Mockito.when(featuresReply.getPhyPort()).thenReturn(pPort);
50         deviceState = new DeviceStateImpl();
51     }
52
53     @Test
54     public void testIsValid_initialValue(){
55         Assert.assertFalse(deviceState.isValid());
56     }
57
58     @Test
59     public void testDeviceSynchronized_initialValue(){
60         Assert.assertFalse(deviceState.deviceSynchronized());
61     }
62
63     @Test
64     public void testStatPollEnabled_initialValue(){
65         Assert.assertFalse(deviceState.isStatisticsPollingEnabled());
66     }
67
68     @Test
69     public void testStatistics_initialValue(){
70         Assert.assertFalse(deviceState.isFlowStatisticsAvailable());
71         Assert.assertFalse(deviceState.isPortStatisticsAvailable());
72         Assert.assertFalse(deviceState.isQueueStatisticsAvailable());
73         Assert.assertFalse(deviceState.isTableStatisticsAvailable());
74     }
75
76     @Test
77     public void testMeterAndGroupAvailable_initialValue(){
78         Assert.assertFalse(deviceState.isGroupAvailable());
79         Assert.assertFalse(deviceState.isMetersAvailable());
80     }
81
82 }