use of org.eclipse.n4js.ide.tests.helper.server.TestWorkspaceManager in project n4js by eclipse.
the class ConvertedIdeTest method importProband.
/**
* Creates an empty yarn workspace project with
* {@link TestWorkspaceManager#createTestOnDisk(org.eclipse.xtext.xbase.lib.Pair...) the test workspace manager},
* starts the LSP server, and then imports all projects in the given proband folder. Each sub-folder of the given
* proband folder is assumed to be a project and will be imported.
*/
protected List<N4JSPackageName> importProband(File probandFolder, Collection<N4JSPackageName> n4jsLibs) {
if (testWorkspaceManager.isCreated()) {
throw new IllegalStateException("the test workspace has already been created");
}
// this will create an empty yarn workspace
testWorkspaceManager.createTestOnDisk();
startAndWaitForLspServer();
// import the projects
final List<N4JSPackageName> importedProjects = new ArrayList<>();
boolean needToCopyLibs = true;
for (final File child : probandFolder.listFiles()) {
if (child.isDirectory()) {
if (child.getName().startsWith(ProjectDescriptionUtils.NPM_SCOPE_PREFIX)) {
for (final File grandChild : child.listFiles()) {
if (grandChild.isDirectory()) {
final N4JSPackageName name = new N4JSPackageName(child.getName(), grandChild.getName());
importProject(probandFolder, name, needToCopyLibs ? n4jsLibs : Collections.emptyList());
importedProjects.add(name);
needToCopyLibs = false;
}
}
} else {
final N4JSPackageName name = new N4JSPackageName(child.getName());
importProject(probandFolder, name, needToCopyLibs ? n4jsLibs : Collections.emptyList());
importedProjects.add(name);
needToCopyLibs = false;
}
}
}
cleanBuildAndWait();
// ensure that all projects have been imported properly
final Set<String> expectedProjects = importedProjects.stream().map(pn -> "yarn-test-project/packages/" + pn.getRawName()).collect(Collectors.toSet());
final Set<String> actualProjects = concurrentIndex.entries().stream().map(Entry::getKey).collect(Collectors.toSet());
final Set<String> missingProjects = new HashSet<>(Sets.difference(expectedProjects, actualProjects));
Assert.assertTrue("some projects were not correctly imported: " + missingProjects, missingProjects.isEmpty());
return importedProjects;
}
Aggregations