Further warning removal
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / configuration / OpenFlowProviderConfigImplTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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 package org.opendaylight.openflowplugin.impl.configuration;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.ArgumentMatchers.eq;
13 import static org.mockito.Mockito.when;
14
15 import org.junit.After;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.mockito.Mock;
20 import org.mockito.junit.MockitoJUnitRunner;
21 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty;
22 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
24 import org.opendaylight.yangtools.yang.common.Uint16;
25 import org.opendaylight.yangtools.yang.common.Uint32;
26
27 @RunWith(MockitoJUnitRunner.class)
28 public class OpenFlowProviderConfigImplTest {
29     private static final Boolean IS_STATISTICS_POLLING_ON = true;
30     private static final Uint16 BARRIER_COUNT_LIMIT = Uint16.valueOf(2000);
31     private static final Uint32 BARRIER_INTERVAL_TIMEOUT_LIMIT = Uint32.valueOf(3000);
32     private static final Uint32 ECHO_REPLY_TIMEOUT = Uint32.valueOf(4000);
33     private static final Boolean ENABLE_FLOW_REMOVED_NOTIFICATION = true;
34     private static final Boolean SKIP_TABLE_FEATURES = true;
35     private static final Uint32 BASIC_TIMER_DELAY = Uint32.valueOf(2690);
36     private static final Uint32 MAXIMUM_TIMER_DELAY = Uint32.valueOf(3679);
37     private static final Boolean SWITCH_FEATURES_MANDATORY = false;
38     private static final Boolean IS_STATISTICS_RPC_ENABLED = false;
39     private static final Boolean USE_SINGLE_LAYER_SERIALIZATION = true;
40     private static final Uint16 RPC_REQUESTS_QUOTA = Uint16.valueOf(2500);
41     private static final Uint32 GLOBAL_NOTIFICATION_QUOTA = Uint32.valueOf(9000);
42     private static final Uint16 THREAD_POOL_MIN_THREADS = Uint16.valueOf(3);
43     private static final Uint16 THREAD_POOL_MAX_THREADS = Uint16.valueOf(1000);
44     private static final Uint32 THREAD_POOL_TIMEOUT = Uint32.valueOf(60);
45     private static final Uint16 DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = Uint16.ZERO;
46     private static final Uint16 DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS = Uint16.valueOf(60);
47     private static final Uint32 DEVICE_DATASTORE_REMOVAL_DELAY = Uint32.valueOf(500);
48
49     @Mock
50     private ConfigurationService configurationService;
51     private OpenflowProviderConfig openflowProviderConfig;
52
53     @Before
54     public void setUp() {
55         when(configurationService.getProperty(eq(ConfigurationProperty.IS_STATISTICS_POLLING_ON.toString()), any()))
56                 .thenReturn(IS_STATISTICS_POLLING_ON);
57         when(configurationService.getProperty(eq(ConfigurationProperty.BARRIER_COUNT_LIMIT.toString()), any()))
58                 .thenReturn(BARRIER_COUNT_LIMIT);
59         when(configurationService.getProperty(eq(ConfigurationProperty.BARRIER_INTERVAL_TIMEOUT_LIMIT.toString()),
60                 any())).thenReturn(BARRIER_INTERVAL_TIMEOUT_LIMIT);
61         when(configurationService.getProperty(eq(ConfigurationProperty.ECHO_REPLY_TIMEOUT.toString()), any()))
62                 .thenReturn(ECHO_REPLY_TIMEOUT);
63         when(configurationService.getProperty(eq(ConfigurationProperty.ENABLE_FLOW_REMOVED_NOTIFICATION.toString()),
64                 any())).thenReturn(ENABLE_FLOW_REMOVED_NOTIFICATION);
65         when(configurationService.getProperty(eq(ConfigurationProperty.SKIP_TABLE_FEATURES.toString()), any()))
66                 .thenReturn(SKIP_TABLE_FEATURES);
67         when(configurationService.getProperty(eq(ConfigurationProperty.BASIC_TIMER_DELAY.toString()), any()))
68                 .thenReturn(BASIC_TIMER_DELAY);
69         when(configurationService.getProperty(eq(ConfigurationProperty.MAXIMUM_TIMER_DELAY.toString()), any()))
70                 .thenReturn(MAXIMUM_TIMER_DELAY);
71         when(configurationService.getProperty(eq(ConfigurationProperty.SWITCH_FEATURES_MANDATORY.toString()), any()))
72                 .thenReturn(SWITCH_FEATURES_MANDATORY);
73         when(configurationService.getProperty(eq(ConfigurationProperty.IS_STATISTICS_RPC_ENABLED.toString()), any()))
74                 .thenReturn(IS_STATISTICS_RPC_ENABLED);
75         when(configurationService.getProperty(eq(ConfigurationProperty.USE_SINGLE_LAYER_SERIALIZATION.toString()),
76                 any())).thenReturn(USE_SINGLE_LAYER_SERIALIZATION);
77         when(configurationService.getProperty(eq(ConfigurationProperty.RPC_REQUESTS_QUOTA.toString()), any()))
78                 .thenReturn(RPC_REQUESTS_QUOTA);
79         when(configurationService.getProperty(eq(ConfigurationProperty.GLOBAL_NOTIFICATION_QUOTA.toString()), any()))
80                 .thenReturn(GLOBAL_NOTIFICATION_QUOTA);
81         when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MIN_THREADS.toString()), any()))
82                 .thenReturn(THREAD_POOL_MIN_THREADS);
83         when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MAX_THREADS.toString()), any()))
84                 .thenReturn(THREAD_POOL_MAX_THREADS);
85         when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_TIMEOUT.toString()), any()))
86                 .thenReturn(THREAD_POOL_TIMEOUT);
87         when(configurationService.getProperty(eq(ConfigurationProperty.DEVICE_CONNECTION_RATE_LIMIT_PER_MIN.toString()),
88                 any())).thenReturn(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN);
89         when(configurationService.getProperty(
90                 eq(ConfigurationProperty.DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS.toString()),
91                 any())).thenReturn(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS);
92         when(configurationService.getProperty(eq(ConfigurationProperty.DEVICE_DATASTORE_REMOVAL_DELAY.toString()),
93                 any())).thenReturn(DEVICE_DATASTORE_REMOVAL_DELAY);
94         openflowProviderConfig = new OpenFlowProviderConfigImpl(configurationService);
95     }
96
97     @After
98     public void tearDown() throws Exception {
99         configurationService.close();
100     }
101
102     @Test
103     public void getRpcRequestsQuota() {
104         assertEquals(RPC_REQUESTS_QUOTA, openflowProviderConfig.getRpcRequestsQuota().getValue());
105     }
106
107     @Test
108     public void isSwitchFeaturesMandatory() {
109         assertEquals(SWITCH_FEATURES_MANDATORY, openflowProviderConfig.getSwitchFeaturesMandatory());
110     }
111
112     @Test
113     public void getGlobalNotificationQuota() {
114         assertEquals(GLOBAL_NOTIFICATION_QUOTA, openflowProviderConfig.getGlobalNotificationQuota());
115     }
116
117     @Test
118     public void isIsStatisticsPollingOn() {
119         assertEquals(IS_STATISTICS_POLLING_ON, openflowProviderConfig.getIsStatisticsPollingOn());
120     }
121
122     @Test
123     public void isIsStatisticsRpcEnabled() {
124         assertEquals(IS_STATISTICS_RPC_ENABLED, openflowProviderConfig.getIsStatisticsRpcEnabled());
125     }
126
127     @Test
128     public void getBarrierIntervalTimeoutLimit() {
129         assertEquals(BARRIER_INTERVAL_TIMEOUT_LIMIT,
130             openflowProviderConfig.getBarrierIntervalTimeoutLimit().getValue());
131     }
132
133     @Test
134     public void getBarrierCountLimit() {
135         assertEquals(BARRIER_COUNT_LIMIT, openflowProviderConfig.getBarrierCountLimit().getValue());
136     }
137
138     @Test
139     public void getEchoReplyTimeout() {
140         assertEquals(ECHO_REPLY_TIMEOUT, openflowProviderConfig.getEchoReplyTimeout().getValue());
141     }
142
143     @Test
144     public void getThreadPoolMinThreads() {
145         assertEquals(THREAD_POOL_MIN_THREADS, openflowProviderConfig.getThreadPoolMinThreads());
146     }
147
148     @Test
149     public void getThreadPoolMaxThreads() {
150         assertEquals(THREAD_POOL_MAX_THREADS, openflowProviderConfig.getThreadPoolMaxThreads().getValue());
151     }
152
153     @Test
154     public void getThreadPoolTimeout() {
155         assertEquals(THREAD_POOL_TIMEOUT, openflowProviderConfig.getThreadPoolTimeout());
156     }
157
158     @Test
159     public void isEnableFlowRemovedNotification() {
160         assertEquals(ENABLE_FLOW_REMOVED_NOTIFICATION, openflowProviderConfig.getEnableFlowRemovedNotification());
161     }
162
163     @Test
164     public void isSkipTableFeatures() {
165         assertEquals(SKIP_TABLE_FEATURES, openflowProviderConfig.getSkipTableFeatures());
166     }
167
168     @Test
169     public void getBasicTimerDelay() {
170         assertEquals(BASIC_TIMER_DELAY, openflowProviderConfig.getBasicTimerDelay().getValue());
171     }
172
173     @Test
174     public void getMaximumTimerDelay() {
175         assertEquals(MAXIMUM_TIMER_DELAY, openflowProviderConfig.getMaximumTimerDelay().getValue());
176     }
177
178     @Test
179     public void isUseSingleLayerSerialization() {
180         assertEquals(USE_SINGLE_LAYER_SERIALIZATION, openflowProviderConfig.getUseSingleLayerSerialization());
181     }
182
183     @Test
184     public void getDeviceConnectionRateLimitPerMin() {
185         assertEquals(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN, openflowProviderConfig.getDeviceConnectionRateLimitPerMin());
186     }
187
188     @Test
189     public void getDeviceConnectionHoldTimeInSeconds() {
190         assertEquals(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS,
191                 openflowProviderConfig.getDeviceConnectionHoldTimeInSeconds());
192     }
193
194     @Test
195     public void getDeviceDatastoreRemovalDelay() {
196         assertEquals(DEVICE_DATASTORE_REMOVAL_DELAY,
197                 openflowProviderConfig.getDeviceDatastoreRemovalDelay().getValue());
198     }
199
200 }