use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.
the class SourcepathMacroTest method defaultValueOfSourcepathShouldBeBuilt.
@Test
public void defaultValueOfSourcepathShouldBeBuilt() throws Exception {
List<ClasspathEntryDto> entries = new ArrayList<>();
Set<String> libs = new HashSet<>();
Path projectsRoot = Path.valueOf("/projects");
when(appContext.getProjectsRoot()).thenReturn(projectsRoot);
when(classpathContainer.getClasspathEntries(anyString())).thenReturn(classpathEntriesPromise);
when(classpathResolver.getLibs()).thenReturn(libs);
sourcepathMacro.expand();
verify(classpathEntriesPromise).then(classpathEntriesCapture.capture());
String classpath = classpathEntriesCapture.getValue().apply(entries);
verify(classpathResolver).resolveClasspathEntries(entries);
assertEquals("/projects/name", classpath);
}
use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.
the class ClasspathMacroTest method defaultValueOfClasspathShouldBeBuilt.
@Test
public void defaultValueOfClasspathShouldBeBuilt() throws Exception {
List<ClasspathEntryDto> entries = new ArrayList<>();
Set<String> libs = new HashSet<>();
Path projectsRoot = Path.valueOf("/projects");
when(appContext.getProjectsRoot()).thenReturn(projectsRoot);
when(classpathContainer.getClasspathEntries(anyString())).thenReturn(classpathEntriesPromise);
when(classpathResolver.getLibs()).thenReturn(libs);
classpathMacro.expand();
verify(classpathEntriesPromise).then(classpathEntriesCapture.capture());
String classpath = classpathEntriesCapture.getValue().apply(entries);
verify(classpathResolver).resolveClasspathEntries(entries);
assertEquals("/projects/name:", classpath);
}
use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.
the class ClasspathMacroTest method classpathShouldBeBuiltWith2Libraries.
@Test
public void classpathShouldBeBuiltWith2Libraries() throws Exception {
String lib1 = "lib1.jar";
String lib2 = "lib2.jar";
List<ClasspathEntryDto> entries = new ArrayList<>();
Set<String> libs = new HashSet<>();
libs.add(lib1);
libs.add(lib2);
when(classpathContainer.getClasspathEntries(anyString())).thenReturn(classpathEntriesPromise);
when(classpathResolver.getLibs()).thenReturn(libs);
classpathMacro.expand();
verify(classpathEntriesPromise).then(classpathEntriesCapture.capture());
String classpath = classpathEntriesCapture.getValue().apply(entries);
verify(classpathResolver).resolveClasspathEntries(entries);
assertEquals("lib2.jar:lib1.jar:", classpath);
}
use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.
the class LibEntryPresenter method go.
@Override
public void go(final AcceptsOneWidget container) {
final Resource resource = appContext.getResource();
Preconditions.checkState(resource != null);
final Optional<Project> project = resource.getRelatedProject();
isPlainJava = JAVAC.equals(project.get().getType());
setReadOnlyMod();
container.setWidget(view);
if (!categories.isEmpty()) {
view.renderLibraries();
return;
}
classpathContainer.getClasspathEntries(project.get().getPath()).then(new Operation<List<ClasspathEntryDto>>() {
@Override
public void apply(List<ClasspathEntryDto> arg) throws OperationException {
categories.clear();
for (ClasspathEntryDto entry : arg) {
if (CONTAINER == entry.getEntryKind() || LIBRARY == entry.getEntryKind()) {
categories.put(entry.getPath(), entry);
}
}
view.setData(categories);
view.renderLibraries();
}
});
}
use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.
the class ClasspathUpdaterService method createModifiedEntry.
private IClasspathEntry[] createModifiedEntry(List<ClasspathEntryDto> entries) {
List<IClasspathEntry> coreClasspathEntries = new ArrayList<>(entries.size());
for (ClasspathEntryDto entry : entries) {
IPath path = fromOSString(entry.getPath());
int entryKind = entry.getEntryKind();
if (IClasspathEntry.CPE_LIBRARY == entryKind) {
coreClasspathEntries.add(newLibraryEntry(path, null, null));
} else if (IClasspathEntry.CPE_SOURCE == entryKind) {
coreClasspathEntries.add(newSourceEntry(path));
} else if (IClasspathEntry.CPE_VARIABLE == entryKind) {
coreClasspathEntries.add(newVariableEntry(path, null, null));
} else if (IClasspathEntry.CPE_CONTAINER == entryKind) {
coreClasspathEntries.add(newContainerEntry(path));
} else if (IClasspathEntry.CPE_PROJECT == entryKind) {
coreClasspathEntries.add(newProjectEntry(path));
}
}
return coreClasspathEntries.toArray(new IClasspathEntry[coreClasspathEntries.size()]);
}
Aggregations