com.github.dreamhead.moco.VerificationData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
package com.github.dreamhead.moco;
import com.google.common.base.Predicate;
import static com.google.common.collect.FluentIterable.from;
import static java.lang.String.format;
public class VerificationData {
private final Iterable requests;
private final RequestMatcher matcher;
private final String mismatchFormat;
public VerificationData(final Iterable requests,
final RequestMatcher matcher,
final String mismatchFormat) {
this.requests = requests;
this.matcher = matcher;
this.mismatchFormat = mismatchFormat;
}
public String mismatchDescription(final int actualSize, final String expected) {
return format(mismatchFormat, expected, actualSize);
}
public final int matchedSize() {
return from(requests).filter(matched()).size();
}
private Predicate matched() {
return new Predicate() {
@Override
public boolean apply(final Request request) {
return matcher.match(request);
}
};
}
}