public abstract class AbstractFutureAssert<SELF extends AbstractFutureAssert<SELF,ACTUAL,RESULT>,ACTUAL extends Future<RESULT>,RESULT> extends AbstractAssert<SELF,ACTUAL>
actual, info, myself, throwUnsupportedExceptionOnEquals
Modifier | Constructor and Description |
---|---|
protected |
AbstractFutureAssert(ACTUAL actual,
Class<?> selfType) |
Modifier and Type | Method and Description |
---|---|
SELF |
isCancelled()
Verifies that the
Future is cancelled. |
SELF |
isDone()
Verifies that the
Future is done. |
SELF |
isNotCancelled()
Verifies that the
Future is not cancelled. |
SELF |
isNotDone()
Verifies that the
Future is not done. |
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
public SELF isCancelled()
Future
is cancelled.
Example:
ExecutorService executorService = Executors.newSingleThreadExecutor();
Future<String> future = executorService.submit(new Callable<String>() {
@Override
public String call() throws Exception {
return "done";
}
});
// assertion will fail:
assertThat(future).isCancelled();
// assertion will pass:
future.cancel(true);
assertThat(future).isCancelled();
Future.isCancelled()
public SELF isNotCancelled()
Future
is not cancelled.
Example:
ExecutorService executorService = Executors.newSingleThreadExecutor();
Future<String> future = executorService.submit(new Callable<String>() {
@Override
public String call() throws Exception {
return "done";
}
});
// assertion will pass:
assertThat(future).isNotCancelled();
// assertion will fail:
future.cancel(true);
assertThat(future).isNotCancelled();
Future.isCancelled()
public SELF isDone()
Future
is done.
Example:
ExecutorService executorService = Executors.newSingleThreadExecutor();
Future<String> future = executorService.submit(new Callable<String>() {
@Override
public String call() throws Exception {
return "done";
}
});
// assertion will pass:
assertThat(future).isDone();
future = executorService.submit(new Callable<String>() {
@Override
public String call() throws Exception {
Thread.sleep(1000);
return "done";
}
});
// assertion will fail:
assertThat(future).isDone();
Future.isDone()
public SELF isNotDone()
Future
is not done.
Example:
ExecutorService executorService = Executors.newSingleThreadExecutor();
Future<String> future = executorService.submit(new Callable<String>() {
@Override
public String call() throws Exception {
Thread.sleep(1000);
return "done";
}
});
// assertion will pass:
assertThat(future).isNotDone();
future = executorService.submit(new Callable<String>() {
@Override
public String call() throws Exception {
return "done";
}
});
// assertion will fail:
assertThat(future).isNotDone();
Future.isDone()
Copyright © 2014–2019 AssertJ. All rights reserved.