Skip to content

Commit 2bc3236

Browse files
committed
refactor(test): update for method code
1 parent 95002f6 commit 2bc3236

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

java/src/test/kotlin/cc/unitmesh/idea/context/JavaClassContextTest.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import com.intellij.lang.java.JavaLanguage
77
import com.intellij.psi.PsiFileFactory
88
import com.intellij.psi.PsiJavaFile
99
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
10+
import org.intellij.lang.annotations.Language
1011

1112
class JavaClassContextTest : LightJavaCodeInsightFixtureTestCase() {
1213
private val fileFactory: PsiFileFactory get() = PsiFileFactory.getInstance(project)
1314

15+
@Language("Java")
1416
private val originCode = """
1517
BlogService blogService;
1618
@@ -49,6 +51,7 @@ public class BlogController {
4951
}
5052
""".trimIndent()
5153

54+
@Language("Java")
5255
private val serviceCode: String = """
5356
package cc.unitmesh.untitled.demo.service;
5457
@@ -106,11 +109,10 @@ class BlogController {
106109
}
107110

108111
fun testShould_convert_function_to_string() {
109-
myFixture.addClass(serviceCode)
112+
val serviceClass = myFixture.addClass(serviceCode)
110113
myFixture.addClass(controllerCode)
111114

112-
val serviceFile = myFixture.findClass("cc.unitmesh.untitled.demo.service.BlogService")
113-
val psiElement = serviceFile.methods[0]
115+
val psiElement = serviceClass.methods[0]
114116
val context = MethodContextProvider(false, true).from(psiElement)
115117

116118
assertEquals(

0 commit comments

Comments
 (0)