@Test public void connectionStatus() throws Exception { ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry(); ConnectionFactory<TestApi1> connectionFactory1 = new StubOAuth1ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION); connectionFactoryLocator.addConnectionFactory(connectionFactory1); ConnectionFactory<TestApi2> connectionFactory2 = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION); connectionFactoryLocator.addConnectionFactory(connectionFactory2); StubConnectionRepository connectionRepository = new StubConnectionRepository(); connectionRepository.addConnection(connectionFactory1.createConnection(new ConnectionData("oauth1Provider", "provider1User1", null, null, null, null, null, null, null))); MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build(); mockMvc.perform(get("/connect")) .andExpect(view().name("connect/status")) .andExpect(model().attribute("providerIds", new HashSet<String>(asList("oauth1Provider", "oauth2Provider")))) .andExpect(model().attributeExists("connectionMap")); mockMvc.perform(get("/connect/oauth1Provider")) .andExpect(view().name("connect/oauth1ProviderConnected")) .andExpect(model().attributeExists("connections")) .andExpect(request().attribute("social.addConnection.duplicate", nullValue())) .andExpect(request().attribute("social.provider.error", nullValue())); mockMvc.perform(get("/connect/oauth2Provider")) .andExpect(view().name("connect/oauth2ProviderConnect")) .andExpect(request().attribute("social.addConnection.duplicate", nullValue())) .andExpect(request().attribute("social.provider.error", nullValue())); }
@RequestMapping(method=RequestMethod.GET) public String connectionStatus(NativeWebRequest request, Model model) { setNoCache(request); processFlash(request, model); Map<String, List<Connection<?>>> connections = connectionRepository.findAllConnections(); model.addAttribute("providerIds", connectionFactoryLocator.registeredProviderIds()); model.addAttribute("connectionMap", connections); return connectView(); }
ConnectController implements InitializingBean { @RequestMapping(method=RequestMethod.GET) public String connectionStatus(NativeWebRequest request, Model model) { setNoCache(request); processFlash(request, model); Map<String, List<Connection<?>>> connections = connectionRepository.findAllConnections(); model.addAttribute("providerIds", connectionFactoryLocator.registeredProviderIds()); model.addAttribute("connectionMap", connections); return connectView(); } }
ConnectController implements InitializingBean { @RequestMapping(method=RequestMethod.GET) public String connectionStatus(NativeWebRequest request, Model model) { setNoCache(request); processFlash(request, model); Map<String, List<Connection<?>>> connections = connectionRepository.findAllConnections(); model.addAttribute("providerIds", connectionFactoryLocator.registeredProviderIds()); model.addAttribute("connectionMap", connections); return connectView(); } @Inject  ConnectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository); }
ConnectController implements InitializingBean { @RequestMapping(method=RequestMethod.GET) public String connectionStatus(NativeWebRequest request, Model model) { setNoCache(request); processFlash(request, model); Map<String, List<Connection<?>>> connections = connectionRepository.findAllConnections(); model.addAttribute("providerIds", connectionFactoryLocator.registeredProviderIds()); model.addAttribute("connectionMap", connections); return connectView(); } @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(); }
ConnectController implements InitializingBean { @RequestMapping(method=RequestMethod.GET) public String connectionStatus(NativeWebRequest request, Model model) { setNoCache(request); processFlash(request, model); Map<String, List<Connection<?>>> connections = connectionRepository.findAllConnections(); model.addAttribute("providerIds", connectionFactoryLocator.registeredProviderIds()); model.addAttribute("connectionMap", connections); return connectView(); } @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();  }