Search in sources :

Example 31 with IJavaProject

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

the class PropertiesIndexTest method springStandardPropertyPresent_ClasspathFile.

@Test
public void springStandardPropertyPresent_ClasspathFile() throws Exception {
    SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager(ValueProviderRegistry.getDefault(), null);
    IJavaProject classpathFileProject = projects.javaProjectWithClasspathFile(CUSTOM_PROPERTIES_PROJECT);
    FuzzyMap<PropertyInfo> index = indexManager.get(classpathFileProject, 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)

Example 32 with IJavaProject

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

the class PropertiesIndexTest method customPropertyPresent_ClasspathFile.

@Test
public void customPropertyPresent_ClasspathFile() throws Exception {
    SpringPropertiesIndexManager indexManager = new SpringPropertiesIndexManager(ValueProviderRegistry.getDefault(), null);
    IJavaProject classpathFileProject = projects.javaProjectWithClasspathFile(CUSTOM_PROPERTIES_PROJECT);
    FuzzyMap<PropertyInfo> index = indexManager.get(classpathFileProject, progressService);
    PropertyInfo propertyInfo = index.get("demo.settings.user");
    assertNotNull(propertyInfo);
    assertEquals(String.class.getName(), propertyInfo.getType());
    assertEquals("user", propertyInfo.getName());
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Test(org.junit.Test)

Example 33 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testEnumPropertyCompletion.

@Test
public void testEnumPropertyCompletion() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Color"));
    data("foo.color", "demo.Color", null, "A foonky colour");
    // Should add the '=' because enums are 'simple' values.
    assertCompletion("foo.c<*>", "foo.color=<*>");
    assertCompletion("foo.color=R<*>", "foo.color=RED<*>");
    assertCompletion("foo.color=G<*>", "foo.color=GREEN<*>");
    assertCompletion("foo.color=B<*>", "foo.color=BLUE<*>");
    assertCompletionsDisplayString("foo.color=<*>", "red", "green", "blue");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 34 with IJavaProject

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

the class ApplicationPropertiesEditorTest method doCommaCollectionReconcileTest.

private void doCommaCollectionReconcileTest(String collectionType) throws Exception {
    Editor editor;
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Color"));
    data("my.colors", collectionType + "<demo.Color>", null, "Ooh! nice colors!");
    editor = newEditor("#comment\n" + "my.colors=RED, green, not-a-color , BLUE");
    editor.assertProblems("not-a-color|demo.Color");
    editor = newEditor("my.colors=\\\n" + "	red , \\\n" + "	green,\\\n" + "	bad\n");
    editor.assertProblems("bad|demo.Color");
    editor = newEditor("my.colors=\\\n" + "	red,\\\n" + "	green,\\\n" + "	blue\n");
    editor.assertProblems();
    editor = newEditor("my.colors=\\\n" + "	bad,\\\n" + "	green,\\\n" + "	blue\n");
    editor.assertProblems("bad|demo.Color");
    editor = newEditor("my.colors=\\\n" + "	bad , \\\n" + "	green,\\\n" + "	blue\n");
    editor.assertProblems("bad|demo.Color");
    editor = newEditor("my.colors=\\\n" + "	red , \\\n" + "	green,\\\n" + "	bad   \n");
    editor.assertProblems("bad|demo.Color");
    editor = newEditor("my.colors=red,\n");
    editor.assertProblems(",|demo.Color");
    editor = newEditor("my.colors=red, \n");
    editor.assertProblems(" |demo.Color");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor)

Example 35 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testMapKeyDotInterpretationInPojo.

@Test
public void testMapKeyDotInterpretationInPojo() throws Exception {
    // Similar to testMapKeyDotInterpretation but this time maps are not attached to property
    // directly but via a pojo property
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Color"));
    assertNotNull(p.getClasspath().findType("demo.ColorData"));
    Editor editor = newEditor("foo.color-names.BLUE.dot=Blauw\n" + "foo.color-data.RED.name=Good\n" + "foo.color-data.GREEN.bad=Bad\n" + "foo.color-data.GREEN.wrong[1]=Wrong\n");
    editor.assertProblems(// dot is eaten so this is an error
    "BLUE.dot|Color", // dot not eaten so '.bad' is accessing a property
    "bad|no property", "wrong|no property");
    assertCompletionsVariations("foo.color-data.RED.ch<*>", "foo.color-data.RED.children[<*>", "foo.color-data.RED.color-children.<*>", "foo.color-data.RED.mapped-children.<*>");
}
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)

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