@Test @SuppressWarnings("unchecked") public void findConnectionsToUsers() { connectionFactoryRegistry.addConnectionFactory(new TestTwitterConnectionFactory()); insertTwitterConnection(); insertFacebookConnection(); insertFacebookConnection2(); MultiValueMap<String, String> providerUsers = new LinkedMultiValueMap<>(); providerUsers.add("facebook", "10"); providerUsers.add("facebook", "9"); providerUsers.add("twitter", "1"); MultiValueMap<String, Connection<?>> connectionsForUsers = connectionRepository.findConnectionsToUsers(providerUsers); assertEquals(2, connectionsForUsers.size()); assertEquals("10", connectionsForUsers.getFirst("facebook").getKey().getProviderUserId()); assertFacebookConnection( (Connection<TestFacebookApi>) connectionsForUsers.get("facebook").get(1)); assertTwitterConnection((Connection<TestTwitterApi>) connectionsForUsers.getFirst("twitter")); }
@Test(expected = IllegalArgumentException.class) public void findConnectionsToUsersEmptyInput() { MultiValueMap<String, String> providerUsers = new LinkedMultiValueMap<>(); connectionRepository.findConnectionsToUsers(providerUsers); }
@Test public void findConnectionsToUsersEmptyResult() { MultiValueMap<String, String> providerUsers = new LinkedMultiValueMap<>(); providerUsers.add("facebook", "1"); assertTrue(connectionRepository.findConnectionsToUsers(providerUsers).isEmpty()); }