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

com.github.dreamhead.moco.internal.BaseServer 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.internal;

import com.github.dreamhead.moco.RequestMatcher;
import com.github.dreamhead.moco.ResponseSetting;
import com.github.dreamhead.moco.Server;

import static com.github.dreamhead.moco.Moco.or;
import static com.github.dreamhead.moco.util.Iterables.head;
import static com.github.dreamhead.moco.util.Iterables.tail;
import static com.google.common.base.Preconditions.checkNotNull;

public abstract class BaseServer>
        extends BaseResponseSettingConfiguration implements Server {
    protected abstract T onRequestAttached(RequestMatcher matcher);

    public final T request(final RequestMatcher matcher) {
        return this.onRequestAttached(checkNotNull(matcher, "Matcher should not be null"));
    }

    public final T request(final RequestMatcher... matchers) {
        checkNotNull(matchers, "Matcher should not be null");
        return request(or(head(matchers), tail(matchers)));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy