MoveTracker { public void addMove(@NotNull String sourcePath, @NotNull String destPath) { String originalSource = sourcePath; for (MoveEntry me : Lists.reverse(entries)) { if (Text.isDescendantOrEqual(me.destPath, sourcePath)) { String relPath = PathUtils.relativize(me.destPath, sourcePath); if (!relPath.isEmpty()) { originalSource = me.sourcePath + '/' + relPath; } else { originalSource = me.sourcePath; } break; } } entries.add(new MoveEntry(originalSource, destPath)); } MoveTracker(); void addMove(@NotNull String sourcePath, @NotNull String destPath); boolean isEmpty(); @Nullable String getSourcePath(String destPath); @Nullable String getDestPath(String sourcePath); boolean containsMove(@Nullable String path); void clear();  }
@Test public void testMultiMove() { MoveTest test = new MoveTest() .addMove("/a/b/c", "/a/f/c", "/a/b/c") .addMove("/a/f/c/d", "/a/b/d", "/a/b/c/d") .addMove("/a/b/d/e", "/a/f/c/e", "/a/b/c/d/e"); test.assertResult(); }
@Test public void testMultiMove2() { MoveTest test = new MoveTest() .addMove("/a/b/c", "/a/f/c", "/a/b/c") .addMove("/a/f/c/d", "/a/b/d", "/a/b/c/d") .addMove("/a/b/d/e", "/a/f/c/e", "/a/b/c/d/e") .addMove("/a/f/c/e", "/a/f/e", "/a/b/c/d/e"); test.assertResult(); }
@Test public void testMultiMove3() { MoveTest test = new MoveTest() .addMove("/a/b/c", "/a/f/c", "/a/b/c") .addMove("/a/f/c/d", "/a/b/d", "/a/b/c/d") .addMove("/a/b/d/e", "/a/f/c/e", "/a/b/c/d/e") .addMove("/a/f/c/e", "/a/b/c", "/a/b/c/d/e"); test.assertResult(); test.addMove("/a/b/d", "/a/b/c/d", "/a/b/c/d"); test.assertResult(); }
@Test public void testMultiMove4() { MoveTest test = new MoveTest() .addMove("/a/b/c", "/a/f/c", "/a/b/c") .addMove("/a/f/c/d", "/a/b/d", "/a/b/c/d") .addMove("/a/b/d/e", "/a/f/c/e", "/a/b/c/d/e") .addMove("/a/f/c", "/a/b/d/e", "/a/b/c"); test.assertResult(); }
@Test public void testMultiMoveIncludingNewNodes() { MoveTest test = new MoveTest() .addMove("/a/b/c", "/a/f/c", "/a/b/c") .addMove("/a/f/c/d", "/a/b/d", "/a/b/c/d") .addMove("/a/b/d/e", "/a/f/c/e", "/a/b/c/d/e") .addMove("/a/b/d/e", "/a/b/c/d/e", "/a/b/c/d/e"); test.assertResult(); }