Skip to content

Commit dc29e7a

Browse files
committed
Add intention action to convert @SQL annotation to SQL file
1 parent b291da9 commit dc29e7a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/test/kotlin/org/domaframework/doma/intellij/action/dao/ConvertSqlAnnotationToFileActionTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
package org.domaframework.doma.intellij.action.dao
1717

1818
import com.intellij.openapi.fileEditor.FileEditorManager
19+
import org.domaframework.doma.intellij.bundle.MessageBundle
1920

2021
class ConvertSqlAnnotationToFileActionTest : ConvertSqlActionTest() {
2122
private val sqlConversionPackage = "sqltofile"
22-
private val convertActionName = "Convert to SQL file (set sqlFile=true)"
23-
private val convertFamilyName = "Convert @Sql annotation to SQL file"
23+
private val convertActionName = MessageBundle.message("convert.sql.annotation.to.file.text")
24+
private val convertFamilyName = MessageBundle.message("convert.sql.annotation.to.file.family")
2425

2526
fun testIntentionAvailableForSelectWithSqlAnnotation() {
2627
val daoName = "SelectWithSqlAnnotationDao"

src/test/kotlin/org/domaframework/doma/intellij/action/dao/ConvertSqlFileToAnnotationActionTest.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ package org.domaframework.doma.intellij.action.dao
1818
import com.intellij.openapi.fileEditor.FileDocumentManager
1919
import com.intellij.psi.PsiDocumentManager
2020
import org.domaframework.doma.intellij.action.sql.ConvertSqlFileToAnnotationFromSqlAction
21+
import org.domaframework.doma.intellij.bundle.MessageBundle
2122

2223
class ConvertSqlFileToAnnotationActionTest : ConvertSqlActionTest() {
2324
private val sqlToAnnotationPackage = "sqltoannotation"
24-
private val convertActionName = "Convert to @Sql annotation (set sqlFile=false)"
25-
private val convertFamilyName = "Convert SQL file to @Sql annotation"
25+
private val convertActionName = MessageBundle.message("convert.sql.file.to.annotation.from.sql.text")
26+
private val convertFamilyName = MessageBundle.message("convert.sql.file.to.annotation.from.sql.family")
2627

2728
fun testIntentionAvailableForSelectWithSqlFile() {
2829
val daoName = "SelectWithSqlFileDao"
@@ -102,7 +103,8 @@ class ConvertSqlFileToAnnotationActionTest : ConvertSqlActionTest() {
102103
val intentions = myFixture.availableIntentions
103104
val convertIntention = intentions.find { it is ConvertSqlFileToAnnotationFromSqlAction }
104105

105-
assertNull("$convertFamilyName intention should NOT be available when SQL file doesn't exist", convertIntention)
106+
assertNull("$convertFamilyName intention should NOT be available when SQL file doesn't exist",
107+
convertIntention)
106108
}
107109

108110
fun testSqlFormattingInAnnotation() {
@@ -114,7 +116,8 @@ class ConvertSqlFileToAnnotationActionTest : ConvertSqlActionTest() {
114116
fun testSelectWithSqlFileConvertAnnotation() {
115117
val daoName = "SelectWithSqlFileConvertAnnotationDao"
116118
val sqlFileName = "selectEmployee.sql"
117-
doConvertActionTest(daoName, sqlToAnnotationPackage, convertFamilyName, ConvertSqlFileToAnnotationFromDaoAction::class)
119+
doConvertActionTest(daoName, sqlToAnnotationPackage, convertFamilyName,
120+
ConvertSqlFileToAnnotationFromDaoAction::class)
118121
// Test SQL File Removed
119122
val generatedSql = findSqlFile("$sqlToAnnotationPackage/$daoName/$sqlFileName")
120123
assertTrue("SQL File [$sqlFileName] should exists ", generatedSql == null)

0 commit comments

Comments
 (0)