public final class GuavaOptionalSubject extends Subject<GuavaOptionalSubject,com.google.common.base.Optional<?>>
Optional
subjects.failureStrategy
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 |
isAbsent()
Fails if the
Optional <T> is present or the subject is null.. |
void |
isPresent()
Fails if the
Optional <T> is absent or the subject is null. |
actual, actualAsString, actualCustomStringRepresentation, check, equals, fail, fail, fail, failComparing, failComparing, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutSubject, failWithRawMessage, failWithRawMessageAndCause, getDisplaySubject, getSubject, hashCode, ignoreCheck, internalCustomName, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameAs, isNull, isSameAs, named
public void isPresent()
Optional
<T>
is absent or the subject is null.public void isAbsent()
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");
Copyright © 2017. All rights reserved.