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());
}
}
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);
}
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());
}
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());
}
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());
}
Aggregations