Tweak value hint providers in application.properties

See https://www.pivotaltracker.com/story/show/161964105
This commit is contained in:
Kris De Volder
2018-11-15 10:41:55 -08:00
parent 706a870fae
commit f39b845964
5 changed files with 51 additions and 8 deletions

View File

@@ -14,6 +14,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -149,15 +150,22 @@ public abstract class AbstractPropsEditorTest {
private CompletionItem assertCompletionWithLabel(String expectLabel, List<CompletionItem> completions) {
StringBuilder found = new StringBuilder();
List<CompletionItem> matching = new ArrayList<CompletionItem>();
for (CompletionItem c : completions) {
String actualLabel = c.getLabel();
found.append(actualLabel+"\n");
if (actualLabel.equals(expectLabel)) {
return c;
matching.add(c);
}
}
fail("No completion found with label '"+expectLabel+"' in:\n"+found);
return null; //unreachable, but compiler doesn't know that.
if (matching.isEmpty()) {
fail("No completion found with label '"+expectLabel+"' in:\n"+found);
} else if (matching.size() > 1) {
fail("Multiple completion found with identical label '"+expectLabel+"' in:\n"+found);
} else {
return matching.get(0);
}
return null;
}
public void assertCompletionCount(int expected, String editorText) throws Exception {

View File

@@ -10,6 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.springframework.ide.vscode.boot.properties.reconcile.ApplicationPropertiesProblemType.PROP_DUPLICATE_KEY;
@@ -1150,7 +1151,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
);
}
@Test public void userDefinedLoggerGroups() throws Exception {
@Test public void userDefinedLoggingGroups() throws Exception {
useProject(createPredefinedMavenProject("empty-boot-2.1.0-app"));
adHocProperties.add("logging.group.foobar");
@@ -1184,6 +1185,34 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
}
@Test public void userDefinedLoggingGroupsValueCompletions() throws Exception {
useProject(createPredefinedMavenProject("empty-boot-2.1.0-app"));
assertCompletionWithLabel(
"logging.group.whatever=demo<*>"
, //==============
"com.example.demo",
//=>
"logging.group.whatever=com.example.demo<*>"
);
assertCompletionWithLabel(
"logging.group.whatever=stuff,demo<*>"
, //==============
"com.example.demo",
//=>
"logging.group.whatever=stuff,com.example.demo<*>"
);
assertCompletionWithLabel(
"logging.group.whatever[0]=demo<*>"
, //==============
"com.example.demo",
//=>
"logging.group.whatever[0]=com.example.demo<*>"
);
}
@Test public void testPropertyMapKeyCompletions() throws Exception {
useProject(createPredefinedMavenProject("empty-boot-2.1.0-app"));
assertCompletionWithLabel(