CommitBuilder { @NotNull CommitBuilder addNode(@NotNull Path path) { addNode(new DocumentNodeState(nodeStore, path, new RevisionVector(revision))); return this; } CommitBuilder(@NotNull DocumentNodeStore nodeStore,
                  @Nullable RevisionVector baseRevision);   CommitBuilder(@NotNull DocumentNodeStore nodeStore,
                  @NotNull Revision revision,
                  @Nullable RevisionVector baseRevision);   }
@Test public void addNode() { RevisionVector baseRev = ns.getHeadRevision(); Path foo = Path.fromString("/foo"); CommitBuilder builder = new CommitBuilder(ns, baseRev); builder.addNode(foo); Commit c = builder.build(ns.newRevision()); assertNotNull(c); assertFalse(c.isEmpty()); }
@Test public void addNodeTwice() { RevisionVector baseRev = ns.getHeadRevision(); Path foo = Path.fromString("/foo"); CommitBuilder builder = new CommitBuilder(ns, baseRev); builder.addNode(foo); try { builder.addNode(foo); fail("Must fail with DocumentStoreException"); } catch (DocumentStoreException e) { assertThat(e.getMessage(), containsString("already added")); } }
@Test public void addNodePathNull() { CommitBuilder builder = new CommitBuilder(ns, null); try { builder.addNode((Path) null); expectNPE(); } catch (NullPointerException e) { } }
@Test public void addNodeStateNull() { CommitBuilder builder = new CommitBuilder(ns, null); try { builder.addNode((DocumentNodeState) null); expectNPE(); } catch (NullPointerException e) { } }