Nested enums tests for properties and yaml
This commit is contained in:
@@ -883,6 +883,31 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
"Bogus|Color"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNestedEnumPropertyListCompletion() throws Exception {
|
||||
IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
|
||||
|
||||
useProject(p);
|
||||
assertNotNull(p.getIndex().findType("demo.C"));
|
||||
assertNotNull(p.getIndex().findType("demo.C$E"));
|
||||
|
||||
assertCompletionsVariations("nested-enum.list-properties[0].<*>",
|
||||
"nested-enum.list-properties[0].enum-value=<*>",
|
||||
"nested-enum.list-properties[0].list-of-enums=<*>"
|
||||
);
|
||||
|
||||
assertCompletionsDisplayString("nested-enum.list-properties[0].list-of-enums=<*>",
|
||||
"no", "yes"
|
||||
);
|
||||
assertCompletionsDisplayString("nested-enum.list-properties[0].list-of-enums=yes,<*>",
|
||||
"no", "yes"
|
||||
);
|
||||
assertCompletionsDisplayString("nested-enum.list-properties[0].enum-value=<*>",
|
||||
"no", "yes"
|
||||
);
|
||||
assertCompletionsVariations("nested-enum.list-properties[0].list-of-enums=yes,n<*>", "nested-enum.list-properties[0].list-of-enums=yes,no<*>");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEnumMapValueCompletion() throws Exception {
|
||||
|
||||
@@ -2390,6 +2390,21 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
"red", "green", "blue"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNestedEnumValueCompletion() throws Exception {
|
||||
useProject(createPredefinedMavenProject("enums-boot-1.3.2-app"));
|
||||
|
||||
assertCompletion("nested-enum:\n list-properties:\n - e<*>", "nested-enum:\n list-properties:\n - enum-value: <*>");
|
||||
assertCompletion("nested-enum:\n list-properties:\n - li<*>", "nested-enum:\n list-properties:\n - list-of-enums:\n - <*>");
|
||||
|
||||
assertCompletion("nested-enum:\n list-properties:\n - enum-value: y<*>", "nested-enum:\n list-properties:\n - enum-value: yes<*>");
|
||||
assertCompletion("nested-enum:\n list-properties:\n - list-of-enums:\n - n<*>", "nested-enum:\n list-properties:\n - list-of-enums:\n - no<*>");
|
||||
|
||||
assertCompletionsDisplayString("nested-enum:\n list-properties:\n - list-of-enums:\n - <*>",
|
||||
"no", "yes"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEnumMapValueCompletion() throws Exception {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package demo;
|
||||
|
||||
public class C {
|
||||
|
||||
public enum E {
|
||||
/**
|
||||
* Javadoc for YES here
|
||||
*/
|
||||
YES,
|
||||
|
||||
/**
|
||||
* Javadoc for NO here
|
||||
*/
|
||||
NO
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package demo;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ConfigurationProperties(prefix = ExampleProperties.PREFIX)
|
||||
@Validated
|
||||
public class ExampleProperties {
|
||||
|
||||
public static final String PREFIX = "nested-enum";
|
||||
|
||||
public C.E enumValue;
|
||||
|
||||
private Set<C.E> listOfEnums;
|
||||
|
||||
private Set<SomeProperties> listProperties;
|
||||
|
||||
private Map<String, SomeProperties> mapProperties;
|
||||
|
||||
public C.E getEnumValue() {
|
||||
return enumValue;
|
||||
}
|
||||
|
||||
public void setEnumValue(C.E enumValue) {
|
||||
this.enumValue = enumValue;
|
||||
}
|
||||
|
||||
public Set<C.E> getListOfEnums() {
|
||||
return listOfEnums;
|
||||
}
|
||||
|
||||
public void setListOfEnums(Set<C.E> listOfEnums) {
|
||||
this.listOfEnums = listOfEnums;
|
||||
}
|
||||
|
||||
public Set<SomeProperties> getListProperties() {
|
||||
return listProperties;
|
||||
}
|
||||
|
||||
public void setListProperties(Set<SomeProperties> listProperties) {
|
||||
this.listProperties = listProperties;
|
||||
}
|
||||
|
||||
public Map<String, SomeProperties> getMapProperties() {
|
||||
return mapProperties;
|
||||
}
|
||||
|
||||
public void setMapProperties(Map<String, SomeProperties> mapProperties) {
|
||||
this.mapProperties = mapProperties;
|
||||
}
|
||||
|
||||
public static class SomeProperties {
|
||||
private C.E enumValue;
|
||||
private Set<C.E> listOfEnums;
|
||||
public C.E getEnumValue() {
|
||||
return enumValue;
|
||||
}
|
||||
public void setEnumValue(C.E enumValue) {
|
||||
this.enumValue = enumValue;
|
||||
}
|
||||
public Set<C.E> getListOfEnums() {
|
||||
return listOfEnums;
|
||||
}
|
||||
public void setListOfEnums(Set<C.E> listOfEnums) {
|
||||
this.listOfEnums = listOfEnums;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user