LoggingHook implements CommitHook, NodeStateDiff { @Override public boolean propertyAdded(PropertyState after) { writer.accept("p+ " + toString(after)); return true; } private  LoggingHook(final Consumer<String> writer); void enter(NodeState before, NodeState after); void leave(NodeState before, NodeState after); @Override boolean propertyAdded(PropertyState after); @Override boolean propertyChanged(PropertyState before, PropertyState after); @Override boolean propertyDeleted(PropertyState before); @Override boolean childNodeAdded(String name, NodeState after); @Override boolean childNodeChanged(String name, NodeState before, NodeState after); @Override boolean childNodeDeleted(String name, NodeState before); @NotNull @Override NodeState processCommit(NodeState before, NodeState after, CommitInfo info);  }
@Test public void testPropertyAdded() throws Exception { assertCommitProduces( lines( "p+ a+string <STRING> = a+string/slash:colon%25percent%24dollar%5Cbackslash%0Anewline", "n!" ), root -> root.setProperty("a string", "a string/slash:colon%percent$dollar\\backslash\nnewline") ); assertCommitProduces( lines( "p+ strings <STRINGS> = [a+string,another+string]", "n!" ), root -> root.setProperty("strings", Arrays.asList("a string", "another string"), STRINGS) ); assertCommitProduces( lines( "p+ a+long <LONG> = 42", "n!" ), root -> root.setProperty("a long", 42L) ); assertCommitProduces( lines( "p+ longs <LONGS> = [42,99]", "n!" ), root -> root.setProperty("longs", Arrays.asList(42L, 99L), LONGS) ); assertCommitProduces( lines( "p+ an+int <LONG> = 42", "n!" ), root -> root.setProperty("an int", 42) ); assertCommitProduces( lines( "p+ a+date <DATE> = Jan+02+01:00:00+CET+1970", "n!" ), root -> root.setProperty("a date", "Jan 02 01:00:00 CET 1970", DATE) ); assertCommitProduces( lines( "p+ a+binary <BINARY> = 68656C6C6F", "n!" ), root -> root.setProperty("a binary", "hello".getBytes()) ); }