import com.google.common.base.Throwables;
public class PollingMatcherAssert implements Probe {
private final Matchers matchers;
public PollingMatcherAssert(Matchers matchers) {
this.matchers = matchers;
}
private String errorMessage;
public boolean isSatisfied() {
try {
matchers.run();
return true;
} catch (Throwable e) {
errorMessage = Throwables.getStackTraceAsString(e);
return false;
}
}
public String describeFailure() {
return errorMessage;
}
@FunctionalInterface
public interface Matchers {
void run() throws Exception;
}
}