X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Futil%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Futil%2Fconcurrent%2FCommonTestUtils.java;h=9ee60f7ad045744b5d566c742b2048b49f9d9e60;hb=6bb7f3a20168a59eeeea366d7d30fa29702e522f;hp=60c56a452c7337cebb9c057839b1a4c1bb8bdf4b;hpb=fb1eaa41ba6bbed796fb168658c8219badd23057;p=yangtools.git diff --git a/common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/CommonTestUtils.java b/common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/CommonTestUtils.java index 60c56a452c..9ee60f7ad0 100644 --- a/common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/CommonTestUtils.java +++ b/common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/CommonTestUtils.java @@ -8,11 +8,10 @@ package org.opendaylight.yangtools.util.concurrent; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.Uninterruptibles; +import java.util.concurrent.CountDownLatch; /** * Some common test utilities. @@ -20,55 +19,27 @@ import com.google.common.util.concurrent.Uninterruptibles; * @author Thomas Pantelis */ public class CommonTestUtils { - + @FunctionalInterface public interface Invoker { - ListenableFuture invokeExecutor( ListeningExecutorService executor, - CountDownLatch blockingLatch ); - }; + ListenableFuture invokeExecutor(ListeningExecutorService executor, CountDownLatch blockingLatch); + } - public static final Invoker SUBMIT_CALLABLE = new Invoker() { - @Override - public ListenableFuture invokeExecutor( ListeningExecutorService executor, - final CountDownLatch blockingLatch ) { - return executor.submit( new Callable() { - @Override - public Void call() throws Exception { - if( blockingLatch != null ) { - Uninterruptibles.awaitUninterruptibly( blockingLatch ); - } - return null; - } - } ); + public static final Invoker SUBMIT_CALLABLE = (executor, blockingLatch) -> executor.submit(() -> { + if (blockingLatch != null) { + Uninterruptibles.awaitUninterruptibly(blockingLatch); } - }; + return null; + }); - public static final Invoker SUBMIT_RUNNABLE = new Invoker() { - @Override - public ListenableFuture invokeExecutor( ListeningExecutorService executor, - final CountDownLatch blockingLatch ) { - return executor.submit( new Runnable() { - @Override - public void run() { - if( blockingLatch != null ) { - Uninterruptibles.awaitUninterruptibly( blockingLatch ); - } - } - } ); + public static final Invoker SUBMIT_RUNNABLE = (executor, blockingLatch) -> executor.submit(() -> { + if (blockingLatch != null) { + Uninterruptibles.awaitUninterruptibly(blockingLatch); } - }; + }); - public static final Invoker SUBMIT_RUNNABLE_WITH_RESULT = new Invoker() { - @Override - public ListenableFuture invokeExecutor( ListeningExecutorService executor, - final CountDownLatch blockingLatch ) { - return executor.submit( new Runnable() { - @Override - public void run() { - if( blockingLatch != null ) { - Uninterruptibles.awaitUninterruptibly( blockingLatch ); - } - } - }, "foo" ); + public static final Invoker SUBMIT_RUNNABLE_WITH_RESULT = (executor, blockingLatch) -> executor.submit(() -> { + if (blockingLatch != null) { + Uninterruptibles.awaitUninterruptibly(blockingLatch); } - }; + }, "foo"); }