// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
// 
//     @Id
//     @Indexed
//     private String providerUserId;
// 
//     @Indexed
//     private String userId;
// 
//     @Indexed
//     private String providerId;
// 
//     private String displayName;
// 
//     private String profileUrl;
// 
//     private String imageUrl;
// 
//     private String accessToken;
// 
//     private String secret;
// 
//     private String refreshToken;
// 
//     private Long expireTime;
// }
// 
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
// 
//     Iterable<SocialRedisConnection> findByProviderId(final String providerId);
// 
//     Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
// 
//     SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
// 
//     // TODO: will be available once DATAKV-135 is finished
//     void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
// 
//     Iterable<SocialRedisConnection> findByUserId(final String userId);
// 
//     Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }


import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.*;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
package be.ordina.jworks.social.redis.connection;



public class RedisConnectionRepository implements ConnectionRepository {

    private final ConnectionFactoryLocator connectionFactoryLocator;
    private final TextEncryptor textEncryptor;
    private final SocialRedisConnectionRepository socialRedisConnectionRepository;
    private final String userId;

    public RedisConnectionRepository(final ConnectionFactoryLocator connectionFactoryLocator, final TextEncryptor textEncryptor, final SocialRedisConnectionRepository socialRedisConnectionRepository, final String userId) {
        Assert.notNull(socialRedisConnectionRepository, "socialRedisConnectionRepository is required");
        Assert.notNull(userId, "userId is required");

        this.userId = userId;
        this.socialRedisConnectionRepository = socialRedisConnectionRepository;
        this.connectionFactoryLocator = connectionFactoryLocator;
        this.textEncryptor = textEncryptor;
    }

    public MultiValueMap<String, Connection<?>> findAllConnections() {
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnection.java
// @Getter
// @Setter
// @AllArgsConstructor
// @RedisHash("socialRedisConnection")
// public class SocialRedisConnection {
// 
//     @Id
//     @Indexed
//     private String providerUserId;
// 
//     @Indexed
//     private String userId;
// 
//     @Indexed
//     private String providerId;
// 
//     private String displayName;
// 
//     private String profileUrl;
// 
//     private String imageUrl;
// 
//     private String accessToken;
// 
//     private String secret;
// 
//     private String refreshToken;
// 
//     private Long expireTime;
// }
// 
// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/data/SocialRedisConnectionRepository.java
// @Repository
// public interface SocialRedisConnectionRepository extends CrudRepository<SocialRedisConnection, String> {
// 
//     Iterable<SocialRedisConnection> findByProviderId(final String providerId);
// 
//     Iterable<SocialRedisConnection> findByUserIdAndProviderId(final String userId, final String providerId);
// 
//     SocialRedisConnection findOneByUserIdAndProviderIdAndProviderUserId(String userId, String providerId, String providerUserId);
// 
//     // TODO: will be available once DATAKV-135 is finished
//     void deleteByUserIdAndProviderIdAndProviderUserId(final String userId, final String providerId, final String providerUserId);
// 
//     Iterable<SocialRedisConnection> findByUserId(final String userId);
// 
//     Iterable<SocialRedisConnection> findByProviderIdAndProviderUserId(final String providerId, final String providerUserId);
// }


// Path: social-redis-spring-boot-starter/src/main/java/be/ordina/jworks/social/redis/connection/RedisConnectionRepository.java
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnection;
import be.ordina.jworks.social.redis.connection.data.SocialRedisConnectionRepository;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.connect.*;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

package be.ordina.jworks.social.redis.connection;



public class RedisConnectionRepository implements ConnectionRepository {

    private final ConnectionFactoryLocator connectionFactoryLocator;
    private final TextEncryptor textEncryptor;
    private final SocialRedisConnectionRepository socialRedisConnectionRepository;
    private final String userId;

    public RedisConnectionRepository(final ConnectionFactoryLocator connectionFactoryLocator, final TextEncryptor textEncryptor, final SocialRedisConnectionRepository socialRedisConnectionRepository, final String userId) {
        Assert.notNull(socialRedisConnectionRepository, "socialRedisConnectionRepository is required");
        Assert.notNull(userId, "userId is required");

        this.userId = userId;
        this.socialRedisConnectionRepository = socialRedisConnectionRepository;
        this.connectionFactoryLocator = connectionFactoryLocator;
        this.textEncryptor = textEncryptor;
    }

    public MultiValueMap<String, Connection<?>> findAllConnections() {
        Iterable<SocialRedisConnection> allConnections = socialRedisConnectionRepository.findByUserId(userId);