Skip to content

Add eventually matcher. #2

Open
@tobyclemson

Description

@tobyclemson

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(...);
       }
   }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions