io.magentys.FutureMission Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cherry-java8 Show documentation
Show all versions of cherry-java8 Show documentation
A syntactical sugar project for BDD oriented tests
package io.magentys;
import java.util.concurrent.CompletableFuture;
public interface FutureMission extends Mission{
default public CompletableFuture accomplishAsync(Mission mission, FunctionalAgent agent) {
CompletableFuture futureResult = new CompletableFuture<>();
Runnable runnable = () -> {
try {
Result result = mission.accomplishAs(agent);
futureResult.complete(result);
} catch (Throwable e) {
futureResult.completeExceptionally(e);
}
};
new Thread(runnable).start();
return futureResult;
}
}