}
@Test
public void beforeCommitHook() throws CommitFailedException {
NodeState root = store.getRoot();
NodeStateBuilder rootBuilder = store.getBuilder(root);
NodeState test = root.getChildNode("test");
NodeStateBuilder testBuilder = store.getBuilder(test);
NodeStateBuilder newNodeBuilder = store.getBuilder(MemoryNodeState.EMPTY_NODE);
final CoreValue fortyTwo = store.getValueFactory().createValue(42);
newNodeBuilder.setProperty("n", fortyTwo);
testBuilder.setNode("newNode", newNodeBuilder.getNodeState());
testBuilder.removeNode("a");
rootBuilder.setNode("test", testBuilder.getNodeState());
final NodeState newRoot = rootBuilder.getNodeState();
commitWithEditor(newRoot, new EmptyEditor() {
@Override
public NodeState editCommit(NodeStore store, NodeState before, NodeState after) {
NodeStateBuilder rootBuilder = store.getBuilder(after);
NodeStateBuilder testBuilder = store.getBuilder(after.getChildNode("test"));
testBuilder.setNode("fromHook", MemoryNodeState.EMPTY_NODE);
rootBuilder.setNode("test", testBuilder.getNodeState());
return rootBuilder.getNodeState();
}
});
test = store.getRoot().getChildNode("test");