UsersTemplate extends AbstractVKontakteOperations implements UsersOperations { @Override public List<VKontakteProfile> getProfiles(List<String> userIds) { requireAuthorization(); Properties props = new Properties(); StringBuilder uids = new StringBuilder(); if(userIds != null) { for(String uid : userIds) { if(uids.toString().isEmpty()) uids.append(uid.trim()); else uids.append(",").append(uid.trim()); } } props.put("uids", userIds == null ? uid : uids.toString()); props.put("fields", "uid,first_name,last_name,photo,photo_medium,photo_big,contacts,bdate"); URI uri = URIBuilder.fromUri(makeOperationURL("getProfiles", props)).build(); VKontakteProfiles profiles = restTemplate.getForObject(uri, VKontakteProfiles.class); checkForError(profiles); return profiles.getProfiles(); } UsersTemplate(RestTemplate restTemplate, String accessToken, String uid, boolean isAuthorizedForUser); @Override List<VKontakteProfile> getProfiles(List<String> userIds); @Override VKontakteProfile getProfile();  }
@Test(expected = VKontakteErrorException.class) public void getProfiles_expiredToken() { mockServer .expect(requestTo("https: .andExpect(method(GET)).andRespond(withResponse(jsonResource("error-code-5"), responseHeaders)); vkontakte.usersOperations().getProfiles(new ArrayList<String>() { private static final long serialVersionUID = 4211781776280003660L; { add("1"); add("2"); } }); }
@Test public void getProfiles_currentUser() { mockServer .expect(requestTo("https: .andExpect(method(GET)).andRespond(withResponse(jsonResource("list-of-profiles"), responseHeaders)); List<VKontakteProfile> profiles = vkontakte.usersOperations().getProfiles(new ArrayList<String>() { private static final long serialVersionUID = 583451105415032388L; { add("1"); add("2"); add("3"); } }); assertProfiles(profiles); }
@Test(expected = MissingAuthorizationException.class) public void getProfiles_unauthorized() { unauthorizedVKontakte.usersOperations().getProfiles(new ArrayList<String>() { private static final long serialVersionUID = 9175797703832707981L; { add("1"); add("2"); } }); }