Search in sources :

Example 56 with IJavaProject

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

the class PropertiesIndexTest method propertyNotPresent_Maven.

@Test
public void propertyNotPresent_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("my.server.port");
    assertNull(propertyInfo);
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Test(org.junit.Test)

Example 57 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testMapKeyDotInterpretation.

@Test
public void testMapKeyDotInterpretation() throws Exception {
    // Interpretation of '.' changes depending on the domain type (i.e. when domain type is
    // is a simple type got which '.' navigation is invalid then the '.' is 'eaten' by the key.
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Color"));
    assertNotNull(p.getClasspath().findType("demo.ColorData"));
    data("atommap", "java.util.Map<java.lang.String,java.lang.Integer>", null, "map of atomic data");
    data("objectmap", "java.util.Map<java.lang.String,java.lang.Object>", null, "map of atomic object (recursive map)");
    data("enummap", "java.util.Map<java.lang.String,demo.Color>", null, "map of enums");
    data("pojomap", "java.util.Map<java.lang.String,demo.ColorData>", null, "map of pojos");
    Editor editor = newEditor("atommap.something.with.dots=Vaporize\n" + "atommap.something.with.bracket[0]=Brackelate\n" + "objectmap.other.with.dots=Objectify\n" + "enummap.more.dots=Enumerate\n" + "pojomap.do.some.dots=Pojodot\n" + "pojomap.bracket.and.dots[1]=lala\n" + "pojomap.zozo[2]=lala\n");
    editor.assertProblems("Vaporize|'int'", "[0]|Can't use '[..]'", // objectmap okay
    "Enumerate|Color", "some|no property", "and|no property", "[2]|Can't use '[..]'");
    assertCompletionsVariations("enummap.more.dots=R<*>", "enummap.more.dots=RED<*>", // fuzzy match: G(R)EEN
    "enummap.more.dots=GREEN<*>");
}
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 58 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testHyperlinkTargets.

@Ignore
@Test
public void testHyperlinkTargets() throws Exception {
    System.out.println(">>> testHyperlinkTargets");
    IJavaProject p = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
    useProject(p);
    Editor editor = newEditor("server.port=888\n" + "spring.datasource.login-timeout=1000\n" + "flyway.init-sqls=a,b,c\n");
    editor.assertLinkTargets("server", "org.springframework.boot.autoconfigure.web.ServerProperties.setPort(Integer)");
    editor.assertLinkTargets("data", "org.springframework.boot.autoconfigure.jdbc.DataSourceConfigMetadata.hikariDataSource()", "org.springframework.boot.autoconfigure.jdbc.DataSourceConfigMetadata.tomcatDataSource()", "org.springframework.boot.autoconfigure.jdbc.DataSourceConfigMetadata.dbcpDataSource()");
    editor.assertLinkTargets("flyway", "org.springframework.boot.autoconfigure.flyway.FlywayProperties.setInitSqls(List<String>)");
    System.out.println("<<< testHyperlinkTargets");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Ignore(org.junit.Ignore) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 59 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testDeprecatedBeanPropertyReconcile.

@Test
public void testDeprecatedBeanPropertyReconcile() throws Exception {
    IJavaProject p = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
    useProject(p);
    data("foo", "demo.Deprecater", null, "A Bean with deprecated properties");
    Editor editor = newEditor("# comment\n" + "foo.name=Old faithfull\n" + "foo.new-name=New and fancy\n" + "foo.alt-name=alternate\n");
    editor.assertProblems("name|Deprecated", "alt-name|Property 'alt-name' of type 'demo.Deprecater' is Deprecated: Use 'something.else' instead. Reason: 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 60 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testValueProposalAssignedToRelaxedPropertyName.

@Test
public void testValueProposalAssignedToRelaxedPropertyName() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    data("relaxed-color", "demo.Color", null, "A soothing color");
    assertCompletion("relaxed-color=b<*>", "relaxed-color=blue<*>");
    assertCompletion("relaxedColor=b<*>", "relaxedColor=blue<*>");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) 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