Skip to content

Commit 9301d18

Browse files
committed
Add JumpToDeclarationActionTest to run on SQL annotations
1 parent d046423 commit 9301d18

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/test/kotlin/org/domaframework/doma/intellij/gutteraction/sql/SqlJumpActionTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
2424
import com.intellij.openapi.actionSystem.CommonDataKeys
2525
import com.intellij.openapi.actionSystem.DataContext
2626
import com.intellij.openapi.fileEditor.FileEditorManager
27+
import com.intellij.openapi.vfs.VirtualFile
2728
import org.domaframework.doma.intellij.DomaSqlTest
2829
import java.awt.event.InputEvent
2930
import java.awt.event.MouseEvent
@@ -37,6 +38,7 @@ class SqlJumpActionTest : DomaSqlTest() {
3738
override fun setUp() {
3839
super.setUp()
3940
addDaoJavaFile("$packageName/JumpActionTestDao.java")
41+
addDaoJavaFile("$packageName/JumpDeclarationActionSqlAnnotationTestDao.java")
4042
addSqlFile(
4143
"$packageName/JumpActionTestDao/jumpToDaoFile.sql",
4244
"$packageName/JumpActionTestDao/notDisplayGutterWithNonExistentDaoMethod.sql",
@@ -128,6 +130,16 @@ class SqlJumpActionTest : DomaSqlTest() {
128130
jumpToDaoTest(action, "ProjectDetail.java")
129131
}
130132

133+
fun testJumpToDeclarationSqlAnnotation() {
134+
val dao = findDaoClass("$packageName.JumpDeclarationActionSqlAnnotationTestDao")
135+
val action: AnAction? = getJumpVariableActionTestOnSqlAnnotation(dao.containingFile.virtualFile)
136+
assertNotNull("Not Found Action", action)
137+
if (action == null) return
138+
139+
isDisplayedActionTest(action)
140+
jumpToDaoTest(action, "Employee.java")
141+
}
142+
131143
private fun getJumDaoActionTest(sqlName: String): AnAction? {
132144
val sql = findSqlFile(sqlName)
133145
assertNotNull("Not Found SQL File", sql)
@@ -154,6 +166,14 @@ class SqlJumpActionTest : DomaSqlTest() {
154166
return action
155167
}
156168

169+
private fun getJumpVariableActionTestOnSqlAnnotation(daoFile: VirtualFile): AnAction {
170+
myFixture.configureFromExistingVirtualFile(daoFile)
171+
val actionId = "org.domaframework.doma.intellij.JumpToDeclarationFromSql"
172+
val action: AnAction = ActionManager.getInstance().getAction(actionId)
173+
assertNotNull("Not Found Action", action)
174+
return action
175+
}
176+
157177
private fun getJumpVariableActionTest(sqlName: String): AnAction? {
158178
val sql = findSqlFile(sqlName)
159179
assertNotNull("Not Found SQL File", sql)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package doma.example.dao.gutteraction;
2+
3+
import java.util.List;
4+
import doma.example.entity.*;
5+
import org.seasar.doma.*;
6+
7+
@Dao
8+
interface JumpDeclarationActionSqlAnnotationTestDao {
9+
10+
@Select
11+
@Sql("""
12+
select * from emp
13+
where name = /* employee.employee<caret>Name */'name'
14+
""")
15+
List<Employee> jumpToEntity(Employee employee);
16+
17+
}

0 commit comments

Comments
 (0)