ContactsResource extends Resource { public CallSpec<List<ContactRequest>, HttpError> getIncomingContactRequests() { return Resource.<List<ContactRequest>, HttpError>newGetSpec(api, "/v1/users/me/contact_requests") .responseAs(list(ContactRequest.class, "contact_requests")) .build(); } ContactsResource(XingApi api); CallSpec<List<XingUser>, HttpError> getUserContacts(String userId); CallSpec<List<XingUser>, HttpError> getOwnContacts(); CallSpec<List<String>, HttpError> getOwnContactsIds(); CallSpec<List<String>, HttpError> getAssignedTags(String userId, String contactId); CallSpec<List<String>, HttpError> getOwnAssignedTags(String contactId); CallSpec<List<XingUser>, HttpError> getSharedContacts(String userId); @Experimental CallSpec<List<XingUser>, HttpError> getUpcomingBirthdays(); CallSpec<List<ContactRequest>, HttpError> getIncomingContactRequests(); CallSpec<List<PendingContactRequest>, HttpError> getPendingContactRequests(); CallSpec<Void, HttpError> sendContactRequest(String userId); CallSpec<Void, HttpError> acceptContactRequest(String recipientId, String senderId); CallSpec<Void, HttpError> revokeContactRequest(String recipientId, String senderId); CallSpec<ContactPaths, HttpError> getContactPaths(String userId, String otherUserId); CallSpec<InvitationStats, HttpError> inviteByMail(String... emails);  }
@Test public void getIncomingContactRequests() throws Exception { server.enqueue(new MockResponse().setBody("{\n" + " \"contact_requests\": [\n" + " {\n" + " \"sender_id\": \"6055623_5cf823\",\n" + " \"sender\": {\n" + " \"id\": \"6055623_5cf823\",\n" + " \"display_name\": \"John Doe\"\n" + " },\n" + " \"message\": \"Sehr geehrter Herr Irgendwas, ich würde Sie gern zu meinen Kontakten hinzufügen" + "\",\n" + " \"received_at\": \"2010-11-17T10:56:16Z\"\n" + " }\n" + " ]\n" + '}')); Response<List<ContactRequest>, HttpError> response = resource.getIncomingContactRequests().execute(); SafeCalendar safeCalendar = new SafeCalendar(2010, Calendar.NOVEMBER, 17, 10, 56, 16); safeCalendar.setTimeZone(TimeZone.getTimeZone("UTC")); assertThat(response.body()).hasSize(1); ContactRequest contactRequest = response.body().get(0); assertThat(contactRequest.getMessage()) .isEqualTo("Sehr geehrter Herr Irgendwas, ich würde Sie gern zu meinen Kontakten hinzufügen"); assertThat(contactRequest.getReceivedAt()) .isEqualTo(safeCalendar); assertThat(contactRequest.getSenderId()) .isEqualTo("6055623_5cf823"); assertThat(contactRequest.getSender()) .isEqualTo(new XingUser("6055623_5cf823").displayName("John Doe")); }