Search in sources :

Example 16 with MavenJavaProject

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

the class ComponentInjectionsHoverProviderTest method setup.

@Before
public void setup() throws Exception {
    mockAppProvider = new MockRunningAppProvider();
    harness = BootJavaLanguageServerHarness.builder().mockDefaults().runningAppProvider(mockAppProvider.provider).watchDogInterval(Duration.ofMillis(100)).build();
    MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app", EXTRA_TYPES);
    assertTrue(jp.getClasspath().findType("com.example.Foo").exists());
    harness.useProject(jp);
    harness.intialize(null);
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) MockRunningAppProvider(org.springframework.ide.vscode.project.harness.MockRunningAppProvider) Before(org.junit.Before)

Example 17 with MavenJavaProject

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

the class VSCodeSourceLinksTest method testJarUrlInnerType.

@Test
public void testJarUrlInnerType() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("empty-boot-15-web-app");
    Optional<String> url = new VSCodeSourceLinks(null).sourceLinkUrlForFQName(project, "org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback");
    assertTrue(url.isPresent());
    String headerPart = url.get().substring(0, url.get().indexOf('?'));
    assertEquals("jdt://contents/spring-web-4.3.12.RELEASE.jar/org.springframework.web.client/RestTemplate$AcceptHeaderRequestCallback.class", headerPart);
    String positionPart = url.get().substring(url.get().lastIndexOf('#'));
    assertEquals("#747,16", positionPart);
}
Also used : VSCodeSourceLinks(org.springframework.ide.vscode.boot.java.links.VSCodeSourceLinks) MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) Test(org.junit.Test)

Example 18 with MavenJavaProject

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

the class AutowiredHoverProviderTest method setup.

@Before
public void setup() throws Exception {
    mockAppProvider = new MockRunningAppProvider();
    harness = BootJavaLanguageServerHarness.builder().mockDefaults().runningAppProvider(mockAppProvider.provider).watchDogInterval(Duration.ofMillis(100)).build();
    MavenJavaProject jp = projects.mavenProject("empty-boot-15-web-app", FOO_INTERFACE);
    assertTrue(jp.getClasspath().findType("com.example.Foo").exists());
    harness.useProject(projects.mavenProject("empty-boot-15-web-app"));
    harness.intialize(null);
}
Also used : MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) MockRunningAppProvider(org.springframework.ide.vscode.project.harness.MockRunningAppProvider) Before(org.junit.Before)

Example 19 with MavenJavaProject

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

the class HtmlJavadocTest method html_testInnerClassLevel2_JavadocForOutputFolder.

@Test
public void html_testInnerClassLevel2_JavadocForOutputFolder() throws Exception {
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("hello.Greeting$TestInnerClass$TestInnerClassLevel2");
    assertNotNull(type);
    IJavadoc javaDoc = type.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals("<div class=\"block\">Comment for level 2 nested class</div>", javaDoc.getRenderable().toHtml());
    IField field = type.getField("innerLevel2Field");
    assertNotNull(field);
    String expected = String.join("\n", "<h4>innerLevel2Field</h4>", "<pre>protected&nbsp;int innerLevel2Field</pre>", "<div class=\"block\">Comment for level 2 inner field</div>");
    javaDoc = field.getJavaDoc();
    assertNotNull(javaDoc);
    assertEquals(expected, javaDoc.getRenderable().toHtml());
    IMethod method = type.getMethod("getInnerLevel2Field", Stream.empty());
    assertNotNull(method);
    expected = String.join("\n", "<h4>getInnerLevel2Field</h4>", "<pre>public&nbsp;int&nbsp;getInnerLevel2Field()</pre>", "<div class=\"block\">Comment for method inside level 2 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 20 with MavenJavaProject

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

the class HtmlJavadocTest method html_testMethodJavadoc.

@Test
public void html_testMethodJavadoc() throws Exception {
    Assume.assumeTrue(javaVersionHigherThan(6));
    MavenJavaProject project = projectSupplier.get();
    IType type = project.getClasspath().findType("java.util.ArrayList");
    assertNotNull(type);
    IMethod method = type.getMethod("size", Stream.empty());
    assertNotNull(method);
    String expected = String.join("\n", "<h4>size</h4>", "<pre>public&nbsp;int&nbsp;size()</pre>", "<div class=\"block\">Returns the number of elements in this list.</div>");
    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)

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