Search in sources :

Example 46 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class TypeEditorTest method addMandatoryPropertyWithBadRequiredType.

@Test
public void addMandatoryPropertyWithBadRequiredType() {
    EditorHook hook = new EditorHook(new TypeEditorProvider());
    NodeState root = INITIAL_CONTENT;
    NodeBuilder builder = root.builder();
    NodeState before = builder.getNodeState();
    NodeBuilder acl = builder.child(AccessControlConstants.REP_POLICY);
    acl.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_ACL, Type.NAME);
    NodeBuilder ace = acl.child("first");
    ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME);
    ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME);
    ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS);
    try {
        hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
        fail();
    } catch (CommitFailedException e) {
        assertTrue(e.isConstraintViolation());
        assertEquals(55, e.getCode());
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) Test(org.junit.Test)

Example 47 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class NodeObserverTest method changeNode.

@Test
public void changeNode() {
    NodeBuilder builder = before.builder();
    builder.getChildNode("m").getChildNode("n").setProperty("p", 42);
    nodeObserver.contentChanged(builder.getNodeState(), CommitInfo.EMPTY);
    assertTrue(nodeObserver.added.isEmpty());
    assertTrue(nodeObserver.deleted.isEmpty());
    assertEquals(ImmutableMap.of("/m/n", ImmutableSet.of("p")), nodeObserver.changed);
    assertEquals(ImmutableMap.of("/m/n", ImmutableMap.of("extra", "42")), nodeObserver.properties);
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 48 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class NodeObserverTest method ignoreAdd.

@Test
public void ignoreAdd() {
    NodeBuilder builder = before.builder();
    builder.getChildNode("a").getChildNode("b").setChildNode("new").setProperty("p", "3");
    nodeObserver.contentChanged(builder.getNodeState(), CommitInfo.EMPTY);
    assertTrue(nodeObserver.added.isEmpty());
    assertTrue(nodeObserver.deleted.isEmpty());
    assertTrue(nodeObserver.changed.isEmpty());
    assertTrue(nodeObserver.properties.isEmpty());
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 49 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class NodeObserverTest method ignoreDelete.

@Test
public void ignoreDelete() {
    NodeBuilder builder = before.builder();
    builder.getChildNode("a").getChildNode("b").remove();
    nodeObserver.contentChanged(builder.getNodeState(), CommitInfo.EMPTY);
    assertTrue(nodeObserver.added.isEmpty());
    assertTrue(nodeObserver.deleted.isEmpty());
    assertTrue(nodeObserver.changed.isEmpty());
    assertTrue(nodeObserver.properties.isEmpty());
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 50 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class NodeObserverTest method addNode.

@Test
public void addNode() {
    NodeBuilder builder = before.builder();
    builder.getChildNode("m").getChildNode("n").setChildNode("new").setProperty("p", "3");
    nodeObserver.contentChanged(builder.getNodeState(), CommitInfo.EMPTY);
    assertEquals(ImmutableMap.of("/m/n/new", ImmutableSet.of("p")), nodeObserver.added);
    assertTrue(nodeObserver.deleted.isEmpty());
    assertTrue(nodeObserver.changed.isEmpty());
    assertTrue(nodeObserver.properties.isEmpty());
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Aggregations

NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1190 Test (org.junit.Test)849 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)338 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)96 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)82 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)80 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)77 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)75 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)73 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)69 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)64 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)61 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)43 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)40 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)38 Blob (org.apache.jackrabbit.oak.api.Blob)36 ArrayList (java.util.ArrayList)29 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)29 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)28 Nonnull (javax.annotation.Nonnull)26