Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuís Copetti2018-09-08 20:50:32 -0400
committerLuís Copetti2018-10-04 23:15:27 -0400
commit66325fa5e9e9dec45f426c95c685b57c20e2878e (patch)
tree9370873246ebf19eb9d88436474eeaf1785efc62 /org.eclipse.egit.ui.test/src/org
parente4dc3eaf0900a469e605b0307a8387c464bb60e9 (diff)
downloadegit-66325fa5e9e9dec45f426c95c685b57c20e2878e.tar.gz
egit-66325fa5e9e9dec45f426c95c685b57c20e2878e.tar.xz
egit-66325fa5e9e9dec45f426c95c685b57c20e2878e.zip
Simplify BranchProjectTracker by removing the persisting code from it
Some classes were added to simplify the overall code for BranchProjectTracker so that it can focus only on auto-creating/importing projects on checkout rather than having it also know how to save and restore that information. Change-Id: I5f927d9a3abc1eb492e25160891f98687f34aa30 Signed-off-by: Luís Copetti <lhcopetti@gmail.com>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/branch/BranchProjectTrackerTest.java34
1 files changed, 27 insertions, 7 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/branch/BranchProjectTrackerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/branch/BranchProjectTrackerTest.java
index ace9ed661..0ddda2807 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/branch/BranchProjectTrackerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/branch/BranchProjectTrackerTest.java
@@ -18,6 +18,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.IOException;
+import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -49,17 +51,20 @@ public class BranchProjectTrackerTest extends LocalRepositoryTestCase {
repository = Activator.getDefault().getRepositoryCache()
.lookupRepository(repoFile);
assertNotNull(repository);
- BranchProjectTracker tracker = new BranchProjectTracker(repository);
org.eclipse.egit.ui.Activator.getDefault().getPreferenceStore()
- .setValue(tracker.getPreference(Constants.MASTER), "");
+ .setValue(getPreferenceKey(Constants.MASTER), "");
org.eclipse.egit.ui.Activator.getDefault().getPreferenceStore()
- .setValue(tracker.getPreference(BRANCH), "");
+ .setValue(getPreferenceKey(BRANCH), "");
+ }
+
+ private String getPreferenceKey(String branch) {
+ return ProjectTrackerPreferenceHelper.getPreferenceKey(repository,
+ branch);
}
@Test
public void twoProjectsWithOnlyOneOnBranch() throws Exception {
- BranchProjectTracker tracker = new BranchProjectTracker(repository);
- String[] paths = tracker.getProjectPaths();
+ String[] paths = getProjectPaths();
assertNotNull(paths);
assertEquals(0, paths.length);
assertNotNull(Git.wrap(repository).branchCreate().setName(BRANCH)
@@ -67,7 +72,7 @@ public class BranchProjectTrackerTest extends LocalRepositoryTestCase {
BranchOperationUI.checkout(repository, BRANCH).start();
TestUtil.joinJobs(JobFamilies.CHECKOUT);
- paths = tracker.getProjectPaths(Constants.MASTER);
+ paths = getProjectPaths(Constants.MASTER);
assertNotNull(paths);
assertEquals(2, paths.length);
@@ -85,7 +90,7 @@ public class BranchProjectTrackerTest extends LocalRepositoryTestCase {
BranchOperationUI.checkout(repository, Constants.MASTER).start();
TestUtil.joinJobs(JobFamilies.CHECKOUT);
- paths = tracker.getProjectPaths(BRANCH);
+ paths = getProjectPaths(BRANCH);
assertNotNull(paths);
assertEquals(1, paths.length);
@@ -108,4 +113,19 @@ public class BranchProjectTrackerTest extends LocalRepositoryTestCase {
assertTrue(project2.exists());
assertTrue(project2.isOpen());
}
+
+ private String[] getProjectPaths() {
+ try {
+ String branch = repository.getBranch();
+ return getProjectPaths(branch);
+ } catch (IOException e) {
+ return new String[0];
+ }
+ }
+
+ private String[] getProjectPaths(String branch) {
+ List<String> value = ProjectTrackerPreferenceHelper
+ .restoreFromPreferences(repository, branch);
+ return value.toArray(new String[0]);
+ }
}

Back to the top