Search in sources :

Example 6 with MavenJavaProject

use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.

the class HtmlJavadocTest method html_testNoJavadocClass.

@Test
public void html_testNoJavadocClass() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    ;
    IType type = project.getClasspath().findType("hello.GreetingController");
    assertNotNull(type);
    assertNull(type.getJavaDoc());
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 7 with MavenJavaProject

use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.

the class JavaIndexTest method findClassInJar.

@Test
public void findClassInJar() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
    IType type = project.getClasspath().findType("org.springframework.test.web.client.ExpectedCount");
    assertNotNull(type);
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 8 with MavenJavaProject

use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.

the class JavaIndexTest method voidConstructor.

@Test
public void voidConstructor() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
    IType type = project.getClasspath().findType("java.util.ArrayList");
    assertNotNull(type);
    IMethod m = type.getMethod("<init>", Stream.empty());
    assertEquals(type.getElementName(), m.getElementName());
    assertEquals(IVoidType.DEFAULT, m.getReturnType());
    assertEquals(0, m.parameters().count());
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IMethod(org.springframework.ide.vscode.commons.java.IMethod) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 9 with MavenJavaProject

use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.

the class JavaIndexTest method constructorMethodWithParams.

@Test
public void constructorMethodWithParams() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
    IType type = project.getClasspath().findType("java.util.ArrayList");
    assertNotNull(type);
    IMethod m = type.getMethod("<init>", Stream.of(IPrimitiveType.INT));
    assertEquals(m.getDeclaringType().getElementName(), m.getElementName());
    assertEquals(IVoidType.DEFAULT, m.getReturnType());
    assertEquals(Collections.singletonList(IPrimitiveType.INT), m.parameters().collect(Collectors.toList()));
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IMethod(org.springframework.ide.vscode.commons.java.IMethod) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 10 with MavenJavaProject

use of org.springframework.ide.vscode.commons.maven.java.MavenJavaProject in project sts4 by spring-projects.

the class MavenProjectCacheTest method testPomFileChanges.

@Test
public void testPomFileChanges() throws Exception {
    MavenProjectCache cache = new MavenProjectCache(server, MavenCore.getDefault(), false, null);
    IJavaProject[] projectChanged = new IJavaProject[] { null };
    IJavaProject[] projectDeleted = new IJavaProject[] { null };
    cache.addListener(new Listener() {

        @Override
        public void created(IJavaProject project) {
        }

        @Override
        public void changed(IJavaProject project) {
            projectChanged[0] = project;
        }

        @Override
        public void deleted(IJavaProject project) {
            projectDeleted[0] = project;
        }
    });
    // Get the project from cache
    MavenJavaProject cachedProject = cache.project(pomFile);
    assertNotNull(cachedProject);
    ImmutableList<Path> calculatedClassPath = cachedProject.getClasspath().getClasspathEntries();
    assertEquals(48, calculatedClassPath.size());
    fileObserver.notifyFileChanged(pomFile.toURI().toString());
    assertNull(projectChanged[0]);
    writeContent(pomFile, new String(Files.readAllBytes(testProjectPath.resolve("pom.newxml")), Charset.defaultCharset()));
    fileObserver.notifyFileChanged(pomFile.toURI().toString());
    assertNotNull(projectChanged[0]);
    assertEquals(cachedProject, projectChanged[0]);
    calculatedClassPath = cachedProject.getClasspath().getClasspathEntries();
    assertEquals(49, calculatedClassPath.size());
    fileObserver.notifyFileDeleted(pomFile.toURI().toString());
    assertEquals(cachedProject, projectDeleted[0]);
}
Also used : Path(java.nio.file.Path) MavenProjectCache(org.springframework.ide.vscode.commons.maven.java.MavenProjectCache) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Listener(org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener) MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) Test(org.junit.Test)

Aggregations

MavenJavaProject (org.springframework.ide.vscode.commons.maven.java.MavenJavaProject)31 Test (org.junit.Test)27 IType (org.springframework.ide.vscode.commons.java.IType)18 IMethod (org.springframework.ide.vscode.commons.java.IMethod)10 IJavadoc (org.springframework.ide.vscode.commons.javadoc.IJavadoc)10 Path (java.nio.file.Path)5 IField (org.springframework.ide.vscode.commons.java.IField)5 File (java.io.File)4 Before (org.junit.Before)4 MockRunningAppProvider (org.springframework.ide.vscode.project.harness.MockRunningAppProvider)4 VSCodeSourceLinks (org.springframework.ide.vscode.boot.java.links.VSCodeSourceLinks)3 MavenProjectCache (org.springframework.ide.vscode.commons.maven.java.MavenProjectCache)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 ProgressService (org.springframework.ide.vscode.commons.languageserver.ProgressService)2 URI (java.net.URI)1 AbstractPropsEditorTest (org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest)1 IJavaProject (org.springframework.ide.vscode.commons.java.IJavaProject)1 DiagnosticService (org.springframework.ide.vscode.commons.languageserver.DiagnosticService)1 Listener (org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener)1