UsersResource { @GET @Path("photourls") @Produces(MediaType.APPLICATION_JSON) public Map<String, String> getUserPhotoURLs() { LOG.debug("Got a call to get user photo URLs"); return chatApiDao.getUsers().values().stream() .filter(u -> u.getMentionName() != null && u.getPhotoUrl() != null) .collect(Collectors.toMap(User::getMentionName, User::getPhotoUrl)); } UsersResource(ChatAlyticsConfig config); @VisibleForTesting protected  UsersResource(IChatApiDAO chatApiDao); @GET @Produces(MediaType.APPLICATION_JSON) Map<String, User> getUsers(); @GET @Path("user") @Produces(MediaType.APPLICATION_JSON) User getUser(@QueryParam(USER) String username); @GET @Path("photourls") @Produces(MediaType.APPLICATION_JSON) Map<String, String> getUserPhotoURLs(); static final String USER_ENDPOINT; }
@Test public void testGetUserPhotoURLs() { String url1 = "http: String url2 = "http: User user1 = new User("u1", "u1@email.com", false, false, false, "name", "mu1", url1, DateTime.now(), DateTime.now(), null, null, null, null); User user2 = new User("u2", "u2@email.com", false, false, false, "name", "mu2", url2, DateTime.now(), DateTime.now(), null, null, null, null); Map<String, User> users = ImmutableMap.of("id1", user1, "id2", user2); when(chatApiDao.getUsers()).thenReturn(users); Map<String, String> expectedResult = ImmutableMap.of(user1.getMentionName(), url1, user2.getMentionName(), url2); Map<String, String> result = underTest.getUserPhotoURLs(); assertEquals(expectedResult, result); }