com.github.dreamhead.moco.internal.BaseServer 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.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(final RequestMatcher matcher);
public T request(final RequestMatcher matcher) {
return this.onRequestAttached(checkNotNull(matcher, "Matcher should not be null"));
}
public T request(final RequestMatcher... matchers) {
checkNotNull(matchers, "Matcher should not be null");
return request(or(head(matchers), tail(matchers)));
}
}