Search in sources :

Example 21 with IJavaProject

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

the class ApplicationPropertiesEditorTest method testEnumsInLowerCaseContentAssist.

@Test
public void testEnumsInLowerCaseContentAssist() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.ClothingSize"));
    data("simple.pants.size", "demo.ClothingSize", null, "The simple pant's size");
    assertCompletionsVariations("simple.pants.size=S<*>", "simple.pants.size=SMALL<*>", "simple.pants.size=EXTRA_SMALL<*>");
    assertCompletionsVariations("simple.pants.size=s<*>", "simple.pants.size=small<*>", "simple.pants.size=extra-small<*>");
    assertCompletionsVariations("simple.pants.size=ex<*>", "simple.pants.size=extra-large<*>", "simple.pants.size=extra-small<*>");
    assertCompletionsVariations("simple.pants.size=EX<*>", "simple.pants.size=EXTRA_LARGE<*>", "simple.pants.size=EXTRA_SMALL<*>");
    assertCompletionsDisplayString("foo.color=<*>", "red", "green", "blue");
    assertCompletionsVariations("foo.color-data.R<*>", "foo.color-data.RED.<*>", "foo.color-data.GREEN.<*>");
    assertCompletionsVariations("foo.color-data.r<*>", "foo.color-data.red.<*>", "foo.color-data.green.<*>");
    assertCompletionsVariations("foo.color-data.<*>", "foo.color-data.blue.<*>", "foo.color-data.green.<*>", "foo.color-data.red.<*>");
    assertCompletionsVariations("foo.color-data.red.na<*>", "foo.color-data.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 22 with IJavaProject

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

the class ApplicationYamlEditorTest method testReconcileBeanPropName.

@Test
public void testReconcileBeanPropName() throws Exception {
    IJavaProject p = createPredefinedMavenProject("boot-1.2.1-app-properties-list-of-pojo");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Foo"));
    data("some-foo", "demo.Foo", null, "some Foo pojo property");
    Editor editor = newEditor("some-foo:\n" + "  name: Good\n" + "  bogus: Bad\n" + "  ? - a\n" + "    - b\n" + "  : Weird\n");
    editor.assertProblems("bogus|Unknown property 'bogus' for type 'demo.Foo'", "- a\n    - b|Expecting a bean-property name for object of type 'demo.Foo' " + "but got a 'Sequence' node");
}
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 23 with IJavaProject

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

the class ApplicationYamlEditorTest method testDeprecatedBeanPropertyHoverInfo.

@Ignore
@Test
public void testDeprecatedBeanPropertyHoverInfo() throws Exception {
    IJavaProject jp = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
    useProject(jp);
    data("foo", "demo.Deprecater", null, "A bean with deprecated property.");
    Editor editor = newEditor("# a comment\n" + "foo:\n" + "  name: foo\n");
    editor.assertHoverContains("name", "<b>Deprecated!</b>");
}
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 24 with IJavaProject

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

the class ApplicationYamlEditorTest method testDeprecatedBeanPropertyCompletions.

@Ignore
@Test
public void testDeprecatedBeanPropertyCompletions() throws Exception {
    IJavaProject jp = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
    useProject(jp);
    data("foo", "demo.Deprecater", null, "A Bean with deprecated properties");
    assertStyledCompletions("foo:\n" + "  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 25 with IJavaProject

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

the class ApplicationYamlEditorTest method testHoverInfoForEnumValueInMapKeyCompletion.

@Test
public void testHoverInfoForEnumValueInMapKeyCompletion() throws Exception {
    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());
    assertCompletionDetails("spring:\n" + "  jackson:\n" + "    serialization:\n" + "      ind<*>", // ==========
    "indent-output", // ==>
    "boolean", "allows enabling (or disabling) indentation");
}
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