public final class OptionalSubject extends Subject<OptionalSubject,Optional<?>>
Optional
subjects.Subject.Factory<SubjectT extends Subject,ActualT>
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, equals, failWithActual, failWithActual, failWithoutActual, getSubject, hashCode, ignoreCheck, internalCustomName, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, 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 © 2019. All rights reserved.