Java 类org.junit.function.ThrowingRunnable 实例源码

项目:error-prone    文件:FutureReturnValueIgnoredNegativeCases.java   
private static void throwing() {
  assertThrows(RuntimeException.class, () -> immediateFuture(null));
  assertThrows(
      RuntimeException.class,
      () -> {
        immediateFuture(null);
      });
  assertThrows(
      RuntimeException.class,
      new ThrowingRunnable() {
        @Override
        public void run() throws Throwable {
          immediateFuture(null);
        }
      });
}
项目:google-cloud-intellij    文件:CloudToolsRule.java   
/**
 * Wraps the given {@link ThrowingRunnable} in a {@link Runnable} that transforms all {@link
 * Throwable throwables} to a {@link RuntimeException}.
 */
private static Runnable wrap(ThrowingRunnable runnable) {
  return () -> {
    try {
      runnable.run();
    } catch (Throwable throwable) {
      throw new RuntimeException(throwable);
    }
  };
}
项目:google-cloud-intellij    文件:CloudToolsRule.java   
/** Runs the given {@link ThrowingRunnable} as a write action on the main thread. */
private static void writeOnMainThread(ThrowingRunnable runnable) {
  ApplicationManager.getApplication()
      .invokeAndWait(() -> ApplicationManager.getApplication().runWriteAction(wrap(runnable)));
}