X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=applications%2Fforwardingrules-sync%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fapplications%2Ffrsync%2Fimpl%2FSyncReactorFutureZipDecoratorTest.java;h=875aaf9284432959b37c750a3205bead3af9ddcc;hb=b4f4b4b702e2ccd8a7c62fd2a5c184c5b1cbe665;hp=e8b9157de928c24ff290fb9bb35ff31cb90ecf30;hpb=96fa8cfd597e38a2c5549334e8cf2910cf938672;p=openflowplugin.git diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java index e8b9157de9..875aaf9284 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java @@ -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> allResults = new ArrayList<>(); - Mockito.when(delegate.syncup(Matchers.>any(), Mockito.eq(first))) - .thenAnswer(new Answer>() { - @Override - public ListenableFuture 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.>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.>any(), Mockito.eq(first))) - .thenAnswer(new Answer>() { - @Override - public ListenableFuture answer(final InvocationOnMock invocationOnMock) throws Throwable { - LOG.info("unlocking next config"); - latchForNext.countDown(); - return Futures.immediateFuture(Boolean.TRUE); - } - }); + Mockito.when(delegate.syncup(ArgumentMatchers.>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.>any(), Mockito.eq(first))) - .thenAnswer(new Answer>() { - @Override - public ListenableFuture 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.>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.>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 +}