@Test void existsWhenNoUserManager() throws Exception { when(this.contextComponentManager.getInstance(UserManager.class, TestUserReference.class.getName())) .thenThrow(new ComponentLookupException("error")); Throwable exception = assertThrows(RuntimeException.class, () -> { this.userManager.exists(new TestUserReference()); }); assertEquals("Failed to find user manager for role [org.xwiki.user.UserManager] and hint " + "[org.xwiki.user.internal.DefaultUserManagerTest$TestUserReference]", exception.getMessage()); assertEquals("ComponentLookupException: error", ExceptionUtils.getRootCauseMessage(exception)); }
@Override public boolean exists(UserReference userReference) { boolean exists; UserReference normalizedUserReference = userReference; if (normalizedUserReference == null) { normalizedUserReference = CurrentUserReference.INSTANCE; } if (GuestUserReference.INSTANCE == normalizedUserReference || SuperAdminUserReference.INSTANCE == normalizedUserReference) { exists = false; } else { exists = resolveUserManager(normalizedUserReference).exists(normalizedUserReference); } return exists; }
DefaultUserManager implements UserManager { @Override public boolean exists(UserReference userReference) { boolean exists; UserReference normalizedUserReference = userReference; if (normalizedUserReference == null) { normalizedUserReference = CurrentUserReference.INSTANCE; } if (GuestUserReference.INSTANCE == normalizedUserReference || SuperAdminUserReference.INSTANCE == normalizedUserReference) { exists = false; } else { exists = resolveUserManager(normalizedUserReference).exists(normalizedUserReference); } return exists; } }
DefaultUserManager implements UserManager { @Override public boolean exists(UserReference userReference) { boolean exists; UserReference normalizedUserReference = userReference; if (normalizedUserReference == null) { normalizedUserReference = CurrentUserReference.INSTANCE; } if (GuestUserReference.INSTANCE == normalizedUserReference || SuperAdminUserReference.INSTANCE == normalizedUserReference) { exists = false; } else { exists = resolveUserManager(normalizedUserReference).exists(normalizedUserReference); } return exists; }  }
DefaultUserManager implements UserManager { @Override public boolean exists(UserReference userReference) { boolean exists; UserReference normalizedUserReference = userReference; if (normalizedUserReference == null) { normalizedUserReference = CurrentUserReference.INSTANCE; } if (GuestUserReference.INSTANCE == normalizedUserReference || SuperAdminUserReference.INSTANCE == normalizedUserReference) { exists = false; } else { exists = resolveUserManager(normalizedUserReference).exists(normalizedUserReference); } return exists; }  @Override boolean exists(UserReference userReference); }
DefaultUserManager implements UserManager { @Override public boolean exists(UserReference userReference) { boolean exists; UserReference normalizedUserReference = userReference; if (normalizedUserReference == null) { normalizedUserReference = CurrentUserReference.INSTANCE; } if (GuestUserReference.INSTANCE == normalizedUserReference || SuperAdminUserReference.INSTANCE == normalizedUserReference) { exists = false; } else { exists = resolveUserManager(normalizedUserReference).exists(normalizedUserReference); } return exists; }  @Override boolean exists(UserReference userReference);  }