[CMLR-080] 完成编译与分层自动化测试
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package vvpkassistant.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import vvpkassistant.User.mapper.SignInRecordDao;
|
||||
import vvpkassistant.User.mapper.UserDao;
|
||||
import vvpkassistant.pk.mapper.PkInfoDao;
|
||||
import vvpkassistant.pk.mapper.PkRecordDao;
|
||||
import vvpkassistant.pk.mapper.PkRecordDetailDao;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
class DaoLambdaMigrationContractTests {
|
||||
|
||||
@Test
|
||||
void shouldRemoveCrossTableMethodsFromUserDao() {
|
||||
List<String> methodNames = Arrays.asList("findCreatedPk", "getMyGuestPkList", "signIn", "checkSignStatus");
|
||||
for (Method method : UserDao.class.getMethods()) {
|
||||
Assertions.assertFalse(methodNames.contains(method.getName()),
|
||||
"UserDao 仍包含跨表方法: " + method.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldUseNonAnnotatedLambdaMethodsForMigratedDaos() throws Exception {
|
||||
assertNoSelect(UserDao.class.getMethod("queryWithPhoneNumber", String.class));
|
||||
assertNoSelect(PkInfoDao.class.getMethod("selectPkInfoByCondition", int.class, int.class, java.util.Map.class, long.class, long.class));
|
||||
assertNoSelect(PkRecordDao.class.getMethod("pkListForToday", long.class, long.class));
|
||||
assertNoSelect(PkRecordDao.class.getMethod("fetchDataFromTodayWithUserId", Integer.class, Long.class));
|
||||
assertNoSelect(PkRecordDao.class.getMethod("getPendingInvitations", String.class, String.class));
|
||||
assertNoSelect(PkRecordDao.class.getMethod("singleRecord", Integer.class));
|
||||
assertNoSelect(PkRecordDao.class.getMethod("findCreatedPk", Integer.class, Integer.class, Integer.class));
|
||||
assertNoSelect(PkRecordDao.class.getMethod("getMyGuestPkList", Integer.class, Integer.class, Integer.class));
|
||||
assertNoSelect(PkRecordDetailDao.class.getMethod("queryDetail", Integer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldUseSignInRecordDaoForSignInChain() throws Exception {
|
||||
Method signIn = SignInRecordDao.class.getMethod("signIn", int.class);
|
||||
Method checkStatus = SignInRecordDao.class.getMethod("checkSignStatus", int.class);
|
||||
Assertions.assertNull(signIn.getAnnotation(Insert.class), "SignInRecordDao.signIn 不应使用注解SQL");
|
||||
Assertions.assertNull(checkStatus.getAnnotation(Select.class), "SignInRecordDao.checkSignStatus 不应使用注解SQL");
|
||||
}
|
||||
|
||||
private static void assertNoSelect(Method method) {
|
||||
Assertions.assertNull(method.getAnnotation(Select.class), "方法不应保留 @Select: " + method.getName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user