DocumentNodeBuilder extends AbstractDocumentNodeBuilder { @Override @NotNull public NodeState getBaseState() { if (base == null || rootBase != root.getBaseState()) { base = getParent().getBaseState().getChildNode(getName()); rootBase = root.getBaseState(); } return base; } DocumentNodeBuilder(MemoryNodeBuilder base,
                        String name,
                        DocumentRootBuilder root); @Override @NotNull NodeState getBaseState(); @Override boolean moveTo(@NotNull NodeBuilder newParent, @NotNull String newName); @Override Blob createBlob(InputStream stream); @Override boolean remove();  }
@Test public void getBaseState() { NodeState state = ns.getRoot(); NodeBuilder builder = state.builder(); assertStateEquals(state, builder.getBaseState()); }
@Test public void getBaseStateFromModifiedBuilder() { NodeState state = ns.getRoot(); NodeBuilder builder = state.builder(); builder.child("foo"); assertStateEquals(state, builder.getBaseState()); }
@Test public void getBaseStateFromModifiedBuilderBranched() { NodeState state = ns.getRoot(); NodeBuilder builder = state.builder(); for (int i = 0; i < UPDATE_LIMIT; i++) { builder.child("c-" + i).setProperty("p", "v"); } assertStateEquals(state, builder.getBaseState()); }
@Test public void getBaseStateFromBuilderFromStateFromModifiedBuilder() { NodeState state = ns.getRoot(); NodeBuilder builder = state.builder(); builder.child("foo"); NodeState modifiedState = builder.getNodeState(); assertStateEquals(modifiedState, modifiedState.builder().getBaseState()); }