Kotlin单元测试增加默认方法查询.
This commit is contained in:
parent
30342f3cfc
commit
549d4ea598
@ -1,7 +1,15 @@
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
compileKotlin{
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
compileTestKotlin {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = ['-Xjvm-default=all']
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -38,6 +38,15 @@ class ChainWrappersTest : BaseDbTest<UserMapper>() {
|
||||
Assertions.assertEquals(4, Db.ktQuery(User::class.java).eq(User::id, 2).one().roleId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDefaultMethod() {
|
||||
doTestAutoCommit(fun(m) {
|
||||
Assertions.assertEquals("hello baomidou!", m.hello())
|
||||
Assertions.assertNotNull(m.findById(1))
|
||||
Assertions.assertNull(m.findById(-1))
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSetSql() {
|
||||
Assertions.assertTrue(
|
||||
|
@ -1,5 +1,16 @@
|
||||
package com.baomidou.mybatisplus.test.kotlin
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper
|
||||
import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
|
||||
|
||||
interface UserMapper : BaseMapper<User>
|
||||
interface UserMapper : BaseMapper<User> {
|
||||
|
||||
fun hello(): String {
|
||||
return "hello baomidou!";
|
||||
}
|
||||
|
||||
fun findById(id: Int): User? {
|
||||
return selectOne(KtQueryWrapper(User::class.java).eq(User::id, id));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user