-
Notifications
You must be signed in to change notification settings - Fork 2
/
EmployeeMapperTest.kt
73 lines (58 loc) · 1.82 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
66
67
68
69
70
71
72
73
package com.driver733.mapstructfluent
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.compilation.shouldNotCompile
import io.kotest.matchers.shouldBe
import org.springframework.boot.test.context.SpringBootTest
@SpringBootTest
class EmployeeMapperTest(
private val mapper: EmployeeMapper
) : FunSpec({
test("mapstruct impl") {
val model = EmployeeModel("Alex")
val actual = model.toEmployeeView()
actual.apply {
shouldBe(EmployeeView("Alex"))
shouldBe(mapper.toEmployeeView(model))
}
}
test("mapstruct additional arguments") {
val model = EmployeeModel("Alex")
val actual = model.toEmployeeCompanyView("amazon")
actual.apply {
shouldBe(EmployeeCompanyView("Alex", "amazon"))
shouldBe(mapper.toEmployeeCompanyView(model, "amazon"))
}
}
test("custom mapper impl") {
val model = EmployeeModel("Alex")
model
.toEmployeeCustomView()
.shouldBe(
mapper.toEmployeeCustomView(model)
)
}
test("ignore BeforeMapping") {
EmployeeMapper::class.java.getBean().toEmployeeViewBefore()
"""
package com.driver733.mapstructfluent
class A {
fun b() {
EmployeeModel("Alex").toEmployeeViewBefore()
}
}
""".trimIndent()
.shouldNotCompile()
}
test("ignore AfterMapping") {
EmployeeMapper::class.java.getBean().toEmployeeViewAfter()
"""
package com.driver733.mapstructfluent
class A {
fun b() {
EmployeeModel("Alex").toEmployeeViewAfter()
}
}
""".trimIndent()
.shouldNotCompile()
}
})