public class InverseRenamingEditorTest extends TestCase {
public void testEdit() throws Exception {
AppContextForTesting.initForTest();
IMocksControl control = EasyMock.createControl();
FileSystem mockFs = control.createMock(FileSystem.class);
AppContext.RUN.fileSystem = mockFs;
ProjectContext context = ProjectContext.builder().build();
InverseRenamingEditor inverseRenamey = new InverseRenamingEditor(
new RenamingEditor(
"renamey", ImmutableMap.of("internal_root", "public_root"), false /*useRegex*/));
Codebase input = new Codebase(new File("/input"), "public", new RepositoryExpression("input"));
Codebase destination =
new Codebase(new File("/destination"), "public", new RepositoryExpression("destination"));
expect(mockFs.getTemporaryDirectory("inverse_rename_run_")).andReturn(new File("/output"));
expect(mockFs.findFiles(new File("/input"))).andReturn(ImmutableSet.of(
new File("/input/toplevel.txt"),
new File("/input/public_root/1.txt"),
new File("/input/public_root/new.txt"),
new File("/input/public_root/inner1/inner2/innernew.txt")));
expect(mockFs.findFiles(new File("/destination"))).andReturn(ImmutableSet.of(
new File("/destination/internal_root/1.txt")));
expectCopy(mockFs, "/input/toplevel.txt", "/output/toplevel.txt");
expectCopy(mockFs, "/input/public_root/1.txt", "/output/internal_root/1.txt");
expectCopy(mockFs, "/input/public_root/new.txt", "/output/internal_root/new.txt");