@Test(expected = NoUserFoundException.class) public void testTakeSameUserWhileExpectingAnother() { var oAuthUser1 = new OAuthUserImpl(null, TEST_USER_1, TEST_PW, ACCESS_TOKEN, REFRESH_TOKEN, SCOPE, CLIENT_ID, USER_ID, US_REGION ); var userSession = new UserSessionImpl(oAuthUser1); when(repo.take()).thenReturn(userSession, userSession, userSession); var authUserProvider = new OAuthUserProvider(repo); assertThat(authUserProvider.take(userSession.getUser()), not(equalTo(userSession.getUser()))); }
@Override public OAuthUser take() { var user = userSessionRepository.take().getUser(); if (user instanceof OAuthUser) { return (OAuthUser) user; } throw new NoUserFoundException("No OAuth users found in the repository."); }
OAuthUserProvider extends AbstractProvider<OAuthUser> { @Override public OAuthUser take() { var user = userSessionRepository.take().getUser(); if (user instanceof OAuthUser) { return (OAuthUser) user; } throw new NoUserFoundException("No OAuth users found in the repository."); } }
OAuthUserProvider extends AbstractProvider<OAuthUser> { @Override public OAuthUser take() { var user = userSessionRepository.take().getUser(); if (user instanceof OAuthUser) { return (OAuthUser) user; } throw new NoUserFoundException("No OAuth users found in the repository."); } OAuthUserProvider();  OAuthUserProvider(final CyclicUserSessionRepository<UserSession> userSessionRepository); }
OAuthUserProvider extends AbstractProvider<OAuthUser> { @Override public OAuthUser take() { var user = userSessionRepository.take().getUser(); if (user instanceof OAuthUser) { return (OAuthUser) user; } throw new NoUserFoundException("No OAuth users found in the repository."); } OAuthUserProvider();  OAuthUserProvider(final CyclicUserSessionRepository<UserSession> userSessionRepository); @Override OAuthUser take(); OAuthUser take(User excludedUser); @Override String name(); }
OAuthUserProvider extends AbstractProvider<OAuthUser> { @Override public OAuthUser take() { var user = userSessionRepository.take().getUser(); if (user instanceof OAuthUser) { return (OAuthUser) user; } throw new NoUserFoundException("No OAuth users found in the repository."); } OAuthUserProvider();  OAuthUserProvider(final CyclicUserSessionRepository<UserSession> userSessionRepository); @Override OAuthUser take(); OAuthUser take(User excludedUser); @Override String name();  }