}
}
@Test
public void checkThatNewModulesInNewProjectsAreCorrect() throws Exception {
IErlProject project = null;
IErlProject project2 = null;
try {
// given
// a project with an external module and searching for it so the
// cache
// is updated
final String projectName = "testprojecta";
project = createProject(
projectName, getTmpPath(projectName));
final String externalName = "xyz.erl";
final File externalFile = createTmpFile(externalName,
"-module(xyz).\nf([_ | _]=L ->\n atom_to_list(L).\n");
final String absolutePath = externalFile.getAbsolutePath();
final File externalsFile = createTmpFile("x.erlidex",
absolutePath);
((ErlProject) project)
.setExternalModulesFile(externalsFile.getAbsolutePath());
project.open(null);
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule findModule = model.findModuleFromProject(project,
externalName, null, IErlElementLocator.Scope.PROJECT_ONLY);
// final ErlModelCache cache = ErlModelCache.getDefault();
// final Set<IErlModule> modulesByName = cache
// .getModulesByName(ListsUtils
// .withoutExtension(externalName));
// when
// creating a new project with a module with the same name and
// searching
// for it
final String projectName2 = "testprojectb";
project2 = createProject(
projectName2, getTmpPath(projectName2));
final IErlModule module = createModule(project2,
externalName, "-module(xyz).\n");
final IErlModule findModule2 = model.findModuleFromProject(project,
externalName, null, IErlElementLocator.Scope.ALL_PROJECTS);
// final Set<IErlModule> modulesByName2 = cache
// .getModulesByName(ListsUtils
// .withoutExtension(externalName));
// then
// the new module should be found
assertNotNull(findModule);
assertEquals(module, findModule2);
// assertTrue(modulesByName2.contains(module));
// final SetView<IErlModule> difference = Sets.difference(
// modulesByName2, modulesByName);
// assertEquals(1, difference.size());
// assertEquals(module, difference.toArray()[0]);
} finally {
if (project != null && project.exists()) {
deleteProject(project);
}
if (project2 != null && project2.exists()) {
deleteProject(project2);
}
}
}