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

com.github.dreamhead.moco.matcher.MatchMatcher 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.matcher;

import com.github.dreamhead.moco.Request;
import com.github.dreamhead.moco.RequestExtractor;
import com.github.dreamhead.moco.RequestMatcher;
import com.github.dreamhead.moco.resource.Resource;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;

import java.util.regex.Pattern;

public class MatchMatcher extends AbstractOperatorMatcher {
    public MatchMatcher(final RequestExtractor extractor, final Resource expected) {
        super(extractor, expected, new Predicate() {

            @Override
            public boolean apply(final String input) {
                Pattern pattern = Pattern.compile(expected.readFor(Optional.absent()).toString());
                return pattern.matcher(input).matches();
            }
        });
    }

    @Override
    protected RequestMatcher newMatcher(final RequestExtractor extractor, final Resource resource) {
        return new MatchMatcher(extractor, resource);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy