public class MockClient extends Object implements Client, AsyncClient
| Constructor and Description |
|---|
MockClient(Supplier<Config> config) |
| Modifier and Type | Method and Description |
|---|---|
Assert |
assertThat(HttpMethod method,
String path)
Assert a specific method and path were invoked
|
static void |
clear()
Clears any MockClient from the primary instance
|
static void |
clear(UnirestInstance unirest)
Clears any MockClient from the instance
|
Stream<Exception> |
close() |
Expectation |
expect(HttpMethod method)
Expect ANY call to a path with this method
|
Expectation |
expect(HttpMethod method,
String path)
Start an expectation chain.
|
Object |
getClient() |
static MockClient |
register()
Creates a new MockClient and registers it on the primary static UnirestInstance
|
static MockClient |
register(UnirestInstance unirest)
Creates a new MockClient and registers it on the Unirest instance
|
void |
registerShutdownHook() |
<T> HttpResponse<T> |
request(HttpRequest request,
Function<RawResponse,HttpResponse<T>> transformer) |
<T> CompletableFuture<HttpResponse<T>> |
request(HttpRequest request,
Function<RawResponse,HttpResponse<T>> transformer,
CompletableFuture<HttpResponse<T>> callback) |
void |
verifyAll()
Verify that all Expectations were invoked
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisRunning, requestpublic static MockClient register()
public static MockClient register(UnirestInstance unirest)
unirest - an instance of Unirestpublic static void clear()
public static void clear(UnirestInstance unirest)
unirest - the instance to clear the mocks frompublic <T> HttpResponse<T> request(HttpRequest request, Function<RawResponse,HttpResponse<T>> transformer)
public <T> CompletableFuture<HttpResponse<T>> request(HttpRequest request, Function<RawResponse,HttpResponse<T>> transformer, CompletableFuture<HttpResponse<T>> callback)
request in interface AsyncClientpublic Object getClient()
getClient in interface AsyncClientgetClient in interface Clientpublic Stream<Exception> close()
close in interface AsyncClientclose in interface Clientpublic void registerShutdownHook()
registerShutdownHook in interface AsyncClientregisterShutdownHook in interface Clientpublic Expectation expect(HttpMethod method, String path)
method - the Http methodpath - the base pathpublic Expectation expect(HttpMethod method)
method - the Http Methodpublic Assert assertThat(HttpMethod method, String path)
method - the Http methodpath - the base pathpublic void verifyAll()
Copyright © 2021. All rights reserved.