Merge branch 'master' into spring-data-content-assist
This commit is contained in:
@@ -21,6 +21,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
@@ -136,6 +137,14 @@ public abstract class AbstractPropsEditorTest {
|
||||
assertCompletions(text /*NONE*/);
|
||||
}
|
||||
|
||||
public void assertNoCompletionWithLabel(String textBefore, String expectLabel) throws Exception {
|
||||
Editor editor = newEditor(textBefore);
|
||||
List<CompletionItem> completions = editor.getCompletions().stream().filter(c -> c.getLabel().equals(expectLabel)).collect(Collectors.toList());
|
||||
if (!completions.isEmpty()) {
|
||||
fail("Expecting no completions with label '"+expectLabel+"', but found some");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that completions contains a completion with a given display string (and check that
|
||||
* it applies as expected).
|
||||
|
||||
@@ -507,7 +507,7 @@ public class AutowiredHoverProviderTest {
|
||||
"}\n"
|
||||
);
|
||||
|
||||
editor.assertHighlights("@Component", "SomeComponent");
|
||||
editor.assertHighlights("@Component", "SomeComponent", "depA", "depB");
|
||||
|
||||
editor.assertTrimmedHover("SomeComponent", 2,
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
@@ -519,6 +519,25 @@ public class AutowiredHoverProviderTest {
|
||||
"Bean id: `someComponent` \n" +
|
||||
"Process [PID=111, name=`the-app`]\n"
|
||||
);
|
||||
|
||||
editor.assertTrimmedHover("depA", 2,
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
" \n" +
|
||||
"Bean id: `someComponent` \n" +
|
||||
"Process [PID=111, name=`the-app`]\n"
|
||||
);
|
||||
|
||||
editor.assertTrimmedHover("depB", 2,
|
||||
"**← `DependencyB`**\n" +
|
||||
"- Bean: `dependencyB` \n" +
|
||||
" Type: `com.example.DependencyB`\n" +
|
||||
" \n" +
|
||||
"Bean id: `someComponent` \n" +
|
||||
"Process [PID=111, name=`the-app`]\n"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -718,7 +737,7 @@ public class AutowiredHoverProviderTest {
|
||||
" private IDependency a;\n" +
|
||||
" private IDependency b;\n" +
|
||||
"\n" +
|
||||
" public SomeComponent(@Qualifier(\"dependencyA\") IDependency a, @Qualifier(\"dependencyB\") IDependency b) {\n" +
|
||||
" public SomeComponent(@Qualifier(\"dependencyA\") IDependency depA, @Qualifier(\"dependencyB\") IDependency depB) {\n" +
|
||||
" this.a = a;\n" +
|
||||
" this.b = b;\n" +
|
||||
" }\n" +
|
||||
@@ -726,7 +745,7 @@ public class AutowiredHoverProviderTest {
|
||||
"}\n"
|
||||
);
|
||||
|
||||
editor.assertHighlights("@Component", "SomeComponent");
|
||||
editor.assertHighlights("@Component", "SomeComponent", "depA", "depB");
|
||||
editor.assertTrimmedHover("SomeComponent", 2,
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
@@ -737,6 +756,25 @@ public class AutowiredHoverProviderTest {
|
||||
"Bean id: `someComponent` \n" +
|
||||
"Process [PID=111, name=`the-app`]\n"
|
||||
);
|
||||
|
||||
editor.assertTrimmedHover("depA",
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
" \n" +
|
||||
"Bean id: `someComponent` \n" +
|
||||
"Process [PID=111, name=`the-app`]\n"
|
||||
);
|
||||
|
||||
editor.assertTrimmedHover("depB",
|
||||
"**← `DependencyB`**\n" +
|
||||
"- Bean: `dependencyB` \n" +
|
||||
" Type: `com.example.DependencyB`\n" +
|
||||
" \n" +
|
||||
"Bean id: `someComponent` \n" +
|
||||
"Process [PID=111, name=`the-app`]\n"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -549,12 +549,12 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
"public class LocalConfig {\n" +
|
||||
" \n" +
|
||||
" @Bean(\"fooImplementation\")\n" +
|
||||
" Foo someFoo(DependencyA a) {\n" +
|
||||
" Foo someFoo(DependencyA depA) {\n" +
|
||||
" return new FooImplementation();\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertHighlights("@Bean", "depA");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `depA` \n" +
|
||||
@@ -563,6 +563,16 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]"
|
||||
);
|
||||
|
||||
editor.assertTrimmedHover("depA",
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `depA` \n" +
|
||||
" Type: `hello.DependencyA`\n" +
|
||||
" \n" +
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -603,12 +613,12 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
"public class LocalConfig {\n" +
|
||||
" \n" +
|
||||
" @Bean(\"fooImplementation\")\n" +
|
||||
" Foo someFoo(DependencyA a, DependencyB b) {\n" +
|
||||
" Foo someFoo(DependencyA depA, DependencyB depB) {\n" +
|
||||
" return new FooImplementation();\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertHighlights("@Bean", "depA", "depB");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `depA` \n" +
|
||||
@@ -619,6 +629,25 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]"
|
||||
);
|
||||
|
||||
editor.assertTrimmedHover("depA",
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `depA` \n" +
|
||||
" Type: `hello.DependencyA`\n" +
|
||||
" \n" +
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]"
|
||||
);
|
||||
|
||||
editor.assertTrimmedHover("depB",
|
||||
"**← `DependencyB`**\n" +
|
||||
"- Bean: `depB` \n" +
|
||||
" Type: `hello.DependencyB`\n" +
|
||||
" \n" +
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -664,7 +693,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
" }\n" +
|
||||
"}"
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertHighlights("@Bean", "deps");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `depA` \n" +
|
||||
@@ -675,7 +704,18 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]"
|
||||
);
|
||||
}
|
||||
|
||||
editor.assertTrimmedHover("deps",
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `depA` \n" +
|
||||
" Type: `hello.DependencyA`\n" +
|
||||
"- Bean: `depB` \n" +
|
||||
" Type: `hello.DependencyB`\n" +
|
||||
" \n" +
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanWithQualifierWiring() throws Exception {
|
||||
@@ -715,7 +755,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
" }\n" +
|
||||
"}"
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertHighlights("@Bean", "deps");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**← `DependencyB`**\n" +
|
||||
"- Bean: `depB` \n" +
|
||||
@@ -724,5 +764,15 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]"
|
||||
);
|
||||
|
||||
editor.assertTrimmedHover("deps",
|
||||
"**← `DependencyB`**\n" +
|
||||
"- Bean: `depB` \n" +
|
||||
" Type: `hello.DependencyB`\n" +
|
||||
" \n" +
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]"
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
" }\n" +
|
||||
"}\n"
|
||||
);
|
||||
editor.assertHighlights("@Component", "AutowiredClass");
|
||||
editor.assertHighlights("@Component", "AutowiredClass", "depA", "depB");
|
||||
editor.assertTrimmedHover("@Component",
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.ide.vscode.boot.metadata.LoggerNameProvider;
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
@@ -69,7 +70,7 @@ public class LoggerNameProviderTest {
|
||||
|
||||
@Test
|
||||
public void directResults() throws Exception {
|
||||
LoggerNameProvider p = new LoggerNameProvider(null);
|
||||
LoggerNameProvider p = create();
|
||||
String query = "jboss";
|
||||
List<String> directQueryResults = getResults(p, query);
|
||||
|
||||
@@ -84,7 +85,7 @@ public class LoggerNameProviderTest {
|
||||
|
||||
@Test
|
||||
public void cachedResults() throws Exception {
|
||||
LoggerNameProvider p = new LoggerNameProvider(null);
|
||||
LoggerNameProvider p = create();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
String query = "jboss";
|
||||
@@ -105,7 +106,7 @@ public class LoggerNameProviderTest {
|
||||
public void incrementalResults() throws Exception {
|
||||
String fullQuery = "jboss";
|
||||
|
||||
CachingValueProvider p = new LoggerNameProvider(null);
|
||||
CachingValueProvider p = create();
|
||||
for (int i = 0; i <= fullQuery.length(); i++) {
|
||||
String query = fullQuery.substring(0, i);
|
||||
List<String> results = getResults(p, query);
|
||||
@@ -120,6 +121,10 @@ public class LoggerNameProviderTest {
|
||||
}
|
||||
}
|
||||
|
||||
private LoggerNameProvider create() {
|
||||
return (LoggerNameProvider) LoggerNameProvider.factory(null).apply(ImmutableMap.of());
|
||||
}
|
||||
|
||||
private void assertElementsAtLeast(List<String> results, String[] expecteds) {
|
||||
Set<String> actuals = ImmutableSet.copyOf(results);
|
||||
StringBuilder missing = new StringBuilder();
|
||||
|
||||
@@ -1183,6 +1183,10 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
"logging.level.indexed=<*>"
|
||||
);
|
||||
|
||||
//Check whether the added parameter to disable group name hints is obeyed:
|
||||
assertNoCompletionWithLabel("logging.group.whatever=<*>", "foobar");
|
||||
assertNoCompletionWithLabel("logging.group.whatever=<*>", "user-defined");
|
||||
assertNoCompletionWithLabel("logging.group.whatever=<*>", "indexed");
|
||||
}
|
||||
|
||||
@Test public void userDefinedLoggingGroupsValueCompletions() throws Exception {
|
||||
|
||||
@@ -296,6 +296,16 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
" group:\n"+
|
||||
" whatever: stuff,com.example.demo<*>"
|
||||
);
|
||||
|
||||
//Check whether the added parameter to disable group name hints is obeyed:
|
||||
assertNoCompletionWithLabel(
|
||||
"logging:\n" +
|
||||
" group:\n"+
|
||||
" whatever: <*>"
|
||||
,
|
||||
"foobar"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
///////////////////// ported tests from old STS code base ////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user