@Test
 public void findPrimaryConnection_afterRemove() {
   insertFacebookConnection();
   insertFacebookConnection2();
   // 9 is the providerUserId of the first Facebook connection
   connectionRepository.removeConnection(new ConnectionKey("facebook", "9"));
   assertEquals(1, connectionRepository.findConnections(TestFacebookApi.class).size());
   assertNotNull(connectionRepository.findPrimaryConnection(TestFacebookApi.class));
 }
 @Test
 public void findConnectionsByApi() {
   insertFacebookConnection();
   insertFacebookConnection2();
   List<Connection<TestFacebookApi>> connections =
       connectionRepository.findConnections(TestFacebookApi.class);
   assertEquals(2, connections.size());
   assertFacebookConnection(connections.get(0));
 }
 @Test
 @SuppressWarnings("unchecked")
 public void findConnectionsByProviderId() {
   connectionFactoryRegistry.addConnectionFactory(new TestTwitterConnectionFactory());
   insertTwitterConnection();
   List<Connection<?>> connections = connectionRepository.findConnections("twitter");
   assertEquals(1, connections.size());
   assertTwitterConnection((Connection<TestTwitterApi>) connections.get(0));
 }
 @Test
 public void findConnectionsByApiEmptyResult() {
   assertTrue(connectionRepository.findConnections(TestFacebookApi.class).isEmpty());
 }
 @Test
 public void findConnectionsByProviderIdEmptyResult() {
   assertTrue(connectionRepository.findConnections("facebook").isEmpty());
 }