use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class BeansByTypeHoverProviderTest method typeButNotABean.
@Test
public void typeButNotABean() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("scannedRandomClass").type("com.example.ScannedRandomClass").build()).add(LiveBean.builder().id("randomOtherBean").type("randomOtherBeanType").dependencies("scannedRandomClass").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 com.example;\n" + "\n" + "import java.io.Serializable;\n" + "\n" + "public class ClassNoBean implements Serializable {\n" + "\n" + " public String apply(String t) {\n" + " return t.toUpperCase();\n" + " }\n" + "\n" + "}\n" + "");
editor.assertHighlights();
editor.assertNoHover("ClassNoBean");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class BeansByTypeHoverProviderTest method scannedAndInjectedFunction.
@Test
public void scannedAndInjectedFunction() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("scannedFunctionClass").type("com.example.ScannedFunctionClass").build()).add(LiveBean.builder().id("org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration").type("org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration").dependencies("scannedFunctionClass").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 com.example;\n" + "\n" + "import java.util.function.Function;\n" + "\n" + "public class ScannedFunctionClass implements Function<String, String> {\n" + "\n" + " @Override\n" + " public String apply(String t) {\n" + " return t.toUpperCase();\n" + " }\n" + "\n" + "}\n" + "");
editor.assertHighlights("ScannedFunctionClass");
editor.assertTrimmedHover("ScannedFunctionClass", "**Injection report for Bean [id: scannedFunctionClass, type: `com.example.ScannedFunctionClass`]**\n" + "\n" + "Process [PID=111, name=`the-app`]:\n" + "\n" + "Bean [id: scannedFunctionClass, type: `com.example.ScannedFunctionClass`] injected into:\n" + "\n" + "- Bean: org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration \n" + " Type: `org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration`");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class ComponentInjectionsHoverProviderTest method onlyShowInfoForRelevantBeanId.
@Test
public void onlyShowInfoForRelevantBeanId() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("fooImplementation").type("com.example.FooImplementation").build()).add(LiveBean.builder().id("alternateFooImplementation").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("alternateFooImplementation").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.assertHoverExactText("@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`");
}
use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.
the class ComponentInjectionsHoverProviderTest method componentWithNoInjections.
@Test
public void componentWithNoInjections() 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 explicitComponentId.
@Test
public void explicitComponentId() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder().add(LiveBean.builder().id("fooImplementation").type("com.example.FooImplementation").build()).add(LiveBean.builder().id("alternateFooImplementation").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("alternateFooImplementation").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(\"alternateFooImplementation\")\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: alternateFooImplementation, type: `com.example.FooImplementation`]**\n" + "\n" + "Process [PID=111, name=`the-app`]:\n" + "\n" + "Bean [id: alternateFooImplementation, type: `com.example.FooImplementation`] injected into:\n" + "\n" + "- Bean: otherBean \n" + " Type: `com.example.OtherBean`\n");
}
Aggregations