From 2bc3236b6aa45379204ebc439956d2375293fbb6 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Sat, 5 Oct 2024 10:57:18 +0800 Subject: [PATCH] refactor(test): update for method code --- .../cc/unitmesh/idea/context/JavaClassContextTest.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/java/src/test/kotlin/cc/unitmesh/idea/context/JavaClassContextTest.kt b/java/src/test/kotlin/cc/unitmesh/idea/context/JavaClassContextTest.kt index dcfe95f727..0421149456 100644 --- a/java/src/test/kotlin/cc/unitmesh/idea/context/JavaClassContextTest.kt +++ b/java/src/test/kotlin/cc/unitmesh/idea/context/JavaClassContextTest.kt @@ -7,10 +7,12 @@ import com.intellij.lang.java.JavaLanguage import com.intellij.psi.PsiFileFactory import com.intellij.psi.PsiJavaFile import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase +import org.intellij.lang.annotations.Language class JavaClassContextTest : LightJavaCodeInsightFixtureTestCase() { private val fileFactory: PsiFileFactory get() = PsiFileFactory.getInstance(project) + @Language("Java") private val originCode = """ BlogService blogService; @@ -49,6 +51,7 @@ public class BlogController { } """.trimIndent() + @Language("Java") private val serviceCode: String = """ package cc.unitmesh.untitled.demo.service; @@ -106,11 +109,10 @@ class BlogController { } fun testShould_convert_function_to_string() { - myFixture.addClass(serviceCode) + val serviceClass = myFixture.addClass(serviceCode) myFixture.addClass(controllerCode) - val serviceFile = myFixture.findClass("cc.unitmesh.untitled.demo.service.BlogService") - val psiElement = serviceFile.methods[0] + val psiElement = serviceClass.methods[0] val context = MethodContextProvider(false, true).from(psiElement) assertEquals(