All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dreamhead.moco.VerificationData Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
package com.github.dreamhead.moco;

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;

import static com.google.common.collect.FluentIterable.from;
import static java.lang.String.format;

public class VerificationData {
    private final ImmutableList requests;
    private final RequestMatcher matcher;
    private final String mismatchFormat;

    public VerificationData(final ImmutableList 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 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);
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy