@Test void curateFile_addTgt_moveSrc_deleteSrc() { SimplePendingActionFactory actionFactory = new SimplePendingActionFactory(REF_A1); PendingActionCurator curator = new PendingActionCurator(actionFactory); Map<String, MockVirtualFile> fs = MockVirtualFileSystem.createTree( "a.txt", "abc", "b.txt", "def" ); MockVirtualFile src = fs.get("a.txt"); MockVirtualFile tgt = fs.get("b.txt"); List<ActionStore.PendingAction> actions = new ArrayList<>(); P4ChangelistIdImpl cl1 = new P4ChangelistIdImpl(100, REF_A1); P4ChangelistIdImpl cl2 = new P4ChangelistIdImpl(100, REF_A1); ActionStore.PendingAction addFile = ActionStore.createPendingAction(REF_A1, new AddEditAction(tgt.asFilePath(), null, cl1, (String) null)); actions.add(addFile); ActionStore.PendingAction moveFile = ActionStore.createPendingAction(REF_A1, new MoveFileAction(src.asFilePath(), tgt.asFilePath(), cl1)); actions.add(moveFile); ActionStore.PendingAction deleteFile = ActionStore.createPendingAction(REF_A1, new DeleteFileAction(src.asFilePath(), cl2)); curator.curateActionList(deleteFile, actions); assertSize(0, actionFactory.created); assertContainsExactly(actions, addFile, moveFile); }
@Test void curateFile_move_deleteTgt() { SimplePendingActionFactory actionFactory = new SimplePendingActionFactory(REF_A1); PendingActionCurator curator = new PendingActionCurator(actionFactory); Map<String, MockVirtualFile> fs = MockVirtualFileSystem.createTree( "a.txt", "abc", "b.txt", "def" ); MockVirtualFile srcFile = fs.get("a.txt"); MockVirtualFile tgtFile = fs.get("b.txt"); List<ActionStore.PendingAction> actions = new ArrayList<>(); P4ChangelistIdImpl cl1 = new P4ChangelistIdImpl(100, REF_A1); P4ChangelistIdImpl cl2 = new P4ChangelistIdImpl(100, REF_A1); ActionStore.PendingAction moveFile = ActionStore.createPendingAction(REF_A1, new MoveFileAction(srcFile.asFilePath(), tgtFile.asFilePath(), cl1)); actions.add(moveFile); ActionStore.PendingAction deleteFile = ActionStore.createPendingAction(REF_A1, new DeleteFileAction(tgtFile.asFilePath(), cl2)); curator.curateActionList(deleteFile, actions); assertSize(1, actionFactory.created); ActionStore.PendingAction created = actionFactory.created.get(0); assertContainsExactly(actions, created); assertNull(created.serverAction); assertNotNull(created.clientAction); assertEquals(created.clientAction.getClass(), DeleteFileAction.class); DeleteFileAction createdDelete = (DeleteFileAction) created.clientAction; assertEquals(cl1, createdDelete.getChangelistId()); }
return new MoveFileAction(state.actionId, state.data.getFilePathNotNull("source"), state.data.getFilePathNotNull("target"),
actions.add(addFile); ActionStore.PendingAction moveFile = ActionStore.createPendingAction(REF_A1, new MoveFileAction(src.asFilePath(), tgt.asFilePath(), cl1)); actions.add(moveFile); ActionStore.PendingAction deleteFile = ActionStore.createPendingAction(REF_A1,
actionFactory.create(new MoveFileAction(existing.getSourceFile(), added.getTargetFile(), added.getChangelistId())), null,
new MoveFileAction(src, tgt, id))); } else {
new MoveFileAction(newFile, toFile, clId)); msgs = res.getServerMessages(); MessageStatusUtil.throwIfMessageOrEmpty("move", msgs);
.map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform(clientConfig, new MoveFileAction(srcFile, tgtFile, new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()))) .whenCompleted(sink::resolve)
new MoveFileAction(fromFile, toFile, clId)); msgs = res.getServerMessages(); assertSize(1, msgs);