use of com.recurly.v3.fixtures.MyResource 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());
}
use of com.recurly.v3.fixtures.MyResource in project recurly-client-java by recurly.
the class MockClient method listResources.
public Pager<MyResource> listResources(QueryParams queryParams) {
final String url = "/resources";
final HashMap<String, String> urlParams = new HashMap<String, String>();
if (queryParams == null)
queryParams = new QueryParams();
final HashMap<String, Object> paramsMap = queryParams.getParams();
final String path = this.interpolatePath(url, urlParams);
Type parameterizedType = TypeToken.getParameterized(Pager.class, MyResource.class).getType();
return new Pager<>(path, paramsMap, this, parameterizedType);
}
Aggregations