OPNFLWPLUG-1032: Neon-MRI: Bump odlparent, yangtools, mdsal
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / configuration / ConfigurationServiceFactoryImplTest.java
index 46cdece6b75f8990221c1f45cfa76436dae6a93d..a9685b24fdf5bee3cebc7fdb934d50f8eca6c3d3 100644 (file)
@@ -10,34 +10,29 @@ package org.opendaylight.openflowplugin.impl.configuration;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import com.google.common.collect.ImmutableMap;
-import java.util.Dictionary;
 import java.util.Hashtable;
+import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationListener;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint16Type;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
 
 @RunWith(MockitoJUnitRunner.class)
 public class ConfigurationServiceFactoryImplTest {
-    private static final int CONFIG_PROP_COUNT = 16;
+    private static final int CONFIG_PROP_COUNT = 23;
     private static final boolean IS_STATISTICS_POLLING_ON = true;
     private static final int BARRIER_COUNT_LIMIT = 2000;
     private static final long BARRIER_INTERVAL_TIMEOUT_LIMIT = 3000;
@@ -55,30 +50,26 @@ public class ConfigurationServiceFactoryImplTest {
     private static final int THREAD_POOL_MIN_THREADS_UPDATE = 4;
     private static final int THREAD_POOL_MAX_THREADS = 1000;
     private static final long THREAD_POOL_TIMEOUT = 60;
+    private static final int DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0;
 
     @Mock
     private OpenflowProviderConfig config;
 
-    @Mock
-    private BundleContext bundleContext;
-
     @Mock
     private ConfigurationListener configurationListener;
 
-    @Mock
-    private ConfigurationAdmin configurationAdmin;
-
-    @Mock
-    private ServiceReference<ConfigurationAdmin> serviceReference;
-
-    @Mock
-    private Configuration configuration;
-
     private ConfigurationService configurationService;
 
     @Before
     public void setUp() throws Exception {
         when(config.isIsStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON);
+        when(config.isIsFlowStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON);
+        when(config.isIsTableStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON);
+        when(config.isIsFlowStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON);
+        when(config.isIsGroupStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON);
+        when(config.isIsMeterStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON);
+        when(config.isIsQueueStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON);
+        when(config.isIsPortStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON);
         when(config.getBarrierCountLimit()).thenReturn(new NonZeroUint16Type(BARRIER_COUNT_LIMIT));
         when(config.getBarrierIntervalTimeoutLimit()).thenReturn(new NonZeroUint32Type(BARRIER_INTERVAL_TIMEOUT_LIMIT));
         when(config.getEchoReplyTimeout()).thenReturn(new NonZeroUint32Type(ECHO_REPLY_TIMEOUT));
@@ -94,17 +85,14 @@ public class ConfigurationServiceFactoryImplTest {
         when(config.getThreadPoolMinThreads()).thenReturn(THREAD_POOL_MIN_THREADS);
         when(config.getThreadPoolMaxThreads()).thenReturn(new NonZeroUint16Type(THREAD_POOL_MAX_THREADS));
         when(config.getThreadPoolTimeout()).thenReturn(THREAD_POOL_TIMEOUT);
+        when(config.getDeviceConnectionRateLimitPerMin()).thenReturn(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN);
 
-        final Dictionary<String, Object> properties = new Hashtable<>();
-        properties.put(ConfigurationProperty.IS_STATISTICS_POLLING_ON.toString(), IS_STATISTICS_POLLING_ON);
+        final Map<String, String> properties = new Hashtable<>();
+        properties.put(ConfigurationProperty.IS_STATISTICS_POLLING_ON.toString(),
+                Boolean.toString(IS_STATISTICS_POLLING_ON));
 
-        when(configuration.getProperties()).thenReturn(properties);
-        when(configurationAdmin.getConfiguration(OFConstants.CONFIG_FILE_ID)).thenReturn(configuration);
-        when(bundleContext.getService(serviceReference)).thenReturn(configurationAdmin);
-        when(bundleContext.getServiceReference(ConfigurationAdmin.class)).thenReturn(serviceReference);
-
-        configurationService = new ConfigurationServiceFactoryImpl()
-                .newInstance(config, bundleContext);
+        configurationService = new ConfigurationServiceFactoryImpl().newInstance(config);
+        configurationService.update(properties);
     }
 
     @Test
@@ -144,5 +132,4 @@ public class ConfigurationServiceFactoryImplTest {
         configurationService.close();
         configurationService.getProperty(ConfigurationProperty.THREAD_POOL_MAX_THREADS.toString(), Integer::valueOf);
     }
-
-}
\ No newline at end of file
+}