UserUtil implements UserConstants { @Nullable public static AuthorizableType getType(@NotNull Tree authorizableNode) { String ntName = TreeUtil.getPrimaryTypeName(authorizableNode); return getType(ntName); } private  UserUtil(); static boolean isAdmin(@NotNull ConfigurationParameters parameters, @NotNull String userId); @NotNull static String getAdminId(@NotNull ConfigurationParameters parameters); @NotNull static String getAnonymousId(@NotNull ConfigurationParameters parameters); static boolean isType(@Nullable Tree authorizableTree, @NotNull AuthorizableType type); @Nullable static AuthorizableType getType(@NotNull Tree authorizableNode); @Nullable static AuthorizableType getType(@Nullable String primaryTypeName); static boolean isSystemUser(@Nullable Tree authorizableTree); @Nullable static String getAuthorizableRootPath(@NotNull ConfigurationParameters parameters,
                                                 @Nullable AuthorizableType type); @Nullable static String getAuthorizableId(@NotNull Tree authorizableTree); @NotNull static String getAuthorizableId(@NotNull Tree authorizableTree, @NotNull AuthorizableType type); @Nullable static T castAuthorizable(@Nullable Authorizable authorizable, Class<T> authorizableClass); static int getImportBehavior(@NotNull ConfigurationParameters config);  }
@Test public void testGetTypeFromTree() { Map<String, AuthorizableType> test = ImmutableMap.of( UserConstants.NT_REP_GROUP, AuthorizableType.GROUP, UserConstants.NT_REP_USER, AuthorizableType.USER, UserConstants.NT_REP_SYSTEM_USER, AuthorizableType.USER ); for (String ntName : test.keySet()) { AuthorizableType expected = test.get(ntName); assertEquals(ntName, expected, UserUtil.getType(createTree(ntName))); } }
@Test public void testGetTypeFromTree2() { List<String> test = ImmutableList.of( UserConstants.NT_REP_AUTHORIZABLE, JcrConstants.NT_FILE ); for (String ntName : test) { assertNull(UserUtil.getType(createTree(ntName))); } }
@Test public void testGetTypeFromNt() { assertEquals(AuthorizableType.GROUP, UserUtil.getType(UserConstants.NT_REP_GROUP)); assertEquals(AuthorizableType.USER, UserUtil.getType(UserConstants.NT_REP_USER)); assertEquals(AuthorizableType.USER, UserUtil.getType(UserConstants.NT_REP_SYSTEM_USER)); }
@Test public void testGetTypeFromNtReturnsNull() { assertNull(UserUtil.getType(UserConstants.NT_REP_AUTHORIZABLE)); assertNull(UserUtil.getType(JcrConstants.NT_FILE)); assertNull(UserUtil.getType((String) null)); assertNull(UserUtil.getType("")); }