Search in sources :

Example 16 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testPojoCompletions.

@Test
public void testPojoCompletions() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Color"));
    assertNotNull(p.getClasspath().findType("demo.ColorData"));
    assertCompletion("foo.dat<*>", "foo.data.<*>");
    assertCompletionsDisplayStringAndDetail("foo.data.", new String[] { "children", "List<demo.ColorData>" }, new String[] { "color-children", "Map<demo.Color[BLUE, GREEN, RED], demo.ColorData>" }, new String[] { "funky", "boolean" }, new String[] { "mapped-children", "Map<String, demo.ColorData>" }, new String[] { "name", "String" }, new String[] { "nested", "demo.ColorData" }, new String[] { "next", "demo.Color[BLUE, GREEN, RED]" }, new String[] { "tags", "List<String>" }, new String[] { "wavelen", "double" });
    assertCompletionsVariations("foo.data.wav<*>", "foo.data.wavelen=<*>");
    assertCompletionsVariations("foo.data.nam<*>", "foo.data.name=<*>");
    assertCompletionsVariations("foo.data.nex<*>", "foo.data.next=<*>");
    assertCompletionsVariations("foo.data.nes<*>", "foo.data.nested.<*>");
    assertCompletionsVariations("foo.data.chi<*>", "foo.data.children[<*>", // fuzzy
    "foo.data.color-children.<*>", // fuzzy
    "foo.data.mapped-children.<*>");
    assertCompletionsVariations("foo.data.tag<*>", "foo.data.tags=<*>");
    assertCompletionsVariations("foo.data.map<*>", "foo.data.mapped-children.<*>");
    assertCompletionsVariations("foo.data.col<*>", "foo.data.color-children.<*>");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 17 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testHyperlinkTargetsLoggingLevel.

@Ignore
@Test
public void testHyperlinkTargetsLoggingLevel() throws Exception {
    System.out.println(">>> testHyperlinkTargetsLoggingLevel");
    IJavaProject p = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
    useProject(p);
    Editor editor = newEditor("logging.level.com.acme=INFO\n");
    editor.assertLinkTargets("level", "org.springframework.boot.logging.LoggingApplicationListener");
    System.out.println("<<< testHyperlinkTargetsLoggingLevel");
}
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 18 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testEnumMapValueReconciling.

@Test
public void testEnumMapValueReconciling() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    data("foo.name-colors", "java.util.Map<java.lang.String,demo.Color>", null, "Map with colors in its values");
    assertNotNull(p.getClasspath().findType("demo.Color"));
    Editor editor = newEditor("foo.name-colors.jacket=BLUE\n" + "foo.name-colors.hat=RED\n" + "foo.name-colors.pants=GREEN\n" + "foo.name-colors.wrong=NOT_A_COLOR\n");
    editor.assertProblems("NOT_A_COLOR|Color");
}
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 19 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testEnumPropertyCompletionInsideCommaSeparateList.

@Test
public void testEnumPropertyCompletionInsideCommaSeparateList() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Color"));
    data("foo.colors", "java.util.List<demo.Color>", null, "A foonky list");
    // Completion requested right after '=' sign:
    assertCompletionsDisplayString("foo.colors=<*>", "red", "green", "blue");
    assertCompletionWithLabel("foo.colors=<*>", "red", "foo.colors=red<*>");
    assertCompletion("foo.colors=R<*>", "foo.colors=RED<*>");
    assertCompletion("foo.colors=g<*>", "foo.colors=green<*>");
    assertCompletion("foo.colors=B<*>", "foo.colors=BLUE<*>");
    // Completion requested after ','
    assertCompletionsDisplayString("foo.colors=red,<*>", "red", "green", "blue");
    assertCompletionWithLabel("foo.colors=red,<*>", "green", "foo.colors=red,green<*>");
    assertCompletion("foo.colors=RED,R<*>", "foo.colors=RED,RED<*>");
    assertCompletion("foo.colors=RED,G<*>", "foo.colors=RED,GREEN<*>");
    assertCompletion("foo.colors=RED,B<*>", "foo.colors=RED,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 20 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testPojoReconciling.

@Test
public void testPojoReconciling() throws Exception {
    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.data.bogus=Something\n" + "foo.data.wavelen=3.0\n" + "foo.data.wavelen=not a double\n" + "foo.data.wavelen.more=3.0\n" + "foo.data.wavelen[0]=3.0\n");
    // ignore deliberate abuse of dups
    editor.ignoreProblem(PROP_DUPLICATE_KEY);
    editor.assertProblems("bogus|no property", "not a double|'double'", ".more|Can't use '.' navigation", "[0]|Can't use '[..]' navigation");
}
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