use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class BeansByTypeHoverProviderTest method generalBeanLiveHoverAvoidOverlapWithAnnotation.
@Test
public void generalBeanLiveHoverAvoidOverlapWithAnnotation() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("fooImplementation").type("com.example.FooImplementation").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.stereotype.Component;\n" + "\n" + "@Component\n" + "public class FooImplementation implements Foo {\n" + "\n" + " @Override\n" + " public void doSomeFoo() {\n" + " System.out.println(\"Foo do do do!\");\n" + " }\n" + "}\n");
editor.assertHighlights("@Component");
editor.assertTrimmedHover("@Component", "**Injection report for Bean [id: fooImplementation, type: `com.example.FooImplementation`]**\n" + "\n" + "Process [PID=111, name=`the-app`]:\n" + "\n" + "Bean [id: fooImplementation, type: `com.example.FooImplementation`] 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 ComponentInjectionsHoverProviderTest method componentWithMultipleInjections.
@Test
public void componentWithMultipleInjections() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("fooImplementation").type("com.example.FooImplementation").build()).add(LiveBean.builder().id("myController").type("com.example.MyController").dependencies("fooImplementation").build()).add(LiveBean.builder().id("otherBean").type("com.example.OtherBean").dependencies("fooImplementation").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.stereotype.Component;\n" + "\n" + "@Component\n" + "public class FooImplementation implements Foo {\n" + "\n" + " @Override\n" + " public void doSomeFoo() {\n" + " System.out.println(\"Foo do do do!\");\n" + " }\n" + "}\n");
editor.assertHighlights("@Component");
editor.assertTrimmedHover("@Component", "**Injection report for Bean [id: fooImplementation, type: `com.example.FooImplementation`]**\n" + "\n" + "Process [PID=111, name=`the-app`]:\n" + "\n" + "Bean [id: fooImplementation, type: `com.example.FooImplementation`] injected into:\n" + "\n" + "- Bean: myController \n" + " Type: `com.example.MyController`\n" + "- Bean: otherBean \n" + " Type: `com.example.OtherBean`");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class ComponentInjectionsHoverProviderTest 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.stereotype.Component;\n" + "\n" + "@Component\n" + "public class FooImplementation implements Foo {\n" + "\n" + " @Override\n" + " public void doSomeFoo() {\n" + " System.out.println(\"Foo do do do!\");\n" + " }\n" + "}\n");
editor.assertHighlights();
editor.assertNoHover("@Component");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class ComponentInjectionsHoverProviderTest method componentFromInnerClass.
@Test
public void componentFromInnerClass() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("demoApplication.InnerClass").type("com.example.DemoApplication$InnerClass").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" + " @SpringBootApplication\n" + " public static class InnerClass {\n" + " \n" + " public static void main(String[] args) {\n" + " SpringApplication.run(DemoApplication.InnerClass.class, args);\n" + " }\n" + " }\n" + "}\n");
editor.assertHighlights("@SpringBootApplication");
editor.assertHoverContains("@SpringBootApplication", "**Injection report for Bean [id: demoApplication.InnerClass, type: `com.example.DemoApplication.InnerClass`]**");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class ComponentInjectionsHoverProviderTest method componentWithAutomaticallyWiredConstructorInjections.
@Test
public void componentWithAutomaticallyWiredConstructorInjections() 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").fileResource(harness.getOutputFolder() + "/com/example/DependencyA.class").build()).add(LiveBean.builder().id("dependencyB").type("com.example.DependencyB").classpathResource("com/example/DependencyB.class").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.stereotype.Component;\n" + "\n" + "@Component\n" + "public class AutowiredClass {\n" + "\n" + " public AutowiredClass(DependencyA depA, DependencyB depB) {\n" + " }\n" + "}\n");
editor.assertHighlights("@Component");
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" + "\n\n" + "Bean [id: autowiredClass, type: `com.example.AutowiredClass`] got autowired with:\n" + "\n" + "- Bean: dependencyA \n" + " Type: `com.example.DependencyA` \n" + " Resource: `" + Paths.get("com/example/DependencyA.class") + "`\n" + "- Bean: dependencyB \n" + " Type: `com.example.DependencyB` \n" + " Resource: `com/example/DependencyB.class`");
}
Aggregations