JsonSlackDAO extends AbstractJSONChatApiDAO { @Override public Map<String, User> getUsers() { WebResource userResource = resource.path("users.list"); String jsonStr = getJsonResultWithRetries(userResource, apiRetries); Collection<User> userCol = deserializeJsonStr(jsonStr, "members", User.class, objMapper); Map<String, User> result = Maps.newHashMapWithExpectedSize(userCol.size()); for (User user : userCol) { result.put(user.getUserId(), user); } return result; } JsonSlackDAO(ChatAlyticsConfig config, Client client); @Override Map<String, Room> getRooms(); @Override Map<String, User> getUsers(); @Override Map<String, User> getUsersForRoom(Room room); URI getRealtimeWebSocketURI(); @Override List<Message> getMessages(DateTime start, DateTime end, Room room); @Override Map<String, String> getEmojis();  }
@Test public void testGetUsers() throws Exception { WebResource mockUserResource = mock(WebResource.class); when(mockResource.path("users.list")).thenReturn(mockUserResource); URI userListURI = Resources.getResource("slack_api_responses/users.list.txt").toURI(); Path usersPath = Paths.get(userListURI); String usersResponseStr = new String(Files.readAllBytes(usersPath)); doReturn(usersResponseStr).when(underTest).getJsonResultWithRetries(mockUserResource, apiRetries); Map<String, User> users = underTest.getUsers(); assertEquals(2, users.size()); for (User user : users.values()) { assertNotNull(user); } }