Refine search
private String getValue(String oakName, Type<String> type) { PropertyState property = definition.getProperty(checkNotNull(oakName)); if (property != null) { return property.getValue(type); } else { return null; } }
@Test public void testGetProperty() { Tree a = root.getTree("/a"); for (String propName : hiddenProps) { assertNull(a.getProperty(propName)); } }
@Test public void testContentRepresentation() throws Exception { Tree tree = root.getTree(user.getPath()); PropertyState property = tree.getProperty(UserConstants.REP_IMPERSONATORS); assertNotNull(property); assertEquals(ImmutableList.of(impersonator.getPrincipal().getName()), property.getValue(Type.STRINGS)); }
@Test public void testMixedImpersonators() throws Exception { assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, "impersonator1", testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); assertEquals(ImmutableSet.of("impersonator1", testUser.getPrincipal().getName()), ImmutableSet.copyOf(impersonators.getValue(Type.STRINGS))); } }
@Test public void testGetProperty() { Tree a = root.getTree("/a"); assertNull(a.getProperty(TreeConstants.OAK_CHILD_ORDER)); }
/** * Returns the boolean value of the named property. * * @param name property name * @return property value, or {@code false} if the property does not exist */ protected boolean getBoolean(@NotNull String name) { PropertyState property = definition.getProperty(checkNotNull(name)); return property != null && property.getValue(Type.BOOLEAN); }
@Test public void getProperty() { Tree tree = root.getTree("/"); PropertyState propertyState = tree.getProperty("any"); assertNull(propertyState); propertyState = tree.getProperty("a"); assertNotNull(propertyState); assertFalse(propertyState.isArray()); assertEquals(LONG, propertyState.getType()); assertEquals(1, (long) propertyState.getValue(LONG)); }
@Test public void testGetInstanceFromTreeCustomPriv() { PrivilegeBits next = PrivilegeBits.NEXT_AFTER_BUILT_INS; Tree tmp = Mockito.mock(Tree.class); when(tmp.getName()).thenReturn("tmpPrivilege"); when(tmp.getProperty(REP_BITS)).thenReturn(next.asPropertyState(REP_BITS)); assertEquals(next, PrivilegeBits.getInstance(tmp)); }
@Nullable public static Iterable<String> getStrings(@NotNull Tree tree, @NotNull String propertyName) { PropertyState property = tree.getProperty(propertyName); if (property == null) { return null; } else { return property.getValue(STRINGS); } }
@Test public void testJcrCreatedBy() throws Exception { Tree tree = TreeUtil.addChild(root.getTree("/"), "test", JcrConstants.NT_FOLDER, root.getTree(NodeTypeConstants.NODE_TYPES_PATH), "userId"); PropertyState ps = tree.getProperty(NodeTypeConstants.JCR_CREATEDBY); assertNotNull(ps); assertEquals("userId", ps.getValue(Type.STRING)); }
@Test public void testCanReadPropertyAceNode2() throws Exception { Tree aceTree = root.getTree(REPO_POLICY_PATH).getChildren().iterator().next(); PropertyState principalProp = aceTree.getProperty(REP_PRINCIPAL_NAME); TreePermission tp = getTreePermission(noAccessSession, aceTree.getPath()); assertFalse(tp.canRead(principalProp)); }
@CheckForNull public static Iterable<String> getStrings(@Nonnull Tree tree, @Nonnull String propertyName) { PropertyState property = tree.getProperty(propertyName); if (property == null) { return null; } else { return property.getValue(STRINGS); } }
@Test public void testJcrCreatedByNullUserId() throws Exception { Tree tree = TreeUtil.addChild(root.getTree("/"), "test", JcrConstants.NT_FOLDER, root.getTree(NodeTypeConstants.NODE_TYPES_PATH), null); PropertyState ps = tree.getProperty(NodeTypeConstants.JCR_CREATEDBY); assertNotNull(ps); assertEquals("", ps.getValue(Type.STRING)); }
@Test public void testCanReadPropertyAceNode() throws Exception { Tree aceTree = root.getTree(REPO_POLICY_PATH).getChildren().iterator().next(); PropertyState principalProp = aceTree.getProperty(REP_PRINCIPAL_NAME); TreePermission tp = getTreePermission(accessSession, aceTree.getPath()); assertTrue(tp.canRead(principalProp)); }
@NotNull private Set<String> getImpersonatorNames(@NotNull Tree userTree) { Set<String> princNames = new HashSet<>(); PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); if (impersonators != null) { for (String v : impersonators.getValue(STRINGS)) { princNames.add(v); } } return princNames; }
@Test public void testAddMemberToNonExistingMember() throws Exception { groupTree.setProperty(REP_MEMBERS, ImmutableList.of(unknownContentId), Type.STRINGS); assertTrue(importer.handlePropInfo(groupTree, createPropInfo(REP_MEMBERS, knownMemberContentId), mockPropertyDefinition(NT_REP_GROUP, true))); importer.processReferences(); PropertyState members = groupTree.getProperty(REP_MEMBERS); assertNotNull(members); assertEquals(ImmutableSet.of(unknownContentId, knownMemberContentId), ImmutableSet.copyOf(members.getValue(Type.STRINGS))); }
@Test public void testHandleAuthorizableIdMvPropertyDef() throws Exception { init(); Tree userTree = createUserTree(); assertFalse(importer.handlePropInfo(userTree, createPropInfo(REP_AUTHORIZABLE_ID, TEST_USER_ID), mockPropertyDefinition(NT_REP_AUTHORIZABLE, true))); assertNull(userTree.getProperty(REP_AUTHORIZABLE_ID)); }
private Iterable<String> getNSData(String name) { PropertyState property = nsdata.getProperty(name); if (property != null && property.getType() == STRINGS) { return property.getValue(STRINGS); } else { return emptyList(); } }
@Test public void testReplaceExistingProperty() throws Exception { userTree.setProperty(REP_IMPERSONATORS, ImmutableList.of("impersonator1"), Type.STRINGS); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); }
@Test public void testHandleImpersonatorsSinglePropertyDef() throws Exception { init(); Tree userTree = createUserTree(); assertFalse(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, "impersonator1"), mockPropertyDefinition(NT_REP_USER, false))); assertNull(userTree.getProperty(REP_IMPERSONATORS)); }