PT #160496285: Fix Properties TypeUtil to find inner enums in the index
This commit is contained in:
@@ -181,11 +181,21 @@ public abstract class AbstractPropsEditorTest {
|
||||
}
|
||||
|
||||
public void assertCompletionsDisplayString(String editorText, String... completionsLabels) throws Exception {
|
||||
assertCompletionsDisplayString(editorText, false, completionsLabels);
|
||||
}
|
||||
|
||||
public void assertCompletionsDisplayString(String editorText, boolean includeDetail, String... completionsLabels) throws Exception {
|
||||
Editor editor = newEditor(editorText);
|
||||
List<CompletionItem> completions = editor.getCompletions();
|
||||
String[] actualLabels = new String[completions.size()];
|
||||
for (int i = 0; i < actualLabels.length; i++) {
|
||||
actualLabels[i] = completions.get(i).getLabel();
|
||||
if (includeDetail) {
|
||||
String detail = completions.get(i).getDetail();
|
||||
if (detail != null && !detail.isEmpty()) {
|
||||
actualLabels[i] += " : " + detail;
|
||||
}
|
||||
}
|
||||
}
|
||||
assertElements(actualLabels, completionsLabels);
|
||||
}
|
||||
|
||||
@@ -1878,7 +1878,22 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Ignore @Test public void testEnumMapKeyCompletion() throws Exception {
|
||||
@Test public void testInnerTypeEnumMapKeyCompletion() throws Exception {
|
||||
useProject(createPredefinedMavenProject("enums-boot-1.3.2-app"));
|
||||
|
||||
data("foo.notes", "java.util.Map<demo.FooProperties.Weekdays,java.lang.String>", null, "Map weekdays to notes");
|
||||
|
||||
assertCompletionsDisplayString(
|
||||
"foo:\n" +
|
||||
" notes:\n" +
|
||||
" <*>",
|
||||
true,
|
||||
//=>
|
||||
"monday : String", "tuesday : String", "wednesday : String", "thursday : String", "friday : String", "saturday : String", "sunday : String"
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void testEnumMapKeyCompletion() throws Exception {
|
||||
useProject(createPredefinedMavenProject("enums-boot-1.3.2-app"));
|
||||
|
||||
data("foo.color-names", "java.util.Map<demo.Color,java.lang.String>", null, "Map with colors in its keys");
|
||||
@@ -1909,6 +1924,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
"foo:\n" +
|
||||
" color-names:\n" +
|
||||
" <*>",
|
||||
true,
|
||||
//=>
|
||||
"blue : String", "green : String", "red : String"
|
||||
);
|
||||
@@ -1981,12 +1997,14 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
"foo:\n" +
|
||||
" color-data:\n" +
|
||||
" <*>",
|
||||
true,
|
||||
"red : demo.ColorData", "green : demo.ColorData", "blue : demo.ColorData"
|
||||
);
|
||||
|
||||
assertCompletionsDisplayString(
|
||||
"foo:\n" +
|
||||
" color-data: <*>\n",
|
||||
true,
|
||||
"red : demo.ColorData", "green : demo.ColorData", "blue : demo.ColorData"
|
||||
);
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
@ConfigurationProperties("foo")
|
||||
public class FooProperties {
|
||||
|
||||
public enum Weekdays {
|
||||
MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY,SUNDAY
|
||||
}
|
||||
|
||||
/**
|
||||
* Pojo
|
||||
@@ -30,6 +34,8 @@ public class FooProperties {
|
||||
//Map Enum -> Pojo
|
||||
private Map<Color, ColorData> colorData;
|
||||
|
||||
private Map<Weekdays, String> notes;
|
||||
|
||||
//List
|
||||
private List<String> list;
|
||||
|
||||
@@ -70,4 +76,10 @@ public class FooProperties {
|
||||
public void setList(List<String> list) {
|
||||
this.list = list;
|
||||
}
|
||||
public Map<Weekdays, String> getNotes() {
|
||||
return notes;
|
||||
}
|
||||
public void setNotes(Map<Weekdays, String> notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user