-
Notifications
You must be signed in to change notification settings - Fork 2
/
EmployeeMapperTest.kt
65 lines (51 loc) · 1.68 KB
/
EmployeeMapperTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.driver733.mapstructfluent
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.compilation.shouldNotCompile
import io.kotest.matchers.shouldBe
import org.mapstruct.factory.Mappers
class EmployeeMapperTest : FunSpec({
test("mapstruct impl") {
val model = EmployeeModel("Alex")
val actual = model.toEmployeeView()
actual.apply {
shouldBe(EmployeeView("Alex"))
shouldBe(Mappers.getMapper(EmployeeMapper::class.java).toEmployeeView(model))
}
}
test("mapstruct additional arguments") {
val model = EmployeeModel("Alex")
val actual = model.toEmployeeCompanyView("amazon")
actual.apply {
shouldBe(EmployeeCompanyView("Alex", "amazon"))
shouldBe(Mappers.getMapper(EmployeeMapper::class.java).toEmployeeCompanyView(model, "amazon"))
}
}
test("ignore BeforeMapping impl") {
Mappers
.getMapper(EmployeeMapper::class.java)
.toEmployeeViewBefore()
"""
package com.driver733.mapstructfluent
class A {
fun b() {
EmployeeModel("Alex").toEmployeeViewBefore()
}
}
""".trimIndent()
.shouldNotCompile()
}
test("ignore AfterMapping impl") {
Mappers
.getMapper(EmployeeMapper::class.java)
.toEmployeeViewAfter()
"""
package com.driver733.mapstructfluent
class A {
fun b() {
EmployeeModel("Alex").toEmployeeViewAfter()
}
}
""".trimIndent()
.shouldNotCompile()
}
})