play.libs.ws.DummyWSClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
RePlay is a fork of the Play1 framework, created by Codeborne.
package play.libs.ws;
import java.util.HashMap;
import java.util.Map;
import static java.util.Collections.emptyMap;
public class DummyWSClient extends WSAsync {
private final Map> requests = new HashMap<>();
private final Map> responses = new HashMap<>();
public void replyWith(String url, HttpMethod method, int status, String body) {
this.responses
.computeIfAbsent(url, u -> new HashMap<>())
.put(method, new DummyHttpResponse(status, body));
}
@Override
public WSRequest newRequest(String url) {
return new DummyWSRequest(url, requests, responses);
}
public DummyWSRequest actualRequest(String url, HttpMethod method) {
return requests.getOrDefault(url, emptyMap()).get(method);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy