Package io.helidon.common.testing.junit5
Class OptionalMatcher
java.lang.Object
io.helidon.common.testing.junit5.OptionalMatcher
Hamcrest matchers for
Optional
.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> org.hamcrest.Matcher
<Optional<T>> A matcher for anOptional
that checks it is empty.static <T> org.hamcrest.Matcher
<Optional<T>> A matcher for anOptional
that checks it is present.static <T> org.hamcrest.Matcher
<Optional<T>> optionalValue
(org.hamcrest.Matcher<? super T> matcher) A matcher for anOptional
that checks it is present, and that the value matches the provided matcher.
-
Method Details
-
optionalValue
public static <T> org.hamcrest.Matcher<Optional<T>> optionalValue(org.hamcrest.Matcher<? super T> matcher) A matcher for anOptional
that checks it is present, and that the value matches the provided matcher.Usage example:
assertThat(myOptional, optionalValue(is("expected")));
- Type Parameters:
T
- type of the value- Parameters:
matcher
- matcher to validate the content of the optional- Returns:
- matcher validating the
Optional
is present and matches the provided matcher
-
optionalEmpty
A matcher for anOptional
that checks it is empty.Usage example:
assertThat(myOptional, optionalEmpty());
- Type Parameters:
T
- type of the optional- Returns:
- matcher validating the
Optional
is empty
-
optionalPresent
A matcher for anOptional
that checks it is present.Usage example:
assertThat(myOptional, optionalPresent());
- Type Parameters:
T
- type of the value- Returns:
- matcher validating the
Optional
is present
-