@Test
 public void findUserIdWithConnection() {
   insertFacebookConnection();
   List<String> userIds =
       usersConnectionRepository.findUserIdsWithConnection(
           connectionRepository.getPrimaryConnection(TestFacebookApi.class));
   assertEquals("1", userIds.get(0));
 }
 @Test
 public void findUserIdsConnectedTo() {
   insertFacebookConnection();
   insertFacebookConnection3();
   Set<String> localUserIds =
       usersConnectionRepository.findUserIdsConnectedTo(
           "facebook", new HashSet<>(Arrays.asList("9", "11")));
   assertEquals(2, localUserIds.size());
   assertTrue(localUserIds.contains("1"));
   assertTrue(localUserIds.contains("2"));
 }
 @Test
 public void findUserIdWithConnectionMultipleConnectionsToSameProviderUser() {
   insertFacebookConnection();
   insertFacebookConnectionSameFacebookUser();
   List<String> localUserIds =
       usersConnectionRepository.findUserIdsWithConnection(
           connectionRepository.getPrimaryConnection(TestFacebookApi.class));
   assertEquals(2, localUserIds.size());
   assertEquals("1", localUserIds.get(0));
   assertEquals("2", localUserIds.get(1));
 }
  @Before
  public void setUp() {
    socialUserConnectionRepository.deleteAll();

    connectionFactoryRegistry = new ConnectionFactoryRegistry();
    connectionFactory = new TestFacebookConnectionFactory();
    connectionFactoryRegistry.addConnectionFactory(connectionFactory);
    usersConnectionRepository =
        new CustomSocialUsersConnectionRepository(
            socialUserConnectionRepository, connectionFactoryRegistry);
    connectionRepository = usersConnectionRepository.createConnectionRepository("1");
  }
 @Test
 public void findUserIdWithConnectionNoSuchConnection() {
   Connection<TestFacebookApi> connection =
       connectionFactory.createConnection(new AccessGrant("12345"));
   assertEquals(0, usersConnectionRepository.findUserIdsWithConnection(connection).size());
 }