X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fdevice%2FDeviceManagerImplTest.java;h=2a0a6f3ce31a99477a9a5683c3e8b5e6fbebaedd;hb=refs%2Fchanges%2F36%2F76236%2F27;hp=3be489dede78b4e6edbdd413c32ac1381a3c12ae;hpb=a94db42744cb59aa79eca25f110f83508b6f3af1;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java index 3be489dede..2a0a6f3ce3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java @@ -10,8 +10,8 @@ package org.opendaylight.openflowplugin.impl.device; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -21,7 +21,6 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import io.netty.util.HashedWheelTimer; import java.lang.reflect.Field; -import java.math.BigInteger; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import org.junit.Assert; @@ -36,7 +35,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; @@ -60,14 +58,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow 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.OpenflowProviderConfigBuilder; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError; @RunWith(MockitoJUnitRunner.class) public class DeviceManagerImplTest { private static final long TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA = 2000L; - private static final int barrierCountLimit = 25600; - private static final long barrierIntervalNanos = 500; + private static final int BARRIER_COUNT_LIMIT = 25600; + private static final long BARRIER_INTERVAL_NANOS = 500; private static final NodeId DUMMY_NODE_ID = new NodeId("dummyNodeId"); private static final KeyedInstanceIdentifier DUMMY_IDENTIFIER = DeviceStateUtil .createNodeInstanceIdentifier(DUMMY_NODE_ID); @@ -107,28 +104,20 @@ public class DeviceManagerImplTest { @Before public void setUp() throws Exception { - when(mockConnectionContext.getNodeId()).thenReturn(DUMMY_NODE_ID); when(mockConnectionContext.getFeatures()).thenReturn(mockFeatures); when(mockConnectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter); when(mockConnectionContext.getDeviceInfo()).thenReturn(deviceInfo); - when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext); when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_IDENTIFIER); when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID); - when(mockFeatures.getCapabilities()).thenReturn(capabilities); - when(mockFeatures.getCapabilitiesV10()).thenReturn(capabilitiesV10); - when(mockFeatures.getDatapathId()).thenReturn(BigInteger.valueOf(21L)); - when(mockedFuture.isDone()).thenReturn(true); when(writeTransaction.submit()).thenReturn(mockedFuture); - when(transactionChain.newWriteOnlyTransaction()).thenReturn(writeTransaction); - when(dataBroker.createTransactionChain(any(TransactionChainListener.class))).thenReturn(transactionChain); when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); deviceManager = new DeviceManagerImpl( new OpenflowProviderConfigBuilder() - .setBarrierCountLimit(new NonZeroUint16Type(barrierCountLimit)) - .setBarrierIntervalTimeoutLimit(new NonZeroUint32Type(barrierIntervalNanos)) + .setBarrierCountLimit(new NonZeroUint16Type(BARRIER_COUNT_LIMIT)) + .setBarrierIntervalTimeoutLimit(new NonZeroUint32Type(BARRIER_INTERVAL_NANOS)) .setGlobalNotificationQuota(TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA) .setSwitchFeaturesMandatory(false) .setEnableFlowRemovedNotification(true) @@ -169,7 +158,7 @@ public class DeviceManagerImplTest { public void removeDeviceFromOperationalDSException() throws Exception { final CheckedFuture failedFuture = Futures.immediateFailedCheckedFuture( - new TransactionCommitFailedException("Test failed transaction", null, null)); + new TransactionCommitFailedException("Test failed transaction")); Mockito.when(writeTransaction.submit()).thenReturn(failedFuture); final ListenableFuture future = deviceManager .removeDeviceFromOperationalDS(DUMMY_IDENTIFIER); @@ -209,7 +198,8 @@ public class DeviceManagerImplTest { } @SuppressWarnings("unchecked") - private static ConcurrentHashMap getContextsCollection(final DeviceManagerImpl deviceManager) throws NoSuchFieldException, IllegalAccessException { + private static ConcurrentHashMap getContextsCollection( + final DeviceManagerImpl deviceManager) throws NoSuchFieldException, IllegalAccessException { // HACK: contexts collection for testing shall be accessed in some more civilized way final Field contextsField = DeviceManagerImpl.class.getDeclaredField("deviceContexts"); Assert.assertNotNull(contextsField);