@Test
public void oauth2Callback_multipleMatchingUsers() throws Exception {
ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
connectionFactoryLocator.addConnectionFactory(connectionFactory2);
StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository(asList("testuser1", "testuser2"));
ProviderSignInController providerSignInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, null);
providerSignInController.afterPropertiesSet();
MockMvc mockMvc = standaloneSetup(providerSignInController).build();
mockMvc.perform(get("/signin/oauth2Provider").param("code", "authcode"))
.andExpect(redirectedUrl("/signin?error=multiple_users"));