JobsResource extends Resource { public CallSpec<List<PartialJob>, HttpError> getJobsByCriteria(String criteria) { return Resource.<List<PartialJob>, HttpError>newGetSpec(api, "/v1/jobs/find") .queryParam("query", criteria) .responseAs(list(PartialJob.class, "jobs", "items")) .build(); } JobsResource(XingApi api); CallSpec<Job, HttpError> getJobById(String jobId); CallSpec<List<PartialJob>, HttpError> getJobsByCriteria(String criteria); CallSpec<List<PartialJob>, HttpError> getJobsRecommendationsForUser(String userId);  }
@Test public void getJobsByCriteria() throws Exception { server.enqueue(new MockResponse().setBody(file("list_of_jobs.json"))); Response<List<PartialJob>, HttpError> response = resource.getJobsByCriteria("some_criteria").execute(); assertThat(response.body().get(0).id()).isEqualTo("61723_4cae01"); assertThat(response.body().get(0).contact().jobCompany().name()).isEqualTo("Rails Heroes"); }