### Question:
ConnectController implements InitializingBean { @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="error") public RedirectView oauth2ErrorCallback(@PathVariable String providerId, @RequestParam("error") String error, @RequestParam(value="error_description", required=false) String errorDescription, @RequestParam(value="error_uri", required=false) String errorUri, NativeWebRequest request) { Map<String, String> errorMap = new HashMap<String, String>(); errorMap.put("error", error); if (errorDescription != null) { errorMap.put("errorDescription", errorDescription); } if (errorUri != null) { errorMap.put("errorUri", errorUri); } sessionStrategy.setAttribute(request, AUTHORIZATION_ERROR_ATTRIBUTE, errorMap); return connectionStatusRedirect(providerId, request); } @Inject  ConnectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository); @Deprecated void setInterceptors(List<ConnectInterceptor<?>> interceptors); void setConnectInterceptors(List<ConnectInterceptor<?>> interceptors); void setDisconnectInterceptors(List<DisconnectInterceptor<?>> interceptors); void setApplicationUrl(String applicationUrl); void setViewPath(String viewPath); void setConnectionStatusUrlPath(String connectionStatusUrlPath); void setSessionStrategy(SessionStrategy sessionStrategy); void addInterceptor(ConnectInterceptor<?> interceptor); void addDisconnectInterceptor(DisconnectInterceptor<?> interceptor); @RequestMapping(method=RequestMethod.GET) String connectionStatus(NativeWebRequest request, Model model); @RequestMapping(value="/{providerId}", method=RequestMethod.GET) String connectionStatus(@PathVariable String providerId, NativeWebRequest request, Model model); @RequestMapping(value="/{providerId}", method=RequestMethod.POST) RedirectView connect(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="oauth_token") RedirectView oauth1Callback(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="code") RedirectView oauth2Callback(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.GET, params="error") RedirectView oauth2ErrorCallback(@PathVariable String providerId, 
			@RequestParam("error") String error, 
			@RequestParam(value="error_description", required=false) String errorDescription,
			@RequestParam(value="error_uri", required=false) String errorUri,
			NativeWebRequest request); @RequestMapping(value="/{providerId}", method=RequestMethod.DELETE) RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request); @RequestMapping(value="/{providerId}/{providerUserId}", method=RequestMethod.DELETE) RedirectView removeConnection(@PathVariable String providerId, @PathVariable String providerUserId, NativeWebRequest request); void afterPropertiesSet();  }### Answer:
@Test public void oauth2ErrorCallback() throws Exception { ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry(); ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("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()); HashMap<String, String> expectedError = new HashMap<String, String>(); expectedError.put("error", "access_denied"); expectedError.put("errorDescription", "The user said no."); expectedError.put("errorUri", "https: mockMvc.perform(get("/connect/oauth2Provider").param("error", "access_denied") .param("error_description", "The user said no.") .param("error_uri", "https: .andExpect(redirectedUrl("/connect/oauth2Provider")) .andExpect(request().sessionAttribute("social_authorization_error", notNullValue())) .andExpect(request().sessionAttribute("social_authorization_error", expectedError)); }