public final class OptionalSubject extends Subject<OptionalSubject,Optional<?>>
Optional
subjects.Modifier and Type | Method and Description |
---|---|
void |
hasValue(Object expected)
Fails if the
Optional <T> does not have the given value or the subject is null. |
void |
isEmpty()
Fails if the
Optional <T> is present or the subject is null. |
void |
isPresent()
Fails if the
Optional <T> is empty or the subject is null. |
static Subject.Factory<OptionalSubject,Optional<?>> |
optionals() |
actual, actualAsString, actualCustomStringRepresentation, check, check, equals, fail, fail, fail, failComparing, failComparing, failWithActual, failWithActual, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutActual, failWithoutSubject, failWithRawMessage, failWithRawMessageAndCause, getSubject, hashCode, ignoreCheck, internalCustomName, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameAs, isNull, isSameAs, named, toString
public void isPresent()
Optional
<T>
is empty or the subject is null.public void isEmpty()
Optional
<T>
is present or the subject is null.public void hasValue(Object expected)
Optional
<T>
does not have the given value or the subject is null.
To make more complex assertions on the optional's value split your assertion in two:
assertThat(myOptional).isPresent();
assertThat(myOptional.get()).contains("foo");
public static Subject.Factory<OptionalSubject,Optional<?>> optionals()
Copyright © 2018. All rights reserved.