use of com.intellij.testFramework.vcs.MockChangeListManagerGate in project intellij-community by JetBrains.
the class GitChangeProviderTest method getChanges.
/**
* Marks the given files dirty in myDirtyScope, gets changes from myChangeProvider and groups the changes in the map.
* Assumes that only one change for a file has happened.
*/
protected Map<FilePath, Change> getChanges(VirtualFile... changedFiles) throws VcsException {
final List<FilePath> changedPaths = ObjectsConvertor.vf2fp(Arrays.asList(changedFiles));
// get changes
MockChangelistBuilder builder = new MockChangelistBuilder();
myChangeProvider.getChanges(myDirtyScope, builder, new EmptyProgressIndicator(), new MockChangeListManagerGate(ChangeListManager.getInstance(myProject)));
List<Change> changes = builder.getChanges();
// get changes for files
final Map<FilePath, Change> result = new HashMap<>();
for (Change change : changes) {
VirtualFile file = change.getVirtualFile();
FilePath filePath = null;
if (file == null) {
// if a file was deleted, just find the reference in the original list of files and use it.
String path = change.getBeforeRevision().getFile().getPath();
for (FilePath fp : changedPaths) {
if (FileUtil.pathsEqual(fp.getPath(), path)) {
filePath = fp;
break;
}
}
} else {
filePath = VcsUtil.getFilePath(file);
}
result.put(filePath, change);
}
return result;
}
use of com.intellij.testFramework.vcs.MockChangeListManagerGate in project intellij-community by JetBrains.
the class SvnTestCase method setUp.
@Before
public void setUp() throws Exception {
System.out.println("Native client for status: " + isUseNativeAcceleration());
String property = System.getProperty("svn.test.data.directory");
if (!StringUtil.isEmpty(property)) {
myTestDataDir = property;
}
UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
try {
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
myTempDirFixture = fixtureFactory.createTempDirTestFixture();
myTempDirFixture.setUp();
myRepoRoot = new File(myTempDirFixture.getTempDirPath(), "svnroot");
assert myRepoRoot.mkdir() || myRepoRoot.isDirectory() : myRepoRoot;
myPluginRoot = new File(PluginPathManager.getPluginHomePath("svn4idea"));
if (!myPluginRoot.isDirectory()) {
Class aClass = SvnTestCase.class;
String rootPath = PathManager.getResourceRoot(aClass, "/" + aClass.getName().replace('.', '/') + ".class");
myPluginRoot = new File(rootPath).getParentFile().getParentFile().getParentFile();
}
File svnBinDir = new File(myPluginRoot, getTestDataDir() + "/svn/bin");
File svnExecutable = null;
if (SystemInfo.isWindows) {
svnExecutable = new File(svnBinDir, "windows/svn.exe");
} else if (SystemInfo.isLinux) {
svnExecutable = new File(svnBinDir, "linux/svn");
} else if (SystemInfo.isMac) {
svnExecutable = new File(svnBinDir, "mac/svn");
}
assertTrue("No Subversion executable was found: " + svnExecutable + ", " + SystemInfo.OS_NAME, svnExecutable != null && svnExecutable.canExecute());
myClientBinaryPath = svnExecutable.getParentFile();
myRunner = SystemInfo.isMac ? createClientRunner(Collections.singletonMap("DYLD_LIBRARY_PATH", myClientBinaryPath.getPath())) : createClientRunner();
ZipUtil.extract(new File(myPluginRoot, getTestDataDir() + "/svn/newrepo.zip"), myRepoRoot, null);
myWcRoot = new File(myTempDirFixture.getTempDirPath(), myWcRootName);
assert myWcRoot.mkdir() || myWcRoot.isDirectory() : myWcRoot;
myRepoUrl = (SystemInfo.isWindows ? "file:///" : "file://") + FileUtil.toSystemIndependentName(myRepoRoot.getPath());
verify(runSvn("co", myRepoUrl, myWcRoot.getPath()));
initProject(myWcRoot, SvnTestCase.this.getTestName());
activateVCS(SvnVcs.VCS_NAME);
myGate = new MockChangeListManagerGate(ChangeListManager.getInstance(myProject));
((StartupManagerImpl) StartupManager.getInstance(myProject)).runPostStartupActivities();
refreshSvnMappingsSynchronously();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
// there should be kind-a waiting for after change list manager finds all changes and runs inner refresh of copies in the above method
if (myInitChangeListManager) {
ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
changeListManager.ensureUpToDate(false);
}
}
Aggregations