Search in sources :

Example 41 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testNavigationProposalAfterRelaxedPropertyName.

@Test
public void testNavigationProposalAfterRelaxedPropertyName() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertCompletionsVariations("foo.colorData.b<*>", "foo.colorData.blue.<*>");
    assertCompletionsVariations("foo.colorData.red.na<*>", "foo.colorData.red.name=<*>");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 42 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testEnumPropertyReconciling.

@Test
public void testEnumPropertyReconciling() 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");
    Editor editor = newEditor("foo.color=BLUE\n" + "foo.color=RED\n" + "foo.color=GREEN\n" + "foo.color.bad=BLUE\n" + "foo.color=Bogus\n");
    // ignore deliberate abuse of dups
    editor.ignoreProblem(PROP_DUPLICATE_KEY);
    editor.assertProblems(".bad|Can't use '.' navigation", "Bogus|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 43 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testEnumMapKeyCompletion.

@Test
public void testEnumMapKeyCompletion() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    data("foo.color-names", "java.util.Map<demo.Color,java.lang.String>", null, "Map with colors in its keys");
    data("foo.color-data", "java.util.Map<demo.Color,demo.ColorData>", null, "Map with colors in its keys, and pojo in values");
    assertNotNull(p.getClasspath().findType("demo.Color"));
    assertNotNull(p.getClasspath().findType("demo.ColorData"));
    // Map Enum -> String:
    assertCompletionsVariations("foo.colnam<*>", "foo.color-names.<*>");
    assertCompletionsVariations("foo.color-names.<*>", "foo.color-names.blue=<*>", "foo.color-names.green=<*>", "foo.color-names.red=<*>");
    assertCompletionsDisplayStringAndDetail("foo.color-names.<*>", new String[] { "blue", "String" }, new String[] { "green", "String" }, new String[] { "red", "String" });
    assertCompletionsVariations("foo.color-names.B<*>", "foo.color-names.BLUE=<*>");
    // Map Enum -> Pojo:
    assertCompletionsVariations("foo.coldat<*>", "foo.color-data.<*>");
    assertCompletionsVariations("foo.color-data.<*>", "foo.color-data.blue.<*>", "foo.color-data.green.<*>", "foo.color-data.red.<*>");
    assertCompletionsVariations("foo.color-data.B<*>", "foo.color-data.BLUE.<*>");
    assertCompletionsDisplayStringAndDetail("foo.color-data.<*>", new String[] { "blue", "demo.ColorData" }, new String[] { "green", "demo.ColorData" }, new String[] { "red", "demo.ColorData" });
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 44 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testDeprecatedBeanPropertyCompletions.

@Ignore
@Test
public void testDeprecatedBeanPropertyCompletions() throws Exception {
    IJavaProject p = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
    useProject(p);
    data("foo", "demo.Deprecater", null, "A Bean with deprecated properties");
    assertStyledCompletions("foo.nam<*>", StyledStringMatcher.plainFont("new-name : String"), StyledStringMatcher.strikeout("name"), StyledStringMatcher.strikeout("alt-name"));
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Ignore(org.junit.Ignore) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 45 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testEnumMapValueCompletion.

@Test
public void testEnumMapValueCompletion() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Color"));
    assertCompletionsVariations("foo.nam<*>", "foo.name-colors.<*>", "foo.color-names.<*>");
    assertCompletionsDisplayString("foo.name-colors.something=<*>", "red", "green", "blue");
    assertCompletionsVariations("foo.name-colors.something=G<*>", "foo.name-colors.something=GREEN<*>");
}
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