UserProfilesResource extends Resource { @Experimental public CallSpec<List<XingUser>, HttpError> findUsersByKeyword(String keywords) { return Resource.<List<XingUser>, HttpError>newGetSpec(api, "/v1/users/find") .responseAs(list(single(XingUser.class, "user"), "users", "items")) .queryParam("keywords", keywords) .build(); } UserProfilesResource(XingApi api); CallSpec<List<XingUser>, HttpError> getUsersById(List<String> ids); CallSpec<XingUser, HttpError> getUserById(String id); CallSpec<XingUser, HttpError> getOwnProfile(); CallSpec<XingUser, HttpError> getOwnIdCard(); CallSpec<List<XingUser>, HttpError> findUsersByEmail(List<String> emails); @Experimental CallSpec<List<XingUser>, HttpError> findUsersByKeyword(String keywords); CallSpec<ProfileMessage, HttpError> getUserProfileMessage(String userId); CallSpec<ProfileMessage, HttpError> getOwnProfileMessage(); CallSpec<String, HttpError> getUserLegalInformation(String userId); CallSpec<String, HttpError> getOwnLegalInformation();  }
@Test public void findUsersByKeyword() throws Exception { server.enqueue(new MockResponse().setBody("{\n" + " \"users\": {\n" + " \"items\": [\n" + " {\n" + " \"user\": {\n" + " \"id\": \"2_abcdef\"\n" + " }\n" + " },\n" + " {\n" + " \"user\": {\n" + " \"id\": \"3_ad7e12\"\n" + " }\n" + " }\n" + " ],\n" + " \"total\": 2\n" + " }\n" + '}')); Response<List<XingUser>, HttpError> response = resource.findUsersByKeyword("test").execute(); assertThat(response.body().size()).isEqualTo(2); assertThat(response.body().get(0).id()).isEqualTo("2_abcdef"); assertThat(response.body().get(1).id()).isEqualTo("3_ad7e12"); }