Search in sources :

Example 26 with IJavaProject

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

the class ApplicationYamlEditorTest method testDeprecatedBeanPropertyReconcile.

@Test
public void testDeprecatedBeanPropertyReconcile() throws Exception {
    IJavaProject jp = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
    useProject(jp);
    data("foo", "demo.Deprecater", null, "A Bean with deprecated properties");
    Editor editor = newEditor("# comment\n" + "foo:\n" + "  name: Old faithfull\n" + "  new-name: New and fancy\n" + "  alt-name: alternate\n");
    editor.assertProblems("name|Property 'name' of type 'demo.Deprecater' is Deprecated!", "alt-name|Deprecated");
    editor = newEditor("# comment\n" + "foo:\n" + "  alt-name: alternate\n");
    // check that message also contains reason and replacement infos.
    editor.assertProblems("alt-name|Use 'something.else' instead");
    editor.assertProblems("alt-name|No good anymore");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 27 with IJavaProject

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

the class ApplicationYamlEditorTest method testHoverInfoForEnumValueInMapKey.

@Test
public void testHoverInfoForEnumValueInMapKey() throws Exception {
    Editor editor;
    IJavaProject project = createPredefinedMavenProject("empty-boot-1.3.0-app");
    useProject(project);
    // This test will fail if source jars haven't been downloaded.
    // Probably that is why it fails in CI build?
    // Let's check:
    // IType type = project.findType("com.fasterxml.jackson.databind.SerializationFeature");
    // System.out.println(">>> source for: "+type.getFullyQualifiedName());
    // System.out.println(downloadSources(type));
    // System.out.println("<<< source for: "+type.getFullyQualifiedName());
    editor = newEditor("spring:\n" + "  jackson:\n" + "    serialization:\n" + "      indent-output: true");
    editor.assertIsHoverRegion("indent-output");
    editor.assertHoverContains("indent-output", "allows enabling (or disabling) indentation");
    // Also try that it works when spelled in all upper-case
    editor = newEditor("spring:\n" + "  jackson:\n" + "    serialization:\n" + "      INDENT_OUTPUT: true");
    editor.assertIsHoverRegion("INDENT_OUTPUT");
    editor.assertHoverContains("INDENT_OUTPUT", "allows enabling (or disabling) indentation");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 28 with IJavaProject

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

the class ActuatorWarningHoverTest method noWarningIf_ActuatorOnClasspath.

@Test
public void noWarningIf_ActuatorOnClasspath() throws Exception {
    // Has running app:
    mockAppProvider.builder().isSpringBootApp(true).processId("22022").processName("foo.bar.RunningApp").profilesUnknown().build();
    // Actuator on classpath:
    String projectName = ACTUATOR_PROJECT;
    IJavaProject project = projects.mavenProject(projectName);
    harness.useProject(project);
    harness.intialize(null);
    Editor editor = harness.newEditor(LanguageId.JAVA, "package hello;\n" + "\n" + "import org.springframework.context.annotation.Bean;\n" + "import org.springframework.context.annotation.Configuration;\n" + "import org.springframework.context.annotation.Profile;\n" + "\n" + "@Configuration\n" + "public class LocalConfig {\n" + "	\n" + "	@Bean\n" + "	Foo myFoo() {\n" + "		return new FooImplementation();\n" + "	}\n" + "}");
    editor.assertHighlights();
    editor.assertNoHover("@Bean");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 29 with IJavaProject

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

the class ActuatorWarningHoverTest method showWarningIf_NoActuator_and_RunningApp.

@Test
public void showWarningIf_NoActuator_and_RunningApp() throws Exception {
    // Has running app:
    mockAppProvider.builder().isSpringBootApp(true).processId("22022").processName("foo.bar.RunningApp").profilesUnknown().build();
    // No actuator on classpath:
    String projectName = NO_ACTUATOR_PROJECT;
    IJavaProject project = projects.mavenProject(projectName);
    harness.useProject(project);
    harness.intialize(null);
    Editor editor = harness.newEditor(LanguageId.JAVA, "package hello;\n" + "\n" + "import org.springframework.context.annotation.Configuration;\n" + "import org.springframework.context.annotation.Profile;\n" + "\n" + "@Configuration\n" + "@Profile({\"local-profile\", \"inactive\", \"testing-profile\"})\n" + "public class LocalConfig {\n" + "}");
    editor.assertHighlights();
    editor.assertHoverContains("@Profile", "No live hover information");
    editor.assertHoverContains("@Profile", "Consider adding `spring-boot-actuator` as a dependency to your project `" + projectName + "`");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 30 with IJavaProject

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

the class PropertiesIndexTest method springStandardPropertyPresent_Maven.

@Test
public void springStandardPropertyPresent_Maven() throws Exception {
    SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager(ValueProviderRegistry.getDefault(), null);
    IJavaProject mavenProject = projects.mavenProject(CUSTOM_PROPERTIES_PROJECT);
    FuzzyMap<PropertyInfo> index = indexManager.get(mavenProject, progressService);
    PropertyInfo propertyInfo = index.get("server.port");
    assertNotNull(propertyInfo);
    assertEquals(Integer.class.getName(), propertyInfo.getType());
    assertEquals("port", propertyInfo.getName());
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Test(org.junit.Test)

Aggregations

IJavaProject (org.springframework.ide.vscode.commons.java.IJavaProject)63 Test (org.junit.Test)52 AbstractPropsEditorTest (org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest)35 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)24 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)8 Ignore (org.junit.Ignore)8 IClasspath (org.springframework.ide.vscode.commons.java.IClasspath)7 TextDocument (org.springframework.ide.vscode.commons.util.text.TextDocument)7 File (java.io.File)6 Path (java.nio.file.Path)6 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)6 URI (java.net.URI)5 Map (java.util.Map)5 Listener (org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener)5 Stream (java.util.stream.Stream)4 JavaCore (org.eclipse.jdt.core.JavaCore)4 AST (org.eclipse.jdt.core.dom.AST)4 ASTParser (org.eclipse.jdt.core.dom.ASTParser)4 JavaProjectFinder (org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder)4 List (java.util.List)3