store.getRoot().getChildNode("test").getProperty("any"));
}
@Test
public void branch() throws CommitFailedException {
NodeStoreBranch branch = store.branch();
NodeStateBuilder rootBuilder = store.getBuilder(branch.getRoot());
NodeStateBuilder testBuilder = store.getBuilder(root.getChildNode("test"));
testBuilder.setNode("newNode", MemoryNodeState.EMPTY_NODE);
testBuilder.removeNode("x");
NodeStateBuilder newNodeBuilder = store.getBuilder(
testBuilder.getNodeState().getChildNode("newNode"));
CoreValue fortyTwo = store.getValueFactory().createValue(42);
newNodeBuilder.setProperty("n", fortyTwo);
testBuilder.setNode("newNode", newNodeBuilder.getNodeState());
rootBuilder.setNode("test", testBuilder.getNodeState());
// Assert changes are present in the builder
NodeState testState = rootBuilder.getNodeState().getChildNode("test");
assertNotNull(testState.getChildNode("newNode"));
assertNull(testState.getChildNode("x"));
assertEquals(fortyTwo, testState.getChildNode("newNode").getProperty("n").getValue());
// Assert changes are not yet present in the branch
testState = branch.getRoot().getChildNode("test");
assertNull(testState.getChildNode("newNode"));
assertNotNull(testState.getChildNode("x"));
branch.setRoot(rootBuilder.getNodeState());
// Assert changes are present in the branch
testState = branch.getRoot().getChildNode("test");
assertNotNull(testState.getChildNode("newNode"));
assertNull(testState.getChildNode("x"));
assertEquals(fortyTwo, testState.getChildNode("newNode").getProperty("n").getValue());
// Assert changes are not yet present in the trunk
testState = store.getRoot().getChildNode("test");
assertNull(testState.getChildNode("newNode"));
assertNotNull(testState.getChildNode("x"));
branch.merge();
// Assert changes are present in the trunk
testState = store.getRoot().getChildNode("test");
assertNotNull(testState.getChildNode("newNode"));
assertNull(testState.getChildNode("x"));