PT #151052858: added simple hover content for autowired annotation live hovers
This commit is contained in:
@@ -98,7 +98,7 @@ public class AutowiredHoverProviderTest {
|
||||
AutowiredHoverProvider provider = new AutowiredHoverProvider();
|
||||
String beansJSON = new String(Files.readAllBytes(new File(directory, "runtime-bean-information.json").toPath()));
|
||||
|
||||
Range hint = provider.getLiveHoverHint((Annotation)node, document, new String[] {beansJSON});
|
||||
Range hint = provider.getLiveHoverHint((Annotation)node, document, beansJSON);
|
||||
assertNotNull(hint);
|
||||
|
||||
assertEquals(11, hint.getStart().getLine());
|
||||
@@ -122,10 +122,10 @@ public class AutowiredHoverProviderTest {
|
||||
ASTNode node = NodeFinder.perform(cu, offset, 0).getParent();
|
||||
|
||||
AutowiredHoverProvider provider = new AutowiredHoverProvider();
|
||||
Range hint = provider.getLiveHoverHint((Annotation)node, document, new String[] {});
|
||||
Range hint = provider.getLiveHoverHint((Annotation)node, document, (String)null);
|
||||
assertNull(hint);
|
||||
}
|
||||
/**
|
||||
|
||||
@Test
|
||||
public void testNoLiveHoverHintForAutowiredOnConstructorWithWrongLiveAppData() throws Exception {
|
||||
File directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-autowired/").toURI());
|
||||
@@ -141,12 +141,12 @@ public class AutowiredHoverProviderTest {
|
||||
ASTNode node = NodeFinder.perform(cu, offset, 0).getParent();
|
||||
|
||||
AutowiredHoverProvider provider = new AutowiredHoverProvider();
|
||||
String beansJSON = new String(Files.readAllBytes(new File(directory, "runtime-bean-information.json").toPath()));
|
||||
String beansJSON = new String(Files.readAllBytes(new File(directory, "wrong-runtime-bean-information.json").toPath()));
|
||||
|
||||
Range hint = provider.getLiveHoverHint((Annotation)node, document, new String[] {beansJSON});
|
||||
Range hint = provider.getLiveHoverHint((Annotation)node, document, beansJSON);
|
||||
assertNull(hint);
|
||||
}
|
||||
*/
|
||||
|
||||
private TextDocument createTempTextDocument(String docURI) throws Exception {
|
||||
Path path = Paths.get(new URI(docURI));
|
||||
String content = new String(Files.readAllBytes(path));
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.autowired.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.java.autowired.LiveBean;
|
||||
import org.springframework.ide.vscode.boot.java.autowired.LiveBeansModel;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class LiveBeansModelTest {
|
||||
|
||||
@Test
|
||||
public void testSimpleModel() throws Exception {
|
||||
String json = IOUtils.toString(ProjectsHarness.class.getResourceAsStream("/live-beans-models/simple-live-beans-model.json"));
|
||||
LiveBeansModel model = LiveBeansModel.parse(json);
|
||||
|
||||
LiveBean[] bean = model.getBeansOfType("org.test.DependencyA");
|
||||
assertEquals(1, bean.length);
|
||||
assertEquals("dependencyA", bean[0].getId());
|
||||
assertEquals("singleton", bean[0].getScope());
|
||||
assertEquals("org.test.DependencyA", bean[0].getType());
|
||||
assertEquals("file [/test-projects/classes/org/test/DependencyA.class]", bean[0].getResource());
|
||||
assertEquals(0, bean[0].getAliases().length);
|
||||
assertEquals(0, bean[0].getDependencies().length);
|
||||
|
||||
bean = model.getBeansOfName("dependencyB");
|
||||
assertEquals(1, bean.length);
|
||||
assertEquals("dependencyB", bean[0].getId());
|
||||
assertEquals("singleton", bean[0].getScope());
|
||||
assertEquals("org.test.DependencyB", bean[0].getType());
|
||||
assertEquals("file [/test-projects/classes/org/test/DependencyB.class]", bean[0].getResource());
|
||||
assertEquals(0, bean[0].getAliases().length);
|
||||
assertEquals(0, bean[0].getDependencies().length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyModel() throws Exception {
|
||||
String json = IOUtils.toString(ProjectsHarness.class.getResourceAsStream("/live-beans-models/empty-live-beans-model.json"));
|
||||
LiveBeansModel model = LiveBeansModel.parse(json);
|
||||
|
||||
LiveBean[] bean = model.getBeansOfType("org.test.DependencyA");
|
||||
assertEquals(0, bean.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTotallyEmptyModel() throws Exception {
|
||||
String json = IOUtils.toString(ProjectsHarness.class.getResourceAsStream("/live-beans-models/totally-empty-live-beans-model.json"));
|
||||
LiveBeansModel model = LiveBeansModel.parse(json);
|
||||
|
||||
LiveBean[] bean = model.getBeansOfType("org.test.DependencyA");
|
||||
assertEquals(0, bean.length);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
[
|
||||
{
|
||||
"context": "application",
|
||||
"parent": null,
|
||||
"beans": [
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,35 @@
|
||||
[
|
||||
{
|
||||
"context": "application",
|
||||
"parent": null,
|
||||
"beans": [
|
||||
{
|
||||
"bean": "dependencyA",
|
||||
"aliases": [],
|
||||
"scope": "singleton",
|
||||
"type": "org.test.DependencyA",
|
||||
"resource": "file [/test-projects/classes/org/test/DependencyA.class]",
|
||||
"dependencies": []
|
||||
},
|
||||
{
|
||||
"bean": "dependencyB",
|
||||
"aliases": [],
|
||||
"scope": "singleton",
|
||||
"type": "org.test.DependencyB",
|
||||
"resource": "file [/test-projects/classes/org/test/DependencyB.class]",
|
||||
"dependencies": []
|
||||
},
|
||||
{
|
||||
"bean": "myAutowiredComponent",
|
||||
"aliases": [],
|
||||
"scope": "singleton",
|
||||
"type": "org.test.MyAutowiredComponent",
|
||||
"resource": "file [/test-projects/classes/org/test/MyAutowiredComponent.class]",
|
||||
"dependencies": [
|
||||
"dependencyA",
|
||||
"dependencyB"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user