update copyrights
[fedora-idea.git] / platform / lvcs-impl / testSrc / com / intellij / historyIntegrTests / revertion / ChangeReverterCanRevertTest.java
blob50aa947dd26df84865cac08bbbf0d35a3537dc68
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.intellij.historyIntegrTests.revertion;
19 import com.intellij.history.integration.revertion.Reverter;
20 import com.intellij.openapi.vfs.VirtualFile;
22 import java.io.IOException;
23 import java.util.Collections;
24 import java.util.List;
26 public class ChangeReverterCanRevertTest extends ChangeReverterTestCase {
27 public void testDoesNotAskIfThereIsNoSubsequentalChanges() throws IOException {
28 root.createChildData(null, "f.txt");
30 Reverter r = createReverter(root, 0);
31 assertTrue(r.askUserForProceeding().isEmpty());
34 public void testAskingForRevertSubsequentalChanges() throws IOException {
35 VirtualFile f = root.createChildData(null, "f.txt");
36 f.setBinaryContent(new byte[1]);
38 Reverter r = createReverter(f, 1);
39 List<String> questions = r.askUserForProceeding();
41 String expected = "There are some changes that have been done after this one.\nThese changes should be reverted too.";
42 assertEquals(Collections.singletonList(expected), questions);
45 public void testCanNotRevertRenameIfSomeFilesAlreadyExist() throws IOException {
46 VirtualFile f = root.createChildData(null, "f.txt");
48 f.rename(null, "ff.txt");
49 assertCanRevert(f, 0);
51 root.createChildData(null, "f.txt");
52 assertCanNotRevert(f, 0, "some files already exist");
55 public void testCanNotRevertMovementIfSomeFilesAlreadyExist() throws IOException {
56 VirtualFile f = root.createChildData(null, "f.txt");
57 VirtualFile dir = root.createChildDirectory(null, "dir");
59 f.move(null, dir);
60 assertCanRevert(f, 0);
62 root.createChildData(null, "f.txt");
63 assertCanNotRevert(f, 0, "some files already exist");
66 public void testIncludeOnlyOnlyErrorMessage() throws IOException {
67 VirtualFile f1 = root.createChildData(null, "f1.txt");
68 VirtualFile f2 = root.createChildData(null, "f2.txt");
69 VirtualFile dir = root.createChildDirectory(null, "dir");
71 f1.move(null, dir);
72 f2.move(null, dir);
73 assertCanRevert(dir, 1);
75 root.createChildData(null, "f1.txt");
76 root.createChildData(null, "f2.txt");
78 List<String> ee = getCanRevertErrors(dir, 1);
79 assertEquals(1, ee.size());
80 assertEquals("some files already exist", ee.get(0));
83 public void testDoesNotConsiderUnaffectedFiles() throws IOException {
84 VirtualFile f1 = root.createChildData(null, "f1.txt");
85 VirtualFile f2 = root.createChildData(null, "f2.txt");
87 f1.rename(null, "f11.txt");
88 f2.rename(null, "f22.txt");
89 root.createChildData(null, "f2.txt");
91 assertCanRevert(f1, 0);
94 public void testDoesNotConsiderPreviousChanges() throws IOException {
95 VirtualFile f = root.createChildData(null, "f.txt");
97 f.rename(null, "ff.txt");
98 f.rename(null, "fff.txt");
99 root.createChildData(null, "f.txt");
101 assertCanRevert(f, 0);