LocalDiffCache extends DiffCache { @Override public String getChanges(@NotNull RevisionVector from, @NotNull RevisionVector to, @NotNull Path path, @Nullable Loader loader) { RevisionsKey key = new RevisionsKey(from, to); Diff diff = diffCache.getIfPresent(key); if (diff != null) { String result = diff.get(path); return result != null ? result : ""; } if (loader != null) { return loader.call(); } return null; } LocalDiffCache(DocumentNodeStoreBuilder<?> builder); @Override String getChanges(@NotNull RevisionVector from,
                             @NotNull RevisionVector to,
                             @NotNull Path path,
                             @Nullable Loader loader); @NotNull @Override Entry newEntry(final @NotNull RevisionVector from,
                          final @NotNull RevisionVector to,
                          boolean local /*ignored*/); @NotNull @Override Iterable<CacheStats> getStats(); @Override void invalidateAll();  }
@Test public void diffFromAsString() { Map<Path, String> changes = Maps.newHashMap(); changes.put(Path.ROOT, "+\"foo\":{}^\"bar\":{}-\"baz\""); changes.put(Path.fromString("/foo"), ""); changes.put(Path.fromString("/bar"), "+\"qux\""); changes.put(Path.fromString("/bar/qux"), ""); Diff diff = new Diff(changes, 0); assertEquals(changes, Diff.fromString(diff.asString()).getChanges()); }