/** * Retrieve assigned tags by current user. * Retrieve all tags the current user has assigned to a contact. * Basically works the same as {@link ContactsResource#getAssignedTags(String, String)}, but already putting the user * id as ME. * * @param contactId ID of the users contact. */ public CallSpec<List<String>, HttpError> getOwnAssignedTags(String contactId) { return getAssignedTags(ME, contactId); }
return getUserContacts(ME);
@Override public Resource create(XingApi api) { return new ContactsResource(api); } };
@Test public void acceptContactRequest() throws Exception { testVoidSpec(resource.acceptContactRequest("user_id", "sender_id")); }
@Test public void getOwnContacts() throws Exception { server.enqueue(new MockResponse().setBody(BODY_LIST_OF_CONTACTS)); Response<List<XingUser>, HttpError> response = resource.getOwnContacts().execute(); // If no exception was thrown then the spec is build correctly. assertThat(response.body().size()).isEqualTo(5); }
+ '}')); Response<ContactPaths, HttpError> response = resource.getContactPaths("firstId", "secondId").execute();
+ '}')); Response<List<ContactRequest>, HttpError> response = resource.getIncomingContactRequests().execute();
@Test public void getOwnContactsIds() throws Exception { server.enqueue(new MockResponse().setBody("{\n" + " \"contact_ids\": {\n" + " \"items\": [\n" + " \"3582_f213af\",\n" + " \"385526_b94012\",\n" + " \"391722_0ab373\"\n" + " ]\n" + " }\n" + '}')); Response<List<String>, HttpError> response = resource.getOwnContactsIds().execute(); // If no exception was thrown then the spec is build correctly. assertThat(response.body()).containsExactly("3582_f213af", "385526_b94012", "391722_0ab373"); }
@Test public void getOwnAssignedTags() throws Exception { server.enqueue(new MockResponse().setBody("{\n" + " \"tags\": {\n" + " \"total\": 2,\n" + " \"items\": [\n" + " {\n" + " \"tag\": \"android\"\n" + " },\n" + " {\n" + " \"tag\": \"kotlin\"\n" + " }\n" + " ]\n" + " }\n" + '}')); Response<List<String>, HttpError> response = resource.getOwnAssignedTags("contact_id").execute(); // If no exception was thrown then the spec is build correctly. assertThat(response.body()).containsExactly("android", "kotlin"); }
@Test public void getPendingContactRequests() throws Exception { server.enqueue(new MockResponse().setBody("{\n" + " \"contact_requests\": [\n" + " {\n" + " \"sender_id\": \"19828488_2f3282\",\n" + " \"recipient_id\": \"8957208_181cf4\"\n" + " },\n" + " {\n" + " \"sender_id\": \"19828488_2f3282\",\n" + " \"recipient_id\": \"20195666_868fe8\"\n" + " },\n" + " {\n" + " \"sender_id\": \"19828488_2f3282\",\n" + " \"recipient_id\": \"12022726_a0415b\"\n" + " }\n" + " ]\n" + '}')); Response<List<PendingContactRequest>, HttpError> response = resource.getPendingContactRequests().execute(); // If no exception was thrown then the spec is build correctly. assertThat(response.body()).containsExactly( new PendingContactRequest("19828488_2f3282", "8957208_181cf4"), new PendingContactRequest("19828488_2f3282", "20195666_868fe8"), new PendingContactRequest("19828488_2f3282", "12022726_a0415b")); }
@Test public void getUserContacts() throws Exception { server.enqueue(new MockResponse().setBody(BODY_LIST_OF_CONTACTS)); Response<List<XingUser>, HttpError> response = resource.getUserContacts("some_id").execute(); // If no exception was thrown then the spec is build correctly. assertThat(response.body().size()).isEqualTo(5); }
@Test public void getAssignedTags() throws Exception { server.enqueue(new MockResponse().setBody("{\n" + " \"tags\": {\n" + " \"total\": 2,\n" + " \"items\": [\n" + " {\n" + " \"tag\": \"Business opportunities in München/Munich\"\n" + " },\n" + " {\n" + " \"tag\": \"friends\"\n" + " }\n" + " ]\n" + " }\n" + '}')); Response<List<String>, HttpError> response = resource.getAssignedTags("user_id", "contact_id").execute(); // If no exception was thrown then the spec is build correctly. assertThat(response.body()).containsExactly("Business opportunities in München/Munich", "friends"); }