io.github.olib963.javatest.matchers.OptionalMatchers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javatest-matchers Show documentation
Show all versions of javatest-matchers Show documentation
Matchers to create assertions from common conditions
package io.github.olib963.javatest.matchers;
import io.github.olib963.javatest.matchers.internal.OptionalMatcher;
import io.github.olib963.javatest.matchers.internal.PredicateMatcher;
import java.util.Optional;
public class OptionalMatchers {
private OptionalMatchers() {}
public static Matcher> isEmptyOptional() {
return PredicateMatcher.of(Optional::isEmpty, "be an empty Optional");
}
public static Matcher> isOptionalOf(T value) {
return isOptionalThat(PredicateMatcher.isEqualTo(value));
}
public static Matcher> isOptionalThat(Matcher matcher) {
return new OptionalMatcher<>(matcher);
}
}