Clean up netconf-client tests
[netconf.git] / netconf / netconf-client / src / test / java / org / opendaylight / netconf / client / SimpleNetconfClientSessionListenerTest.java
index 133eef6bf022b507fdc6c0827e4293b7e6920b5e..65e1c8e109f280bbd3f37b67a453d51c6fedb218 100644 (file)
@@ -5,13 +5,11 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.client;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyObject;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
@@ -26,31 +24,27 @@ import io.netty.util.concurrent.GenericFutureListener;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.internal.util.collections.Sets;
-import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
 
 public class SimpleNetconfClientSessionListenerTest {
-
     private Channel channel;
     private ChannelPromise channelFuture;
-    Set<String> caps;
     private NetconfHelloMessage helloMessage;
     private NetconfMessage message;
     private NetconfClientSessionListener sessionListener;
     private NetconfClientSession clientSession;
 
     @Before
-    public void setUp() throws NetconfDocumentedException {
+    public void setUp() {
         channel = mock(Channel.class);
         channelFuture = mock(ChannelPromise.class);
         mockEventLoop();
         doReturn(channelFuture).when(channel).newPromise();
-        doReturn(channelFuture).when(channel).writeAndFlush(anyObject());
-        doReturn(channelFuture).when(channel).writeAndFlush(anyObject(), any(ChannelPromise.class));
+        doReturn(channelFuture).when(channel).writeAndFlush(any());
+        doReturn(channelFuture).when(channel).writeAndFlush(any(), any(ChannelPromise.class));
         doReturn(channelFuture).when(channelFuture).addListener(any(GenericFutureListener.class));
-        caps = Sets.newSet("a", "b");
+        final var caps = Set.of("a", "b");
         helloMessage = NetconfHelloMessage.createServerHello(caps, 10);
         message = new NetconfMessage(helloMessage.getDocument());
         sessionListener = mock(NetconfClientSessionListener.class);
@@ -67,11 +61,11 @@ public class SimpleNetconfClientSessionListenerTest {
     }
 
     @Test
-    public void testSessionDown() throws Exception {
+    public void testSessionDown() {
         SimpleNetconfClientSessionListener simpleListener = new SimpleNetconfClientSessionListener();
         final Future<NetconfMessage> promise = simpleListener.sendRequest(message);
         simpleListener.onSessionUp(clientSession);
-        verify(channel, times(1)).writeAndFlush(anyObject(), anyObject());
+        verify(channel, times(1)).writeAndFlush(any(), any());
 
         simpleListener.onSessionDown(clientSession, new Exception());
         assertFalse(promise.isSuccess());
@@ -82,7 +76,7 @@ public class SimpleNetconfClientSessionListenerTest {
         SimpleNetconfClientSessionListener simpleListener = new SimpleNetconfClientSessionListener();
         final Future<NetconfMessage> promise = simpleListener.sendRequest(message);
         simpleListener.onSessionUp(clientSession);
-        verify(channel, times(1)).writeAndFlush(anyObject(), anyObject());
+        verify(channel, times(1)).writeAndFlush(any(), any());
 
         simpleListener.sendRequest(message);
         assertFalse(promise.isSuccess());
@@ -93,7 +87,7 @@ public class SimpleNetconfClientSessionListenerTest {
         SimpleNetconfClientSessionListener simpleListener = new SimpleNetconfClientSessionListener();
         final Future<NetconfMessage> promise = simpleListener.sendRequest(message);
         simpleListener.onSessionUp(clientSession);
-        verify(channel, times(1)).writeAndFlush(anyObject(), anyObject());
+        verify(channel, times(1)).writeAndFlush(any(), any());
 
         simpleListener.onMessage(clientSession, message);
         assertTrue(promise.isSuccess());