Skip to content

Commit 63c9605

Browse files
committed
Fix tests for unavailable SQL annotation conversion intentions and update method signatures
1 parent 953dd4f commit 63c9605

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,23 @@ abstract class ConvertSqlActionTest : DomaSqlTest() {
6565
convertIntention.invoke(myFixture.project, myFixture.editor, myFixture.file)
6666
}
6767

68+
protected fun doNotAvailableConvertActionTest(
69+
daoName: String,
70+
sqlToAnnotationPackage: String,
71+
convertFamilyName: String,
72+
) {
73+
addDaoJavaFile("$sqlToAnnotationPackage/$daoName.java")
74+
val daoClass = findDaoClass("$sqlToAnnotationPackage.$daoName")
75+
myFixture.configureFromExistingVirtualFile(daoClass.containingFile.virtualFile)
76+
77+
val intentions = myFixture.availableIntentions
78+
val convertIntention = intentions.find { it.familyName == convertFamilyName }
79+
if (convertIntention != null) {
80+
fail("[$convertFamilyName] intention should be available without @Sql annotation")
81+
return
82+
}
83+
}
84+
6885
protected fun doTestSqlFormat(
6986
daoName: String,
7087
sqlFileName: String,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ class ConvertSqlAnnotationToFileActionTest : ConvertSqlActionTest() {
110110

111111
fun testIntentionNotAvailableForMethodWithoutSqlAnnotation() {
112112
val daoName = "NoSqlAnnotationDao"
113-
doAvailableConvertActionTest(daoName, sqlConversionPackage, convertFamilyName)
113+
doNotAvailableConvertActionTest(daoName, sqlConversionPackage, convertFamilyName)
114114
}
115115

116116
fun testIntentionNotAvailableForUnsupportedAnnotation() {
117117
val daoName = "UnsupportedAnnotationDao"
118-
doAvailableConvertActionTest(daoName, sqlConversionPackage, convertFamilyName)
118+
doNotAvailableConvertActionTest(daoName, sqlConversionPackage, convertFamilyName)
119119
}
120120

121121
private fun doTest(

src/test/testData/src/main/java/doma/example/dao/sqltofile/bulk/BulkConvertToSqlFileDao.after.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ public interface BulkConvertToSqlFileDao {
3737
@Select
3838
Employee selectEmployee(int id);
3939

40-
@Insert
40+
@Insert(sqlFile = true)
4141
int insertEmployee(Employee employee);
4242

43-
@Update
43+
@Update(sqlFile = true)
4444
int updateEmployee(Employee employee);
4545

46-
@Delete
46+
@Delete(sqlFile = true)
4747
int deleteEmployee(Employee employee);
4848

49-
@BatchInsert
49+
@BatchInsert(sqlFile = true)
5050
int[] batchInsertEmployees(List<Employee> employees);
5151

52-
@BatchUpdate
52+
@BatchUpdate(sqlFile = true)
5353
int[] batchUpdateEmployees(List<Employee> employees);
5454

55-
@BatchDelete
55+
@BatchDelete(sqlFile = true)
5656
int[] batchDeleteEmployees(List<Employee> employees);
5757

5858
@Script
@@ -64,4 +64,4 @@ public interface BulkConvertToSqlFileDao {
6464
// Annotation not supported
6565
@Function
6666
void executeFunc();
67-
}
67+
}

0 commit comments

Comments
 (0)