@Bean
 public UsersConnectionRepository usersConnectionRepository() {
   JdbcUsersConnectionRepository repository =
       new JdbcUsersConnectionRepository(
           dataSource, connectionFactoryLocator(), Encryptors.noOpText());
   repository.setConnectionSignUp(ConnectionSignUp());
   return repository;
 }
Exemple #2
0
 @Override
 public UsersConnectionRepository getUsersConnectionRepository(
     ConnectionFactoryLocator connectionFactoryLocator) {
   JdbcUsersConnectionRepository repository =
       new JdbcUsersConnectionRepository(
           dataSource, connectionFactoryLocator, Encryptors.noOpText());
   repository.setConnectionSignUp(new AccountConnectionSignUpService(usersDao));
   return repository;
 }
 @Test
 public void findUserIdWithConnectionNoConnection_withConnectionSignUpReturningNull() {
   Connection<TestFacebookApi> connection =
       connectionFactory.createConnection(new AccessGrant("12345"));
   usersConnectionRepository.setConnectionSignUp(
       new ConnectionSignUp() {
         public String execute(Connection<?> connection) {
           return null;
         }
       });
   List<String> userIds = usersConnectionRepository.findUserIdsWithConnection(connection);
   assertEquals(0, userIds.size());
 }
  @Override
  public void afterPropertiesSet() throws Exception {

    JdbcUsersConnectionRepository usersConnectionRepositiory =
        new JdbcUsersConnectionRepository(
            dataSource, connectionFactoryLocator(), Encryptors.noOpText());

    socialContext =
        new SocialContext(usersConnectionRepositiory, new UserCookieGenerator(), facebook());

    usersConnectionRepositiory.setConnectionSignUp(socialContext);
    this.usersConnectionRepositiory = usersConnectionRepositiory;
  }
 @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<String>(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() {
   EmbeddedDatabaseFactory factory = new EmbeddedDatabaseFactory();
   if (testMySqlCompatiblity) {
     factory.setDatabaseConfigurer(new MySqlCompatibleH2DatabaseConfigurer());
   } else {
     factory.setDatabaseType(EmbeddedDatabaseType.H2);
   }
   ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
   populator.addScript(new ClassPathResource(getSchemaSql(), getClass()));
   factory.setDatabasePopulator(populator);
   database = factory.getDatabase();
   dataAccessor = new JdbcTemplate(database);
   connectionFactoryRegistry = new ConnectionFactoryRegistry();
   connectionFactory = new TestFacebookConnectionFactory();
   connectionFactoryRegistry.addConnectionFactory(connectionFactory);
   usersConnectionRepository =
       new JdbcUsersConnectionRepository(
           database, connectionFactoryRegistry, Encryptors.noOpText());
   if (!getTablePrefix().equals("")) {
     usersConnectionRepository.setTablePrefix(getTablePrefix());
   }
   connectionRepository = usersConnectionRepository.createConnectionRepository("1");
 }
 @Test
 public void findUserIdWithConnectionNoSuchConnection() {
   Connection<TestFacebookApi> connection =
       connectionFactory.createConnection(new AccessGrant("12345"));
   assertEquals(0, usersConnectionRepository.findUserIdsWithConnection(connection).size());
 }