Search in sources :

Example 1 with IMethod

use of org.springframework.ide.vscode.commons.java.IMethod 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 IMethod

use of org.springframework.ide.vscode.commons.java.IMethod 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 3 with IMethod

use of org.springframework.ide.vscode.commons.java.IMethod 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 4 with IMethod

use of org.springframework.ide.vscode.commons.java.IMethod 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)

Example 5 with IMethod

use of org.springframework.ide.vscode.commons.java.IMethod 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)

Aggregations

IMethod (org.springframework.ide.vscode.commons.java.IMethod)12 IType (org.springframework.ide.vscode.commons.java.IType)12 Test (org.junit.Test)10 MavenJavaProject (org.springframework.ide.vscode.commons.maven.java.MavenJavaProject)10 IJavadoc (org.springframework.ide.vscode.commons.javadoc.IJavadoc)7 IField (org.springframework.ide.vscode.commons.java.IField)5 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 InetAddress (java.net.InetAddress)1 Charset (java.nio.charset.Charset)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1