OPNFLWPLUG-1032: Neon-MRI: Bump odlparent, yangtools, mdsal
[openflowplugin.git] / applications / forwardingrules-sync / src / test / java / org / opendaylight / openflowplugin / applications / frsync / impl / SyncReactorFutureZipDecoratorTest.java
index e8b9157de928c24ff290fb9bb35ff31cb90ecf30..875aaf9284432959b37c750a3205bead3af9ddcc 100644 (file)
@@ -23,13 +23,11 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
 import org.mockito.InOrder;
-import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.mockito.stubbing.Answer;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
 import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
@@ -65,8 +63,8 @@ public class SyncReactorFutureZipDecoratorTest {
     public void setUp() {
         final ExecutorService executorService = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder()
                 .setDaemon(false)
-                .setNameFormat("frsync-test%d")
-                .setUncaughtExceptionHandler((thread, e) -> LOG.error("Uncaught exception {}", thread, e))
+                .setNameFormat("frsync-test-%d")
+                .setUncaughtExceptionHandler((thread, ex) -> LOG.error("Uncaught exception {}", thread, ex))
                 .build());
         syncThreadPool = MoreExecutors.listeningDecorator(executorService);
         reactor = new SyncReactorFutureZipDecorator(delegate, syncThreadPool);
@@ -89,16 +87,13 @@ public class SyncReactorFutureZipDecoratorTest {
         final SyncupEntry zipped = new SyncupEntry(dataAfter2, configDS, dataBefore, configDS);
         final List<ListenableFuture<Boolean>> allResults = new ArrayList<>();
 
-        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
-                .thenAnswer(new Answer<ListenableFuture<Boolean>>() {
-                    @Override
-                    public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
-                        LOG.info("unlocking next configs");
-                        latchForNext.countDown();
-                        latchForFirst.await();
-                        LOG.info("unlocking first delegate");
-                        return Futures.immediateFuture(Boolean.TRUE);
-                    }
+        Mockito.when(delegate.syncup(ArgumentMatchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
+                .thenAnswer(invocationOnMock -> {
+                    LOG.info("unlocking next configs");
+                    latchForNext.countDown();
+                    latchForFirst.await();
+                    LOG.info("unlocking first delegate");
+                    return Futures.immediateFuture(Boolean.TRUE);
                 });
 
         allResults.add(reactor.syncup(fcNodePath, first));
@@ -136,15 +131,12 @@ public class SyncReactorFutureZipDecoratorTest {
         final SyncupEntry first = new SyncupEntry(dataBefore, configDS, null, configDS);
         final SyncupEntry second = new SyncupEntry(dataAfter, configDS, dataBefore, configDS);
 
-        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
-                .thenAnswer(new Answer<ListenableFuture<Boolean>>() {
-            @Override
-            public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
-                LOG.info("unlocking next config");
-                latchForNext.countDown();
-                return Futures.immediateFuture(Boolean.TRUE);
-            }
-            });
+        Mockito.when(delegate.syncup(ArgumentMatchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
+                .thenAnswer(invocationOnMock -> {
+                    LOG.info("unlocking next config");
+                    latchForNext.countDown();
+                    return Futures.immediateFuture(Boolean.TRUE);
+                });
 
         reactor.syncup(fcNodePath, first);
         latchForNext.await();
@@ -174,17 +166,14 @@ public class SyncReactorFutureZipDecoratorTest {
         final SyncupEntry first = new SyncupEntry(configAfter, configDS, configBefore, configDS);
         final SyncupEntry second = new SyncupEntry(configActual, configDS, freshOperational, operationalDS);
 
-        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
-                .thenAnswer(new Answer<ListenableFuture<Boolean>>() {
-            @Override
-            public ListenableFuture<Boolean> answer(final InvocationOnMock invocationOnMock) throws Throwable {
-                LOG.info("unlocking for fresh operational");
-                latchForNext.countDown();
-                latchForFirst.await();
-                LOG.info("unlocking first delegate");
-                return Futures.immediateFuture(Boolean.TRUE);
-            }
-        });
+        Mockito.when(delegate.syncup(ArgumentMatchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first)))
+                .thenAnswer(invocationOnMock -> {
+                    LOG.info("unlocking for fresh operational");
+                    latchForNext.countDown();
+                    latchForFirst.await();
+                    LOG.info("unlocking first delegate");
+                    return Futures.immediateFuture(Boolean.TRUE);
+                });
 
         reactor.syncup(fcNodePath, first);
         latchForNext.await();
@@ -202,8 +191,8 @@ public class SyncReactorFutureZipDecoratorTest {
         Mockito.verify(delegate, Mockito.times(1)).syncup(fcNodePath, second);
     }
 
-    private void mockSyncupWithEntry(final SyncupEntry entry) throws InterruptedException {
-        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(entry)))
+    private void mockSyncupWithEntry(final SyncupEntry entry) {
+        Mockito.when(delegate.syncup(ArgumentMatchers.any(), Mockito.eq(entry)))
                 .thenReturn(Futures.immediateFuture(Boolean.TRUE));
     }
 
@@ -211,4 +200,4 @@ public class SyncReactorFutureZipDecoratorTest {
     public void tearDown() {
         syncThreadPool.shutdownNow();
     }
-}
\ No newline at end of file
+}