Search in sources :

Example 1 with MavenJavaProject

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

the class HtmlJavadocTest method html_testConstructorJavadoc.

@Test
public void html_testConstructorJavadoc() throws Exception {
    Assume.assumeTrue(javaVersionHigherThan(6));
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("java.util.ArrayList");
    assertNotNull(type);
    IMethod method = type.getMethod("<init>", Stream.empty());
    assertNotNull(method);
    String expected = String.join("\n", "<h4>ArrayList</h4>");
    IJavadoc javaDoc = method.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) IMethod(org.springframework.ide.vscode.commons.java.IMethod) IType(org.springframework.ide.vscode.commons.java.IType) Test(org.junit.Test)

Example 2 with MavenJavaProject

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

the class HtmlJavadocTest method html_testClassJavadoc.

@Test
public void html_testClassJavadoc() throws Exception {
    Assume.assumeTrue(javaVersionHigherThan(6));
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("java.util.Map");
    assertNotNull(type);
    String expected = String.join("\n", "<div class=\"block\">An object that maps keys to values.  A map cannot contain duplicate keys;", " each key can map to at most one value.");
    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 3 with MavenJavaProject

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

the class HtmlJavadocTest method html_testFieldAndMethodJavadocForJar.

@Test
public void html_testFieldAndMethodJavadocForJar() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("org.springframework.boot.SpringApplication");
    assertNotNull(type);
    IField field = type.getField("BANNER_LOCATION_PROPERTY_VALUE");
    assertNotNull(field);
    String expected = String.join("\n", "<h4>BANNER_LOCATION_PROPERTY_VALUE</h4>", "<pre>public static final&nbsp;<a href=\"http://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true\" title=\"class or interface in java.lang\">String</a> BANNER_LOCATION_PROPERTY_VALUE</pre>", "<div class=\"block\">Default banner location.</div>", "<dl>", "<dt><span class=\"seeLabel\">See Also:</span></dt>", "<dd><a href=\"../../../constant-values.html#org.springframework.boot.SpringApplication.BANNER_LOCATION_PROPERTY_VALUE\">Constant Field Values</a></dd>", "</dl>");
    IJavadoc javaDoc = field.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
    IMethod method = type.getMethod("getListeners", Stream.empty());
    assertNotNull(method);
    expected = String.join("\n", "<h4>getListeners</h4>", "<pre>public&nbsp;<a href=\"http://docs.oracle.com/javase/6/docs/api/java/util/Set.html?is-external=true\" title=\"class or interface in java.util\">Set</a>&lt;org.springframework.context.ApplicationListener&lt;?&gt;&gt;&nbsp;getListeners()</pre>", "<div class=\"block\">Returns read-only ordered Set of the <code>ApplicationListener</code>s that will be", " applied to the SpringApplication and registered with the <code>ApplicationContext</code>", " .</div>", "<dl>", "<dt><span class=\"returnLabel\">Returns:</span></dt>", "<dd>the listeners</dd>", "</dl>");
    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 4 with MavenJavaProject

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

the class HtmlJavadocTest method html_testJavadocOutputFolder.

@Test
public void html_testJavadocOutputFolder() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("hello.Greeting");
    assertNotNull(type);
    String expected = "<div class=\"block\">Comment for Greeting class</div>";
    IJavadoc javaDoc = type.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
    IField field = type.getField("id");
    assertNotNull(field);
    expected = String.join("\n", "<h4>id</h4>", "<pre>protected final&nbsp;long id</pre>", "<div class=\"block\">Comment for id field</div>");
    javaDoc = field.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
    IMethod method = type.getMethod("getId", Stream.empty());
    assertNotNull(method);
    expected = String.join("\n", "<h4>getId</h4>", "<pre>public&nbsp;long&nbsp;getId()</pre>", "<div class=\"block\">Comment for getId()</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 5 with MavenJavaProject

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

the class HtmlJavadocTest method html_testNoJavadocMethod.

@Test
public void html_testNoJavadocMethod() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("hello.Application");
    assertNotNull(type);
    IMethod method = type.getMethod("corsConfigurer", Stream.empty());
    assertNotNull(method);
    String expected = String.join("\n", "<h4>corsConfigurer</h4>", "<pre>@Bean", "public&nbsp;org.springframework.web.servlet.config.annotation.WebMvcConfigurer&nbsp;corsConfigurer()</pre>");
    IJavadoc 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) 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