Search in sources :

Example 11 with MavenJavaProject

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

the class BeanInjectedIntoHoverProviderTest 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("hello.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 12 with MavenJavaProject

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

the class VSCodeSourceLinksTest method testJarUrl.

@Test
public void testJarUrl() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("empty-boot-15-web-app");
    Optional<String> url = new VSCodeSourceLinks(null).sourceLinkUrlForFQName(project, "org.springframework.boot.autoconfigure.SpringBootApplication");
    assertTrue(url.isPresent());
    String headerPart = url.get().substring(0, url.get().indexOf('?'));
    assertEquals("jdt://contents/spring-boot-autoconfigure-1.5.8.RELEASE.jar/org.springframework.boot.autoconfigure/SpringBootApplication.class", headerPart);
    String positionPart = url.get().substring(url.get().lastIndexOf('#'));
    assertEquals("#55,19", 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 13 with MavenJavaProject

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

the class VSCodeSourceLinksTest method testJavaSourceUrl.

@Test
public void testJavaSourceUrl() throws Exception {
    MavenJavaProject project = mavenProjectsCache.get("empty-boot-15-web-app");
    Optional<String> url = new VSCodeSourceLinks(null).sourceLinkUrlForFQName(project, "com.example.EmptyBoot15WebAppApplication");
    assertTrue(url.isPresent());
    Path projectPath = Paths.get(project.pom().getParent());
    URI uri = URI.create(url.get());
    // Use File to get rid of the fragment parts of the URL. The URL may have fragments that indicate line and column numbers
    uri = new File(uri.getPath()).toURI();
    Path relativePath = projectPath.relativize(Paths.get(uri));
    assertEquals(Paths.get("src/main/java/com/example/EmptyBoot15WebAppApplication.java"), relativePath);
    String positionPart = url.get().substring(url.get().lastIndexOf('#'));
    assertEquals("#7,14", positionPart);
}
Also used : VSCodeSourceLinks(org.springframework.ide.vscode.boot.java.links.VSCodeSourceLinks) Path(java.nio.file.Path) MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) URI(java.net.URI) File(java.io.File) Test(org.junit.Test)

Example 14 with MavenJavaProject

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

the class ApplicationPropertiesEditorTest method testEnableApt.

@Test
public void testEnableApt() throws Throwable {
    MavenJavaProject p = createPredefinedMavenProject("boot-1.2.0-properties-live-metadta");
    // Check some assumptions about the initial state of the test project (if these checks fail then
    // the test may be 'vacuous' since the things we are testing for already exist beforehand.
    Path metadataFile = p.getClasspath().getOutputFolder().resolve(PropertiesLoader.PROJECT_META_DATA_LOCATIONS[0]);
    assertTrue(metadataFile.toFile().isFile());
    assertContains("\"name\": \"foo.counter\"", Files.toString(metadataFile.toFile(), Charset.forName("UTF8")));
}
Also used : Path(java.nio.file.Path) MavenJavaProject(org.springframework.ide.vscode.commons.maven.java.MavenJavaProject) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 15 with MavenJavaProject

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

the class BeansByTypeHoverProviderTest 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");
    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)

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