use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class ComponentInjectionsHoverProviderTest method componentFromInnerInnerClass.
@Test
public void componentFromInnerInnerClass() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("demoApplication.InnerClass.InnerInnerClass").type("com.example.DemoApplication$InnerClass$InnerInnerClass").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("the-app").beans(beans).build();
Editor editor = harness.newEditor(LanguageId.JAVA, "package com.example;\n" + "\n" + "import org.springframework.boot.SpringApplication;\n" + "import org.springframework.boot.autoconfigure.SpringBootApplication;\n" + "import org.springframework.context.annotation.Bean;\n" + "import org.springframework.web.client.RestTemplate;\n" + "\n" + "public class DemoApplication {\n" + " \n" + " public static class InnerClass {\n" + " \n" + " @SpringBootApplication\n" + " public static class InnerInnerClass {\n" + " \n" + " public static void main(String[] args) {\n" + " SpringApplication.run(DemoApplication.InnerClass.InnerInnerClass.class, args);\n" + " }\n" + " }\n" + " }\n" + "}\n");
editor.assertHighlights("@SpringBootApplication");
editor.assertHoverContains("@SpringBootApplication", "**Injection report for Bean [id: demoApplication.InnerClass.InnerInnerClass, type: `com.example.DemoApplication.InnerClass.InnerInnerClass`]**");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class ComponentInjectionsHoverProviderTest method bug_153072942_SpringBootApplication__withCGLib_is_a_Component.
@Test
public void bug_153072942_SpringBootApplication__withCGLib_is_a_Component() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("demoApplication").type("com.example.DemoApplication$$EnhancerBySpringCGLIB$$f378241f").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("the-app").beans(beans).build();
Editor editor = harness.newEditor(LanguageId.JAVA, "package com.example;\n" + "\n" + "import org.springframework.boot.SpringApplication;\n" + "import org.springframework.boot.autoconfigure.SpringBootApplication;\n" + "import org.springframework.context.annotation.Bean;\n" + "import org.springframework.web.client.RestTemplate;\n" + "\n" + "@SpringBootApplication\n" + "public class DemoApplication {\n" + " \n" + "\n" + " public static void main(String[] args) {\n" + " SpringApplication.run(DemoApplication.class, args);\n" + " }\n" + "}\n");
editor.assertHighlights("@SpringBootApplication");
editor.assertHoverContains("@SpringBootApplication", "**Injection report for Bean [id: demoApplication, type: `com.example.DemoApplication`]**");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class ComponentInjectionsHoverProviderTest method componentWithAutowiredConstructorNoAdditionalHovers.
@Test
public void componentWithAutowiredConstructorNoAdditionalHovers() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("autowiredClass").type("com.example.AutowiredClass").dependencies("dependencyA", "dependencyB").build()).add(LiveBean.builder().id("dependencyA").type("com.example.DependencyA").build()).add(LiveBean.builder().id("dependencyB").type("com.example.DependencyB").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("the-app").beans(beans).build();
Editor editor = harness.newEditor(LanguageId.JAVA, "package com.example;\n" + "\n" + "import org.springframework.beans.factory.annotation.Autowired;\n" + "import org.springframework.stereotype.Component;\n" + "\n" + "@Component\n" + "public class AutowiredClass {\n" + "\n" + " @Autowired\n" + " public AutowiredClass(DependencyA depA, DependencyB depB) {\n" + " }\n" + "}\n");
editor.assertHighlights("@Component", "@Autowired");
editor.assertTrimmedHover("@Component", "**Injection report for Bean [id: autowiredClass, type: `com.example.AutowiredClass`]**\n" + "\n" + "Process [PID=111, name=`the-app`]:\n" + "\n" + "Bean [id: autowiredClass, type: `com.example.AutowiredClass`] exists but is **Not injected anywhere**\n");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class AutowiredHoverProviderTest method noHoversWhenRunningAppDoesntHaveTheComponent.
@Test
public void noHoversWhenRunningAppDoesntHaveTheComponent() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("whateverBean").type("com.example.UnrelatedComponent").build()).add(LiveBean.builder().id("myController").type("com.example.UnrelatedComponent").dependencies("whateverBean").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("unrelated-app").beans(beans).build();
Editor editor = harness.newEditor(LanguageId.JAVA, "package com.example;\n" + "\n" + "import org.springframework.beans.factory.annotation.Autowired;\n" + "import org.springframework.stereotype.Component;\n" + "\n" + "@Component\n" + "public class AutowiredClass {\n" + "\n" + " @Autowired\n" + " public AutowiredClass(DependencyA depA, DependencyB depB) {\n" + " }\n" + "}\n");
editor.assertHighlights();
editor.assertNoHover("@Autowired");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class AutowiredHoverProviderTest method bug_152553935.
@Test
public void bug_152553935() throws Exception {
// https://www.pivotaltracker.com/story/show/152553935
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("defaultFoo").type("com.example.FooImplementation").dependencies("defaultFoo").dependencies("otherBean").build()).add(LiveBean.builder().id("otherBean").type("com.example.DependencyA").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("the-app").beans(beans).build();
Editor editor = harness.newEditor("package com.example;\n" + "\n" + "import org.springframework.beans.factory.annotation.Autowired;\n" + "import org.springframework.scheduling.TaskScheduler;\n" + "import org.springframework.stereotype.Component;\n" + "\n" + "@Component(\"defaultFoo\")\n" + "public class FooImplementation implements Foo {\n" + " \n" + " private TaskScheduler scheduler;\n" + " \n" + " @Autowired Foo self;\n" + " \n" + " @Override\n" + " public void doSomeFoo() {\n" + " scheduler.scheduleWithFixedDelay(() -> {\n" + " System.out.println(\"Doo Done done!\");\n" + " }, 1000);\n" + " System.out.println(\"Foo do do do do!\");\n" + " }\n" + "\n" + " @Autowired\n" + " public void setScheduler(TaskScheduler scheduler) {\n" + " this.scheduler = scheduler;\n" + " }\n" + "\n" + "}");
editor.assertHighlights("@Component", "@Autowired", "@Autowired");
for (int i = 1; i <= 2; i++) {
editor.assertHoverContains("@Autowired", i, "Bean [id: defaultFoo, type: `com.example.FooImplementation`] got autowired with:\n" + "\n" + "- Bean: otherBean \n" + " Type: `com.example.DependencyA`");
}
}
Aggregations