Search in sources :

Example 51 with IJavaProject

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

the class ApplicationYamlEditorTest method testEnumsInLowerCaseContentAssist.

@Ignore
@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");
    assertCompletions("simple:\n" + "  pants:\n" + "    size: S<*>", "simple:\n" + "  pants:\n" + "    size: SMALL<*>", "simple:\n" + "  pants:\n" + "    size: EXTRA_SMALL<*>");
    assertCompletions("simple:\n" + "  pants:\n" + "    size: s<*>", "simple:\n" + "  pants:\n" + "    size: small<*>", "simple:\n" + "  pants:\n" + "    size: extra-small<*>");
    assertCompletions("simple:\n" + "  pants:\n" + "    size: ex<*>", // =>
    "simple:\n" + "  pants:\n" + "    size: extra-large<*>", // or
    "simple:\n" + "  pants:\n" + "    size: extra-small<*>");
    assertCompletions("simple:\n" + "  pants:\n" + "    size: EX<*>", // =>
    "simple:\n" + "  pants:\n" + "    size: EXTRA_LARGE<*>", // or
    "simple:\n" + "  pants:\n" + "    size: EXTRA_SMALL<*>");
    assertCompletionsDisplayString("foo:\n  color: <*>", "red", "green", "blue");
    assertCompletions("foo:\n  color-data: B<*>", "foo:\n  color-data: \n    BLUE:\n      <*>");
    assertCompletions("foo:\n  color-data: b<*>", "foo:\n  color-data: \n    blue:\n      <*>");
    assertCompletions("foo:\n  color-data: <*>", "foo:\n  color-data: \n    blue:\n      <*>", "foo:\n  color-data: \n    green:\n      <*>", "foo:\n  color-data: \n    red:\n      <*>");
    assertCompletions("foo:\n" + "  color-data:\n" + "    red: na<*>", "foo:\n" + "  color-data:\n" + "    red: \n" + "      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 52 with IJavaProject

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

the class ApplicationYamlEditorTest method test_STS4231.

@Ignore
@Test
public void test_STS4231() throws Exception {
    // Should the 'predefined' project need to be recreated... use the commented code below:
    // BootProjectTestHarness projectHarness = new BootProjectTestHarness(ResourcesPlugin.getWorkspace());
    // IJavaProject project = projectHarness.createBootProject("boot-1.3.0-app-sts-4231",
    // bootVersionAtLeast("1.3.0"),
    // withStarters("web", "cloud-config-server")
    // );
    // For more robust test use predefined project which is not so much a moving target:
    IJavaProject project = createPredefinedMavenProject("boot-1.3.0-app-sts-4231");
    useProject(project);
    assertCompletionsDisplayString("info:\n" + "  component: Config Server\n" + "spring:\n" + "  application:\n" + "    name: configserver\n" + "  jmx:\n" + "    default-domain: cloud.config.server\n" + "  cloud:\n" + "    config:\n" + "      server:\n" + "        git:\n" + "          uri: https://github.com/spring-cloud-samples/config-repo\n" + "          repos:\n" + "            my-repo:\n" + "              <*>\n", // ==>
    "name : String", "pattern : String[]");
    assertCompletion("info:\n" + "  component: Config Server\n" + "spring:\n" + "  application:\n" + "    name: configserver\n" + "  jmx:\n" + "    default-domain: cloud.config.server\n" + "  cloud:\n" + "    config:\n" + "      server:\n" + "        git:\n" + "          uri: https://github.com/spring-cloud-samples/config-repo\n" + "          repos:\n" + "            my-repo:\n" + "              p<*>\n", // ==>
    "info:\n" + "  component: Config Server\n" + "spring:\n" + "  application:\n" + "    name: configserver\n" + "  jmx:\n" + "    default-domain: cloud.config.server\n" + "  cloud:\n" + "    config:\n" + "      server:\n" + "        git:\n" + "          uri: https://github.com/spring-cloud-samples/config-repo\n" + "          repos:\n" + "            my-repo:\n" + "              pattern:\n" + "              - <*>\n");
}
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 53 with IJavaProject

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

the class ApplicationYamlEditorTest method testContentAssistCamelCaseBeanProp.

@Test
public void testContentAssistCamelCaseBeanProp() throws Exception {
    IJavaProject p = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
    useProject(p);
    data("demo.bean", "demo.CamelCaser", "For testing tolerance of camelCase", null);
    assertCompletion("demo:\n" + "  bean:\n" + "    theLeft:\n" + "      answer<*>\n", // =>
    "demo:\n" + "  bean:\n" + "    theLeft:\n" + "      the-answer-to-everything: <*>\n");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 54 with IJavaProject

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

the class PropertiesIndexTest method propertyNotPresent_ClasspathFile.

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

Example 55 with IJavaProject

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

the class PropertiesIndexTest method customPropertyPresent_Maven.

@Test
public void customPropertyPresent_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("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)

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