Open
Description
See Funk for resultOfSampling, Sampler and CompletableSample.
public static Matcher<? super T> eventually(Matcher<? super T> matcher) {
return new TypeSafeDiagnosingMatcher<T>() {
@Override
public boolean matchesSafely(T item, Description description) {
boolean matchedSuccessfully = resultOfSampling(new Sampler<Boolean>() {
@Override
public Boolean takeSample() {
return matcher.matches(item);
}
@Override
public boolean isComplete(Boolean sample) {
return sample;
}
}
if(!matchedSuccessfully) {
description.appendText(...);
return false;
}
return true;
}
@Override
public void describeTo(Description description) {
description.appendText(...);
}
}
}