spring-attic / spring-social

Allows you to connect your applications with SaaS providers such as Facebook and Twitter.
http://projects.spring.io/spring-social
Apache License 2.0
619 stars 351 forks source link

Incorrect JavaDoc of "ConnectionRepository::findAllConnections" method #210

Closed petrdvorak closed 8 years ago

petrdvorak commented 8 years ago

Currently, the JavaDoc in ConnectionRepository::findAllConnections() method says following:

" Returns an empty map if the user has no connections.

This information seems to be misleading - it suggests that no keys are present in the returned map. According to my testing though, this method returns map with keys representing all registered providers and empty lists as values in case the user has no connection with the provider.

Here is my sample code:

ConnectionRepository repository = userConnectionRepository.createConnectionRepository(userId);
MultiValueMap<String, Connection<?>> connections = repository.findAllConnections();

for (String provider : connections.keySet()) {
    if (!connections.get(provider).isEmpty()) { // <= this works as expected and skips the provider with no connection
        Connection<?> c = connections.getFirst(provider);
        Service s = new Service();
        s.setName(provider);
        s.setConnectionDisplayName(c.getDisplayName());
        resultList.add(s);
    }
}

It would be nice to fix the docs to be more precise.