@Test public void testGetUserManagerNullSession() { try { CommonUtils.getUserManager(Mockito.mock(ResourceResolver.class)); fail(); } catch (RepositoryException re) { assertEquals("Failed to get user manager", re.getMessage()); } }
public static final UserManager getUserManager(@NotNull ResourceResolver resolver) throws RepositoryException { return Optional.ofNullable(resolver.adaptTo(Session.class)).map(session -> { UserManager userManager = null; if (session instanceof JackrabbitSession) { try { userManager = ((JackrabbitSession) session).getUserManager(); } catch (RepositoryException e) { log.error("Failed to get user manager", e); } } return userManager; }).orElseThrow(() -> new RepositoryException("Failed to get user manager")); }
CommonUtils { public static final UserManager getUserManager(@NotNull ResourceResolver resolver) throws RepositoryException { return Optional.ofNullable(resolver.adaptTo(Session.class)).map(session -> { UserManager userManager = null; if (session instanceof JackrabbitSession) { try { userManager = ((JackrabbitSession) session).getUserManager(); } catch (RepositoryException e) { log.error("Failed to get user manager", e); } } return userManager; }).orElseThrow(() -> new RepositoryException("Failed to get user manager")); } }
CommonUtils { public static final UserManager getUserManager(@NotNull ResourceResolver resolver) throws RepositoryException { return Optional.ofNullable(resolver.adaptTo(Session.class)).map(session -> { UserManager userManager = null; if (session instanceof JackrabbitSession) { try { userManager = ((JackrabbitSession) session).getUserManager(); } catch (RepositoryException e) { log.error("Failed to get user manager", e); } } return userManager; }).orElseThrow(() -> new RepositoryException("Failed to get user manager")); } private  CommonUtils(); }
CommonUtils { public static final UserManager getUserManager(@NotNull ResourceResolver resolver) throws RepositoryException { return Optional.ofNullable(resolver.adaptTo(Session.class)).map(session -> { UserManager userManager = null; if (session instanceof JackrabbitSession) { try { userManager = ((JackrabbitSession) session).getUserManager(); } catch (RepositoryException e) { log.error("Failed to get user manager", e); } } return userManager; }).orElseThrow(() -> new RepositoryException("Failed to get user manager")); } private  CommonUtils(); static final UserManager getUserManager(@NotNull ResourceResolver resolver); }
CommonUtils { public static final UserManager getUserManager(@NotNull ResourceResolver resolver) throws RepositoryException { return Optional.ofNullable(resolver.adaptTo(Session.class)).map(session -> { UserManager userManager = null; if (session instanceof JackrabbitSession) { try { userManager = ((JackrabbitSession) session).getUserManager(); } catch (RepositoryException e) { log.error("Failed to get user manager", e); } } return userManager; }).orElseThrow(() -> new RepositoryException("Failed to get user manager")); } private  CommonUtils(); static final UserManager getUserManager(@NotNull ResourceResolver resolver);  }