Bump mdsal to 5.0.2
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / connection / listener / HandshakeListenerImplTest.java
index 9dede809beaba2e9476dd160d30806abf411b1d5..2982270b0f811b9a44fc41cc2eb5bec60950c053 100644 (file)
@@ -8,7 +8,8 @@
 
 package org.opendaylight.openflowplugin.impl.connection.listener;
 
-import java.math.BigInteger;
+import static org.mockito.ArgumentMatchers.any;
+
 import java.net.InetSocketAddress;
 import org.junit.After;
 import org.junit.Assert;
@@ -16,8 +17,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Captor;
-import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
@@ -28,11 +29,11 @@ import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
 import org.opendaylight.openflowplugin.impl.connection.ConnectionContextImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint64;
 
 /**
  * Test for {@link HandshakeListenerImpl}.
@@ -55,26 +56,26 @@ public class HandshakeListenerImplTest {
     private HandshakeListenerImpl handshakeListener;
 
     @Before
-    public void setUp() throws Exception {
-        Mockito.when(connectionAdapter.barrier(Matchers.<BarrierInput>any()))
+    public void setUp() {
+        Mockito.when(connectionAdapter.barrier(ArgumentMatchers.any()))
                 .thenReturn(RpcResultBuilder.success(new BarrierOutputBuilder().build()).buildFuture());
         connectionContextSpy = Mockito.spy(new ConnectionContextImpl(connectionAdapter));
         Mockito.when(connectionContextSpy.getConnectionAdapter()).thenReturn(connectionAdapter);
-        Mockito.when(features.getDatapathId()).thenReturn(BigInteger.TEN);
+        Mockito.when(features.getDatapathId()).thenReturn(Uint64.valueOf(10));
         handshakeListener = new HandshakeListenerImpl(connectionContextSpy, deviceConnectedHandler);
         handshakeListener.setHandshakeContext(handshakeContext);
     }
 
     @After
-    public void tearDown() throws Exception {
+    public void tearDown() {
         Mockito.verify(handshakeContext).close();
     }
 
     @Test
-    public void testOnHandshakeSuccessfull() throws Exception {
+    public void testOnHandshakeSuccessfull() {
         handshakeListener.onHandshakeSuccessful(features, OFConstants.OFP_VERSION_1_3);
         Mockito.verify(connectionContextSpy).changeStateToWorking();
-        Mockito.verify(connectionContextSpy).setFeatures(Matchers.any(FeaturesReply.class));
+        Mockito.verify(connectionContextSpy).setFeatures(any(FeaturesReply.class));
         Mockito.verify(connectionContextSpy).setNodeId(nodeIdCaptor.capture());
         Mockito.verify(connectionContextSpy).handshakeSuccessful();
         Mockito.verify(deviceConnectedHandler).deviceConnected(connectionContextSpy);
@@ -84,7 +85,7 @@ public class HandshakeListenerImplTest {
     }
 
     @Test
-    public void testOnHandshakeFailure1() throws Exception {
+    public void testOnHandshakeFailure1() {
         connectionContextSpy.setNodeId(new NodeId("ut-device:10"));
         handshakeListener.onHandshakeFailure();
         Mockito.verify(handshakeContext).close();
@@ -92,8 +93,9 @@ public class HandshakeListenerImplTest {
     }
 
     @Test
-    public void testOnHandshakeFailure2() throws Exception {
-        Mockito.when(connectionAdapter.getRemoteAddress()).thenReturn(InetSocketAddress.createUnresolved("ut-ofp.example.org", 4242));
+    public void testOnHandshakeFailure2() {
+        Mockito.when(connectionAdapter.getRemoteAddress())
+                .thenReturn(InetSocketAddress.createUnresolved("ut-ofp.example.org", 4242));
         connectionContextSpy.setNodeId(new NodeId("openflow:1"));
         handshakeListener.onHandshakeFailure();
         Mockito.verify(handshakeContext).close();