use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.
the class CompilationUnitCacheTest method cu_cache_invalidated_by_doc_close.
@Test
public void cu_cache_invalidated_by_doc_close() throws Exception {
harness = BootJavaLanguageServerHarness.builder().mockDefaults().build();
harness.useProject(new IJavaProject() {
@Override
public IClasspath getClasspath() {
return new DelegatingCachedClasspath<>(() -> null, null);
}
});
harness.intialize(null);
TextDocument doc = new TextDocument(harness.createTempUri(), LanguageId.JAVA, 0, "package my.package\n" + "\n" + "public class SomeClass {\n" + "\n" + "}\n");
harness.newEditorFromFileUri(doc.getUri(), doc.getLanguageId());
CompilationUnit cu = getCompilationUnit(doc);
assertNotNull(cu);
harness.closeDocument(doc.getId());
CompilationUnit cuAnother = getCompilationUnit(doc);
assertNotNull(cuAnother);
assertFalse(cu == cuAnother);
CompilationUnit cuYetAnother = getCompilationUnit(doc);
assertTrue(cuAnother == cuYetAnother);
}
use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.
the class ApplicationPropertiesEditorTest method testPojoArrayCompletions.
@Test
public void testPojoArrayCompletions() throws Exception {
IJavaProject p = createPredefinedMavenProject("boot-1.2.1-app-properties-list-of-pojo");
useProject(p);
assertNotNull(p.getClasspath().findType("demo.Foo"));
assertCompletionsVariations("volder.foo.l<*>", "volder.foo.list[<*>");
assertCompletionsDisplayStringAndDetail("volder.foo.list[0].<*>", new String[] { "description", "String" }, new String[] { "name", "String" }, new String[] { "roles", "List<String>" });
assertCompletionsVariations("volder.foo.list[0].na<*>", "volder.foo.list[0].name=<*>");
assertCompletionsVariations("volder.foo.list[0].d<*>", "volder.foo.list[0].description=<*>");
assertCompletionsVariations("volder.foo.list[0].rl<*>", "volder.foo.list[0].roles=<*>");
}
use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.
the class ApplicationPropertiesEditorTest method testPredefinedProject.
@Test
public void testPredefinedProject() throws Exception {
IJavaProject p = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
IType type = p.getClasspath().findType("demo.DemoApplication");
assertNotNull(type);
}
use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.
the class ApplicationPropertiesEditorTest method testEnumsInLowerCaseReconciling.
@Test
public void testEnumsInLowerCaseReconciling() 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");
Editor editor = newEditor("simple.pants.size=NOT_A_SIZE\n" + "simple.pants.size=EXTRA_SMALL\n" + "simple.pants.size=extra-small\n" + "simple.pants.size=small\n" + "simple.pants.size=SMALL\n");
// ignore deliberate abuse of dups
editor.ignoreProblem(PROP_DUPLICATE_KEY);
editor.assertProblems("NOT_A_SIZE|ClothingSize");
editor = newEditor("foo.color-names.red=Rood\n" + "foo.color-names.green=Groen\n" + "foo.color-names.blue=Blauw\n" + "foo.color-names.not-a-color=Wrong\n" + "foo.color-names.blue.bad=Blauw\n");
editor.assertProblems("not-a-color|Color", // because value type is not dotable the dots will be taken to be part of map key
"blue.bad|Color");
editor = newEditor("foo.color-data.red.next=green\n" + "foo.color-data.green.next=not a color\n" + "foo.color-data.red.bogus=green\n" + "foo.color-data.red.name=Rood\n");
editor.assertProblems("not a color|Color", "bogus|no property");
}
use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.
the class ApplicationPropertiesEditorTest method testReconcilePojoArray.
@Test
public void testReconcilePojoArray() throws Exception {
IJavaProject p = createPredefinedMavenProject("boot-1.2.1-app-properties-list-of-pojo");
useProject(p);
assertNotNull(p.getClasspath().findType("demo.Foo"));
Editor editor = newEditor("token.bad.guy=problem\n" + "volder.foo.list[0].name=Kris\n" + "volder.foo.list[0].description=Kris\n" + "volder.foo.list[0].roles[0]=Developer\n" + "volder.foo.list[0]garbage=Grable\n" + "volder.foo.list[0].bogus=Bad\n");
// This is the more ambitious requirement but it is not implemented yet.
editor.assertProblems("token.bad.guy|unknown property", // 'description' is ok
"garbage|'.' or '['", "bogus|has no property");
}
Aggregations