2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.impl.device;
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;
29 * org.opendaylight.openflowplugin.impl.device
31 * test of {@link DeviceStateImpl} - lightweight version, using basic ways (TDD)
33 @RunWith(MockitoJUnitRunner.class)
34 public class DeviceStateImplTest {
37 private FeaturesReply featuresReply;
38 private DeviceStateImpl deviceState;
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());
47 public void initialization() {
48 Mockito.when(featuresReply.getVersion()).thenReturn(version);
49 Mockito.when(featuresReply.getPhyPort()).thenReturn(pPort);
50 deviceState = new DeviceStateImpl();
54 public void testIsValid_initialValue(){
55 Assert.assertFalse(deviceState.isValid());
59 public void testDeviceSynchronized_initialValue(){
60 Assert.assertFalse(deviceState.deviceSynchronized());
64 public void testStatPollEnabled_initialValue(){
65 Assert.assertFalse(deviceState.isStatisticsPollingEnabled());
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());
77 public void testMeterAndGroupAvailable_initialValue(){
78 Assert.assertFalse(deviceState.isGroupAvailable());
79 Assert.assertFalse(deviceState.isMetersAvailable());