use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class BeanInjectedIntoHoverProviderTest method noHoversWhenRunningAppDoesntHaveTheBean.
@Test
public void noHoversWhenRunningAppDoesntHaveTheBean() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("whateverBean").type("com.example.UnrelatedBeanType").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("unrelated-app").beans(beans).build();
Editor editor = harness.newEditor(LanguageId.JAVA, "package hello;\n" + "\n" + "import org.springframework.context.annotation.Bean;\n" + "import org.springframework.context.annotation.Configuration;\n" + "import org.springframework.context.annotation.Profile;\n" + "\n" + "@Configuration\n" + "public class LocalConfig {\n" + " \n" + " @Bean(\"fooImplementation\")\n" + " Foo someFoo() {\n" + " return new FooImplementation();\n" + " }\n" + "}");
editor.assertHighlights();
editor.assertNoHover("@Bean");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class BeanInjectedIntoHoverProviderTest method beanWithFileResource.
@Test
public void beanWithFileResource() throws Exception {
Path of = harness.getOutputFolder();
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("fooImplementation").type("hello.FooImplementation").fileResource("should/not/matter").build()).add(LiveBean.builder().id("myController").type("hello.MyController").fileResource(of + "/hello/MyController.class").dependencies("fooImplementation").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("the-app").beans(beans).build();
Editor editor = harness.newEditor(LanguageId.JAVA, "package hello;\n" + "\n" + "import org.springframework.context.annotation.Bean;\n" + "import org.springframework.context.annotation.Configuration;\n" + "import org.springframework.context.annotation.Profile;\n" + "\n" + "@Configuration\n" + "public class LocalConfig {\n" + " \n" + " @Bean(\"fooImplementation\")\n" + " Foo someFoo() {\n" + " return new FooImplementation();\n" + " }\n" + "}");
editor.assertHighlights("@Bean");
editor.assertTrimmedHover("@Bean", "**Injection report for Bean [id: fooImplementation]**\n" + "\n" + "Process [PID=111, name=`the-app`]:\n" + "\n" + "Bean [id: fooImplementation, type: `hello.FooImplementation`] injected into:\n" + "\n" + "- Bean: myController \n" + " Type: `hello.MyController` \n" + " Resource: `" + Paths.get("hello/MyController.class") + "`");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class BeanInjectedIntoHoverProviderTest method beanFromInnerClassWithOneInjection.
@Test
public void beanFromInnerClassWithOneInjection() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("fooImplementation").type("hello.FooImplementation").build()).add(LiveBean.builder().id("myController").type("hello.MyController").dependencies("fooImplementation").build()).add(LiveBean.builder().id("irrelevantBean").type("com.example.IrrelevantBean").dependencies("myController").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("the-app").beans(beans).build();
Editor editor = harness.newEditor(LanguageId.JAVA, "package hello;\n" + "\n" + "import org.springframework.context.annotation.Bean;\n" + "import org.springframework.context.annotation.Configuration;\n" + "import org.springframework.context.annotation.Profile;\n" + "\n" + "public class OuterClass {\n" + " \n" + " @Configuration\n" + " public static class InnerClass {\n" + " \n" + " @Bean(\"fooImplementation\")\n" + " Foo someFoo() {\n" + " return new FooImplementation();\n" + " }\n" + " }\n" + "}");
editor.assertHighlights("@Bean");
editor.assertTrimmedHover("@Bean", "**Injection report for Bean [id: fooImplementation]**\n" + "\n" + "Process [PID=111, name=`the-app`]:\n" + "\n" + "Bean [id: fooImplementation, type: `hello.FooImplementation`] injected into:\n" + "\n" + "- Bean: myController \n" + " Type: `hello.MyController`\n");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class BeanInjectedIntoHoverProviderTest method beanWithNoInjections.
@Test
public void beanWithNoInjections() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("myFoo").type("hello.FooImplementation").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("the-app").beans(beans).build();
Editor editor = harness.newEditor(LanguageId.JAVA, "package hello;\n" + "\n" + "import org.springframework.context.annotation.Bean;\n" + "import org.springframework.context.annotation.Configuration;\n" + "import org.springframework.context.annotation.Profile;\n" + "\n" + "@Configuration\n" + "public class LocalConfig {\n" + " \n" + " @Bean\n" + " Foo myFoo() {\n" + " return new FooImplementation();\n" + " }\n" + "}");
editor.assertHighlights("@Bean");
editor.assertTrimmedHover("@Bean", "**Injection report for Bean [id: myFoo]**\n" + "\n" + "Process [PID=111, name=`the-app`]:\n" + "\n" + "Bean [id: myFoo, type: `hello.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 BeanInjectedIntoHoverProviderTest method beanWithOneInjection.
@Test
public void beanWithOneInjection() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("fooImplementation").type("hello.FooImplementation").build()).add(LiveBean.builder().id("myController").type("hello.MyController").dependencies("fooImplementation").build()).add(LiveBean.builder().id("irrelevantBean").type("com.example.IrrelevantBean").dependencies("myController").build()).build();
mockAppProvider.builder().isSpringBootApp(true).processId("111").processName("the-app").beans(beans).build();
Editor editor = harness.newEditor(LanguageId.JAVA, "package hello;\n" + "\n" + "import org.springframework.context.annotation.Bean;\n" + "import org.springframework.context.annotation.Configuration;\n" + "import org.springframework.context.annotation.Profile;\n" + "\n" + "@Configuration\n" + "public class LocalConfig {\n" + " \n" + " @Bean(\"fooImplementation\")\n" + " Foo someFoo() {\n" + " return new FooImplementation();\n" + " }\n" + "}");
editor.assertHighlights("@Bean");
editor.assertTrimmedHover("@Bean", "**Injection report for Bean [id: fooImplementation]**\n" + "\n" + "Process [PID=111, name=`the-app`]:\n" + "\n" + "Bean [id: fooImplementation, type: `hello.FooImplementation`] injected into:\n" + "\n" + "- Bean: myController \n" + " Type: `hello.MyController`\n");
}
Aggregations