@Test public void tesGetUserStatus() throws UserNotFoundException { when(user.getStatus()).thenReturn(UserStatus.active); when(userManagerAlpha.getUser(PRIMARY_PRINCIPAL)).thenReturn(user); final PrincipalCollection principals = getPrincipals(); assertThat(underTest.getUserStatus(principals), is(UserStatus.active)); }
public UserStatus getUserStatus(final PrincipalCollection principals) throws UserNotFoundException { String userId = null; if (principals != null) { userId = principals.getPrimaryPrincipal().toString(); try { final User user = findUserManager(principals).getUser(userId); if (user != null) { return user.getStatus(); } } catch (final NoSuchUserManagerException e) { throw new UserNotFoundException(userId, e.getMessage(), e); } catch (final UserNotFoundTransientException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } catch (final UserNotFoundException e) { throw e; } catch (final RuntimeException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } } throw new UserNotFoundException(userId); }
UserPrincipalsHelper extends ComponentSupport { public UserStatus getUserStatus(final PrincipalCollection principals) throws UserNotFoundException { String userId = null; if (principals != null) { userId = principals.getPrimaryPrincipal().toString(); try { final User user = findUserManager(principals).getUser(userId); if (user != null) { return user.getStatus(); } } catch (final NoSuchUserManagerException e) { throw new UserNotFoundException(userId, e.getMessage(), e); } catch (final UserNotFoundTransientException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } catch (final UserNotFoundException e) { throw e; } catch (final RuntimeException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } } throw new UserNotFoundException(userId); } }
UserPrincipalsHelper extends ComponentSupport { public UserStatus getUserStatus(final PrincipalCollection principals) throws UserNotFoundException { String userId = null; if (principals != null) { userId = principals.getPrimaryPrincipal().toString(); try { final User user = findUserManager(principals).getUser(userId); if (user != null) { return user.getStatus(); } } catch (final NoSuchUserManagerException e) { throw new UserNotFoundException(userId, e.getMessage(), e); } catch (final UserNotFoundTransientException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } catch (final UserNotFoundException e) { throw e; } catch (final RuntimeException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } } throw new UserNotFoundException(userId); } @Inject  UserPrincipalsHelper(final List<UserManager> userManagers); }
UserPrincipalsHelper extends ComponentSupport { public UserStatus getUserStatus(final PrincipalCollection principals) throws UserNotFoundException { String userId = null; if (principals != null) { userId = principals.getPrimaryPrincipal().toString(); try { final User user = findUserManager(principals).getUser(userId); if (user != null) { return user.getStatus(); } } catch (final NoSuchUserManagerException e) { throw new UserNotFoundException(userId, e.getMessage(), e); } catch (final UserNotFoundTransientException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } catch (final UserNotFoundException e) { throw e; } catch (final RuntimeException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } } throw new UserNotFoundException(userId); } @Inject  UserPrincipalsHelper(final List<UserManager> userManagers); UserStatus getUserStatus(final PrincipalCollection principals); UserManager findUserManager(final PrincipalCollection principals); }
UserPrincipalsHelper extends ComponentSupport { public UserStatus getUserStatus(final PrincipalCollection principals) throws UserNotFoundException { String userId = null; if (principals != null) { userId = principals.getPrimaryPrincipal().toString(); try { final User user = findUserManager(principals).getUser(userId); if (user != null) { return user.getStatus(); } } catch (final NoSuchUserManagerException e) { throw new UserNotFoundException(userId, e.getMessage(), e); } catch (final UserNotFoundTransientException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } catch (final UserNotFoundException e) { throw e; } catch (final RuntimeException e) { log.debug("Ignoring transient user error", e); return UserStatus.disabled; } } throw new UserNotFoundException(userId); } @Inject  UserPrincipalsHelper(final List<UserManager> userManagers); UserStatus getUserStatus(final PrincipalCollection principals); UserManager findUserManager(final PrincipalCollection principals);  }