GH-1041: removed outdated beans addon symbol information, now fully replaced with new spring index
This commit is contained in:
@@ -13,7 +13,7 @@ package org.springframework.ide.vscode.boot.java.beans.test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -26,9 +26,9 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@@ -43,9 +43,10 @@ public class SpringIndexerBeansTest {
|
||||
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private JavaProjectFinder projectFinder;
|
||||
@Autowired private SpringSymbolIndex indexer;
|
||||
@Autowired private SpringMetamodelIndex springIndex;
|
||||
|
||||
private File directory;
|
||||
@Autowired private SpringSymbolIndex indexer;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
@@ -69,19 +70,15 @@ public class SpringIndexerBeansTest {
|
||||
SpringIndexerHarness.symbol("@Configuration", "@+ 'simpleConfiguration' (@Configuration <: @Component) SimpleConfiguration"),
|
||||
SpringIndexerHarness.symbol("@Bean", "@+ 'simpleBean' (@Bean) BeanClass")
|
||||
);
|
||||
|
||||
List<? extends SymbolAddOnInformation> addon = indexer.getAdditonalInformation(docUri);
|
||||
assertEquals(2, addon.size());
|
||||
|
||||
assertEquals(1, addon.stream()
|
||||
.filter(info -> info instanceof BeansSymbolAddOnInformation)
|
||||
.filter(info -> "simpleConfiguration".equals(((BeansSymbolAddOnInformation) info).getBeanID()))
|
||||
.count());
|
||||
|
||||
assertEquals(1, addon.stream()
|
||||
.filter(info -> info instanceof BeansSymbolAddOnInformation)
|
||||
.filter(info -> "simpleBean".equals(((BeansSymbolAddOnInformation) info).getBeanID()))
|
||||
.count());
|
||||
|
||||
Bean[] beans = springIndex.getBeansOfDocument(docUri);
|
||||
assertEquals(2, beans.length);
|
||||
|
||||
Bean simpleConfigBean = Arrays.stream(beans).filter(bean -> bean.getName().equals("simpleConfiguration")).findFirst().get();
|
||||
Bean simpleBean = Arrays.stream(beans).filter(bean -> bean.getName().equals("simpleBean")).findFirst().get();
|
||||
|
||||
assertEquals("org.test.SimpleConfiguration", simpleConfigBean.getType());
|
||||
assertEquals("org.test.BeanClass", simpleBean.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.beans.test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -26,9 +26,9 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@@ -44,6 +44,7 @@ public class SpringIndexerFunctionBeansTest {
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private SpringSymbolIndex indexer;
|
||||
@Autowired private JavaProjectFinder projectFinder;
|
||||
@Autowired private SpringMetamodelIndex springIndex;
|
||||
|
||||
private File directory;
|
||||
|
||||
@@ -70,18 +71,14 @@ public class SpringIndexerFunctionBeansTest {
|
||||
SpringIndexerHarness.symbol("@Bean", "@> 'uppercase' (@Bean) Function<String,String>")
|
||||
);
|
||||
|
||||
List<? extends SymbolAddOnInformation> addon = indexer.getAdditonalInformation(docUri);
|
||||
assertEquals(2, addon.size());
|
||||
|
||||
assertEquals(1, addon.stream()
|
||||
.filter(info -> info instanceof BeansSymbolAddOnInformation)
|
||||
.filter(info -> "functionClass".equals(((BeansSymbolAddOnInformation) info).getBeanID()))
|
||||
.count());
|
||||
|
||||
assertEquals(1, addon.stream()
|
||||
.filter(info -> info instanceof BeansSymbolAddOnInformation)
|
||||
.filter(info -> "uppercase".equals(((BeansSymbolAddOnInformation) info).getBeanID()))
|
||||
.count());
|
||||
Bean[] beans = springIndex.getBeansOfDocument(docUri);
|
||||
assertEquals(2, beans.length);
|
||||
|
||||
Bean configBean = Arrays.stream(beans).filter(bean -> bean.getName().equals("functionClass")).findFirst().get();
|
||||
Bean functionBean = Arrays.stream(beans).filter(bean -> bean.getName().equals("uppercase")).findFirst().get();
|
||||
|
||||
assertEquals("org.test.FunctionClass", configBean.getType());
|
||||
assertEquals("java.util.function.Function<java.lang.String,java.lang.String>", functionBean.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2024 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -19,6 +19,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -29,9 +30,9 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@@ -47,6 +48,7 @@ public class DataRepositorySymbolProviderTest {
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private JavaProjectFinder projectFinder;
|
||||
@Autowired private SpringSymbolIndex indexer;
|
||||
@Autowired private SpringMetamodelIndex springIndex;
|
||||
|
||||
private File directory;
|
||||
|
||||
@@ -71,10 +73,14 @@ public class DataRepositorySymbolProviderTest {
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@+ 'customerRepository' (Customer) Repository<Customer,Long>", docUri, 6, 17, 6, 35));
|
||||
|
||||
List<? extends SymbolAddOnInformation> addon = indexer.getAdditonalInformation(docUri);
|
||||
assertEquals(1, addon.size());
|
||||
|
||||
assertEquals("customerRepository", ((BeansSymbolAddOnInformation) addon.get(0)).getBeanID());
|
||||
Bean[] repoBean = this.springIndex.getBeansWithName("test-spring-data-symbols", "customerRepository");
|
||||
assertEquals(1, repoBean.length);
|
||||
assertEquals("customerRepository", repoBean[0].getName());
|
||||
assertEquals("org.test.CustomerRepository", repoBean[0].getType());
|
||||
|
||||
Bean[] matchingBeans = springIndex.getMatchingBeans("test-spring-data-symbols", "org.springframework.data.repository.CrudRepository");
|
||||
assertEquals(2, matchingBeans.length);
|
||||
ArrayUtils.contains(matchingBeans, repoBean[0]);
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2024 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -31,10 +31,11 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.requestmapping.WebfluxHandlerInformation;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@@ -47,14 +48,10 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@Import(SymbolProviderTestConf.class)
|
||||
public class WebFluxMappingSymbolProviderTest {
|
||||
|
||||
@Autowired
|
||||
private BootLanguageServerHarness harness;
|
||||
|
||||
@Autowired
|
||||
private SpringSymbolIndex indexer;
|
||||
|
||||
@Autowired
|
||||
JavaProjectFinder projectFinder;
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private SpringSymbolIndex indexer;
|
||||
@Autowired private JavaProjectFinder projectFinder;
|
||||
@Autowired private SpringMetamodelIndex springIndex;
|
||||
|
||||
private File directory;
|
||||
|
||||
@@ -79,9 +76,10 @@ public class WebFluxMappingSymbolProviderTest {
|
||||
assertTrue(containsSymbol(symbols, "@/users -- GET - Content-Type: application/json", docUri, 13, 1, 13, 74));
|
||||
assertTrue(containsSymbol(symbols, "@/users/{username} -- GET - Content-Type: application/json", docUri, 18, 1, 18, 85));
|
||||
|
||||
List<? extends SymbolAddOnInformation> addon = indexer.getAdditonalInformation(docUri);
|
||||
assertEquals(1, addon.size());
|
||||
assertEquals("userController", ((BeansSymbolAddOnInformation) addon.get(0)).getBeanID());
|
||||
Bean[] beans = springIndex.getBeansOfDocument(docUri);
|
||||
assertEquals(1, beans.length);
|
||||
assertEquals("userController", beans[0].getName());
|
||||
assertEquals("org.test.UserController", beans[0].getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -30,8 +30,6 @@ import org.springframework.ide.vscode.boot.app.BootLanguageServerBootApp;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.bootiful.XmlBeansTestConf;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolIndexConfig;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
@@ -92,37 +90,9 @@ public class SpringIndexerXMLProjectTest {
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'namedParameterJdbcTemplate' NamedParameterJdbcTemplate", docUri, 12, 14, 12, 45));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'persistenceExceptionTranslationPostProcessor' PersistenceExceptionTranslationPostProcessor", docUri, 18, 10, 18, 97));
|
||||
|
||||
List<? extends SymbolAddOnInformation> addon = symbolIndex.getAdditonalInformation(docUri);
|
||||
assertEquals(4, addon.size());
|
||||
|
||||
assertEquals(1, addon.stream()
|
||||
.filter(info -> info instanceof BeansSymbolAddOnInformation)
|
||||
.filter(info -> "transactionManager".equals(((BeansSymbolAddOnInformation) info).getBeanID()))
|
||||
.count());
|
||||
|
||||
assertEquals(1, addon.stream()
|
||||
.filter(info -> info instanceof BeansSymbolAddOnInformation)
|
||||
.filter(info -> "jdbcTemplate".equals(((BeansSymbolAddOnInformation) info).getBeanID()))
|
||||
.count());
|
||||
|
||||
assertEquals(1, addon.stream()
|
||||
.filter(info -> info instanceof BeansSymbolAddOnInformation)
|
||||
.filter(info -> "namedParameterJdbcTemplate".equals(((BeansSymbolAddOnInformation) info).getBeanID()))
|
||||
.count());
|
||||
|
||||
assertEquals(1, addon.stream()
|
||||
.filter(info -> info instanceof BeansSymbolAddOnInformation)
|
||||
.filter(info -> "persistenceExceptionTranslationPostProcessor".equals(((BeansSymbolAddOnInformation) info).getBeanID()))
|
||||
.count());
|
||||
|
||||
|
||||
String beansOnClasspathDocUri = directory.toPath().resolve("src/main/resources/beans.xml").toUri().toString();
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'sb' SimpleBean", beansOnClasspathDocUri, 6, 14, 6, 21));
|
||||
|
||||
addon = symbolIndex.getAdditonalInformation(beansOnClasspathDocUri);
|
||||
assertEquals(1, addon.size());
|
||||
assertEquals("sb", ((BeansSymbolAddOnInformation) addon.get(0)).getBeanID());
|
||||
|
||||
Bean[] beans = springIndex.getBeansOfProject("test-annotation-indexing-xml-project");
|
||||
assertEquals(5, beans.length);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user