use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class TypeEditorTest method addNamedPropertyWithBadRequiredType.
@Test
public void addNamedPropertyWithBadRequiredType() {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeState before = builder.getNodeState();
NodeBuilder testNode = builder.child("testNode");
testNode.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME);
testNode.setProperty(JCR_MIXINTYPES, ImmutableList.of("mix:title"), Type.NAMES);
testNode.setProperty("jcr:title", true);
try {
hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
fail();
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class TypeEditorTest method requiredTypeIsUndefined.
@Test
public void requiredTypeIsUndefined() throws CommitFailedException {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeState before = builder.getNodeState();
builder.setProperty("any", "title");
NodeState after = builder.getNodeState();
hook.processCommit(before, after, CommitInfo.EMPTY);
builder.setProperty("any", 134.34, Type.DOUBLE);
hook.processCommit(after, builder.getNodeState(), CommitInfo.EMPTY);
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class TypeEditorTest method malformedUUID.
@Test
public void malformedUUID() throws CommitFailedException {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeState before = builder.getNodeState();
builder.child("testcontent").setProperty(JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME);
builder.child("testcontent").setProperty("jcr:uuid", "not-a-uuid");
NodeState after = builder.getNodeState();
root = hook.processCommit(before, after, CommitInfo.EMPTY);
builder = root.builder();
before = builder.getNodeState();
builder.child("testcontent").setProperty(JCR_MIXINTYPES, ImmutableList.of(MIX_REFERENCEABLE), Type.NAMES);
try {
hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
fail("should not be able to change mixin due to illegal uuid format");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class TypeEditorTest method changeNodeTypeWExtraProps.
@Test
public void changeNodeTypeWExtraProps() throws CommitFailedException {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeState before = builder.getNodeState();
builder.child("testcontent").setProperty(JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME);
builder.child("testcontent").setProperty("extra", "information");
NodeState after = builder.getNodeState();
root = hook.processCommit(before, after, CommitInfo.EMPTY);
builder = root.builder();
before = builder.getNodeState();
builder.child("testcontent").setProperty(JCR_PRIMARYTYPE, "nt:folder", Type.NAME);
try {
hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
fail("should not be able to change node type due to extra properties");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.
the class TypeEditorTest method changeNamedPropertyToBadRequiredType.
@Test
public void changeNamedPropertyToBadRequiredType() {
EditorHook hook = new EditorHook(new TypeEditorProvider());
NodeState root = INITIAL_CONTENT;
NodeBuilder builder = root.builder();
NodeBuilder testNode = builder.child("testNode");
testNode.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME);
testNode.setProperty(JCR_MIXINTYPES, ImmutableList.of("mix:title"), Type.NAMES);
testNode.setProperty("jcr:title", "title");
NodeState before = builder.getNodeState();
testNode.setProperty("jcr:title", true);
try {
hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
fail();
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
}
}
Aggregations