Search in sources :

Example 11 with LiveBeansModel

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");
}
Also used : Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) LiveBeansModel(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel) Test(org.junit.Test)

Example 12 with LiveBeansModel

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`");
}
Also used : Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) LiveBeansModel(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel) Test(org.junit.Test)

Example 13 with LiveBeansModel

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`");
}
Also used : Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) LiveBeansModel(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel) Test(org.junit.Test)

Example 14 with LiveBeansModel

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");
}
Also used : Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) LiveBeansModel(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel) Test(org.junit.Test)

Example 15 with LiveBeansModel

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");
}
Also used : Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) LiveBeansModel(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel) Test(org.junit.Test)

Aggregations

LiveBeansModel (org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel)37 Test (org.junit.Test)33 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)29 LiveBean (org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBean)7 SpringBootApp (org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp)4 Hover (org.eclipse.lsp4j.Hover)3 Path (java.nio.file.Path)1 Optional (java.util.Optional)1 Stream (java.util.stream.Stream)1 BootJavaLanguageServerComponents (org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents)1 SourceLinkFactory (org.springframework.ide.vscode.boot.java.links.SourceLinkFactory)1 SourceLinks (org.springframework.ide.vscode.boot.java.links.SourceLinks)1 SpringResource (org.springframework.ide.vscode.boot.java.utils.SpringResource)1 IJavaProject (org.springframework.ide.vscode.commons.java.IJavaProject)1 SimpleLanguageServer (org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer)1 Renderables (org.springframework.ide.vscode.commons.util.Renderables)1 StringUtil (org.springframework.ide.vscode.commons.util.StringUtil)1