use of org.apache.jackrabbit.core.state.ChangeLog in project jackrabbit by apache.
the class PersistenceManagerTest method assertCreateUpdateDelete.
private void assertCreateUpdateDelete(PersistenceManager manager) throws Exception {
NodeState node = new NodeState(NODE_ID, TEST, RepositoryImpl.ROOT_NODE_ID, ItemState.STATUS_NEW, true);
node.addChildNodeEntry(TEST, CHILD_ID);
node.addPropertyName(NameConstants.JCR_PRIMARYTYPE);
node.addPropertyName(TEST);
NodeState child = new NodeState(CHILD_ID, TEST, NODE_ID, ItemState.STATUS_NEW, true);
child.addPropertyName(NameConstants.JCR_PRIMARYTYPE);
PropertyState property = new PropertyState(PROPERTY_ID, ItemState.STATUS_NEW, true);
property.setType(PropertyType.REFERENCE);
property.setValues(new InternalValue[] { InternalValue.create(CHILD_ID) });
NodeReferences references = new NodeReferences(CHILD_ID);
references.addReference(PROPERTY_ID);
ChangeLog create = new ChangeLog();
create.added(node);
create.added(child);
create.added(property);
create.modified(references);
manager.store(create);
assertTrue(manager.exists(NODE_ID));
assertTrue(manager.exists(CHILD_ID));
assertTrue(manager.exists(PROPERTY_ID));
assertTrue(manager.existsReferencesTo(CHILD_ID));
assertEquals(node, manager.load(NODE_ID));
assertEquals(child, manager.load(CHILD_ID));
assertEquals(property, manager.load(PROPERTY_ID));
assertEquals(references, manager.loadReferencesTo(CHILD_ID));
references.removeReference(PROPERTY_ID);
node.setStatus(ItemState.STATUS_EXISTING);
ChangeLog update = new ChangeLog();
update.modified(references);
node.removePropertyName(TEST);
update.deleted(property);
update.modified(node);
manager.store(update);
assertTrue(manager.exists(NODE_ID));
assertTrue(manager.exists(CHILD_ID));
assertFalse(manager.exists(PROPERTY_ID));
assertFalse(manager.existsReferencesTo(CHILD_ID));
assertEquals(node, manager.load(NODE_ID));
assertEquals(child, manager.load(CHILD_ID));
ChangeLog delete = new ChangeLog();
delete.deleted(child);
delete.deleted(node);
manager.store(delete);
assertFalse(manager.exists(NODE_ID));
assertFalse(manager.exists(CHILD_ID));
assertFalse(manager.exists(PROPERTY_ID));
assertFalse(manager.existsReferencesTo(CHILD_ID));
}
Aggregations