ConnectionFactory<TestApi1> connectionFactory = new StubOAuth1ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
connectionFactoryLocator.addConnectionFactory(connectionFactory);
StubConnectionRepository connectionRepository = new StubConnectionRepository();
MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build();
assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());
mockMvc.perform(get("/connect/oauth1Provider")
.sessionAttr("oauthToken", new OAuthToken("requestToken", "requestTokenSecret"))
.param("oauth_token", "requestToken")
.param("oauth_verifier", "verifier"))
.andExpect(redirectedUrl("/connect/oauth1Provider"))
.andExpect(request().sessionAttribute("social_provider_error", notNullValue()));