Search in sources :

Example 21 with MavenJavaProject

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

the class HtmlJavadocTest method html_testNoJavadocField.

@Test
public void html_testNoJavadocField() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("hello.GreetingController");
    assertNotNull(type);
    IField field = type.getField("template");
    assertNotNull(field);
    String expected = String.join("\n", "<h4>template</h4>", "<pre>public static final&nbsp;<a href=\"http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true\" title=\"class or interface in java.lang\">String</a> template</pre>", "<dl>", "<dt><span class=\"seeLabel\">See Also:</span></dt>", "<dd><a href=\"../constant-values.html#hello.GreetingController.template\">Constant Field Values</a></dd>", "</dl>");
    IJavadoc javaDoc = field.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IJavadoc(org.springframework.ide.vscode.commons.javadoc.IJavadoc) IField(org.springframework.ide.vscode.commons.java.IField) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 22 with MavenJavaProject

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

the class HtmlJavadocTest method html_testEmptyJavadocClass.

@Test
public void html_testEmptyJavadocClass() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("hello.Application");
    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 23 with MavenJavaProject

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

the class HtmlJavadocTest method html_testInnerClassJavadocForOutputFolder.

@Test
public void html_testInnerClassJavadocForOutputFolder() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("hello.Greeting$TestInnerClass");
    assertNotNull(type);
    IJavadoc javaDoc = type.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals("<div class=\"block\">Comment for inner class</div>", javaDoc.getRenderable().toHtml());
    IField field = type.getField("innerField");
    assertNotNull(field);
    String expected = String.join("\n", "<h4>innerField</h4>", "<pre>protected&nbsp;int innerField</pre>", "<div class=\"block\">Comment for inner field</div>");
    javaDoc = field.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
    IMethod method = type.getMethod("getInnerField", Stream.empty());
    assertNotNull(method);
    expected = String.join("\n", "<h4>getInnerField</h4>", "<pre>public&nbsp;int&nbsp;getInnerField()</pre>", "<div class=\"block\">Comment for method inside nested class</div>");
    javaDoc = method.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IJavadoc(org.springframework.ide.vscode.commons.javadoc.IJavadoc) IMethod(org.springframework.ide.vscode.commons.java.IMethod) IField(org.springframework.ide.vscode.commons.java.IField) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 24 with MavenJavaProject

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

the class HtmlJavadocTest method html_testNestedClassJavadoc.

@Test
public void html_testNestedClassJavadoc() throws Exception {
    Assume.assumeTrue(javaVersionHigherThan(6));
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("java.util.Map$Entry");
    assertNotNull(type);
    String expected = String.join("\n", "<div class=\"block\">A map entry (key-value pair).  The <tt>Map.entrySet</tt> method returns", " a collection-view of the map, whose elements are of this class.  The");
    IJavadoc javaDoc = type.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml().substring(0, expected.length()));
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) IJavadoc(org.springframework.ide.vscode.commons.javadoc.IJavadoc) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 25 with MavenJavaProject

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

the class JavaIndexTest method findClassInOutputFolder.

@Test
public void findClassInOutputFolder() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("gs-rest-service-cors-boot-1.4.1-with-classpath-file");
    IType type = project.getClasspath().findType("hello.Greeting");
    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)

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