use of com.recurly.v3.fixtures.MockClient in project recurly-client-java by recurly.
the class PagerTest method testFirst.
@Test
public void testFirst() throws IOException {
final Call mCall = mock(Call.class);
Answer answer = (i) -> {
Request request = i.getArgument(0);
HttpUrl url = request.url();
assertEquals("1", url.queryParameter("limit"));
return mCall;
};
when(mCall.execute()).thenReturn(MockClient.buildResponse(200, "OK", getResourceFirstItemJson()));
OkHttpClient mockOkHttpClient = MockClient.getMockOkHttpClient(answer);
final MockClient client = new MockClient("apiKey", mockOkHttpClient);
Pager<MyResource> pager = client.listResources(null);
MyResource resource = pager.getFirst();
assertEquals("Resource First Item", resource.getMyString());
}
Aggregations