com.thoughtworks.webstub.dsl.builders.RequestBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of web-stub Show documentation
Show all versions of web-stub Show documentation
Library for stubbing external HTTP dependencies
package com.thoughtworks.webstub.dsl.builders;
import com.thoughtworks.webstub.config.ConfigurationProvider;
import com.thoughtworks.webstub.config.HttpConfiguration;
import com.thoughtworks.webstub.config.Request;
import com.thoughtworks.webstub.config.Header;
import java.util.ArrayList;
import java.util.Collection;
public class RequestBuilder {
private ConfigurationProvider configurationProvider;
protected String uri;
protected String method;
protected Collection headers = new ArrayList();
public RequestBuilder(ConfigurationProvider configurationProvider) {
this.configurationProvider = configurationProvider;
}
public T withMethod(String method) {
this.method = method;
return (T) this;
}
public T withUri(String uri) {
this.uri = uri;
return (T) this;
}
public T withHeader(String name, String value) {
headers.add(new Header(name, value));
return (T) this;
}
protected Request build() {
return new Request(method, uri, null, headers);
}
public final void returns(ResponseBuilder responseBuilder) {
configurationProvider.configurationCreated(new HttpConfiguration(this.build(), responseBuilder.build()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy