From ae19fd9de2b6d80540608bde8b19f0cb7d034030 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Sun, 29 Jul 2018 20:10:18 +0300 Subject: [PATCH] svn: Refactor "SvnResolveTreeAcceptVariantsTest" - move method --- .../svn/SvnResolveTreeAcceptVariantsTest.java | 110 +++++++++--------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java index 40c6d2a538ef..ff6c6e3e6adf 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java @@ -98,6 +98,61 @@ public class SvnResolveTreeAcceptVariantsTest extends SvnTestCase { checkFileContents(); } + @Test + public void testTheirsFull() throws Exception { + mySvnClientRunner.checkout(myRepoUrl, myTheirs); + + createSubTree(); + runInEdtAndWait(() -> new ConflictCreator(vcs, myTheirs, myWorkingCopyDir, conflictData, mySvnClientRunner).create()); + + refreshChanges(); + refreshChanges(); + + final String conflictFile = conflictData.getConflictFile(); + final File conflictIoFile = new File(myWorkingCopyDir.getPath(), conflictFile); + final FilePath filePath = VcsUtil.getFilePath(conflictIoFile); + final Change change = changeListManager.getChange(filePath); + assertNotNull(change); + assertTrue(change instanceof ConflictedSvnChange); + FilePath beforePath = null; + if (change.isMoved() || change.isRenamed()) { + beforePath = change.getBeforeRevision().getFile(); + } + + new SvnTreeConflictResolver(vcs, filePath, beforePath).resolveSelectTheirsFull(); + + myTheirs.refresh(false, true); + refreshVfs(); + VfsUtil.processFileRecursivelyWithoutIgnored(myTheirs, file -> { + final String relative = getRelativePath(file, myTheirs, File.separatorChar); + File workingFile = new File(myWorkingCopyDir.getPath(), relative); + boolean exists = workingFile.exists(); + if (!exists) { + String[] excluded = conflictData.getExcludeFromToTheirsCheck(); + if (excluded != null && asList(excluded).contains(relative)) { + return true; + } + assertTrue(createTestFailedComment(relative), exists); + } + final File theirsFile = virtualToIoFile(file); + Info theirsInfo = vcs.getInfo(theirsFile); + Info thisInfo = vcs.getInfo(workingFile); + if (theirsInfo != null) { + assertEquals(createTestFailedComment(relative) + ", theirs: " + theirsInfo.getRevision().getNumber() + ", mine: " + + thisInfo.getRevision().getNumber(), theirsInfo.getRevision().getNumber(), thisInfo.getRevision().getNumber()); + if (!theirsFile.isDirectory()) { + try { + assertEquals(FileUtil.loadFile(theirsFile), FileUtil.loadFile(workingFile)); + } + catch (IOException e) { + fail(e.getMessage()); + } + } + } + return true; + }); + } + private void checkFileContents() throws IOException { for (TreeConflictData.FileData leftFile : conflictData.getLeftFiles()) { if (!leftFile.myIsDir && !StringUtil.isEmpty(leftFile.myContents)) { @@ -164,61 +219,6 @@ public class SvnResolveTreeAcceptVariantsTest extends SvnTestCase { return "File: " + path + " in: " + myWorkingCopyDir.getPath(); } - @Test - public void testTheirsFull() throws Exception { - mySvnClientRunner.checkout(myRepoUrl, myTheirs); - - createSubTree(); - runInEdtAndWait(() -> new ConflictCreator(vcs, myTheirs, myWorkingCopyDir, conflictData, mySvnClientRunner).create()); - - refreshChanges(); - refreshChanges(); - - final String conflictFile = conflictData.getConflictFile(); - final File conflictIoFile = new File(myWorkingCopyDir.getPath(), conflictFile); - final FilePath filePath = VcsUtil.getFilePath(conflictIoFile); - final Change change = changeListManager.getChange(filePath); - assertNotNull(change); - assertTrue(change instanceof ConflictedSvnChange); - FilePath beforePath = null; - if (change.isMoved() || change.isRenamed()) { - beforePath = change.getBeforeRevision().getFile(); - } - - new SvnTreeConflictResolver(vcs, filePath, beforePath).resolveSelectTheirsFull(); - - myTheirs.refresh(false, true); - refreshVfs(); - VfsUtil.processFileRecursivelyWithoutIgnored(myTheirs, file -> { - final String relative = getRelativePath(file, myTheirs, File.separatorChar); - File workingFile = new File(myWorkingCopyDir.getPath(), relative); - boolean exists = workingFile.exists(); - if (!exists) { - String[] excluded = conflictData.getExcludeFromToTheirsCheck(); - if (excluded != null && asList(excluded).contains(relative)) { - return true; - } - assertTrue(createTestFailedComment(relative), exists); - } - final File theirsFile = virtualToIoFile(file); - Info theirsInfo = vcs.getInfo(theirsFile); - Info thisInfo = vcs.getInfo(workingFile); - if (theirsInfo != null) { - assertEquals(createTestFailedComment(relative) + ", theirs: " + theirsInfo.getRevision().getNumber() + ", mine: " - + thisInfo.getRevision().getNumber(), theirsInfo.getRevision().getNumber(), thisInfo.getRevision().getNumber()); - if (!theirsFile.isDirectory()) { - try { - assertEquals(FileUtil.loadFile(theirsFile), FileUtil.loadFile(workingFile)); - } - catch (IOException e) { - fail(e.getMessage()); - } - } - } - return true; - }); - } - private static Object getStaticFieldValue(Field field) { try { return field.get(null);