kotlinFixture๋ฅผ ์ ์ฉํด๋ณด๋ ์ค ์๋ฌ๋ฅผ ๋ง์ฃผํ๋ค.
val domain: Domain =
fixture<Domain> {
property(Domain::doubleField) { 100.0 }
property(Domain::mutableMapField) {
mutableMapOf(
"key" to "value",
)
}
}
์์ ๊ฐ์ด Domain ๋ฅผ fixture๋ก ์์ฑํ๋๋ฐ ์๋์ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค.
kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Could not compute caller for function: public constructor Array(size: kotlin.Int, init: (kotlin.Int) -> T) defined in kotlin.Array[DeserializedClassConstructorDescriptor@143d9427] (member = null)
๊ฒ์ํด๋ณด๋ kotlineFixture์์ ํน์ ํ์ ์ ๋ง๋ค์ด์ฃผ์ง ์์์ ๋ฐ์ํ ์ค๋ฅ์๋ค.
fixture ์ ์ธ์์ ์๋์ ๊ฐ์ด ํน์ ํ์
์ ๋ํด์ ์ง์ ํ ์๊ฐ ์๋ค.
๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ๋ฉด ๋๋ค.
์ง๋ฆฌ์ ๋ณด๋ฅผ ์ฒ๋ฆฌํ๊ธฐ ์ํด์ org.locationtech.jts.geom๋ฅผ import ํ์ฌ ์ฌ์ฉ์ค์ธ๋ฐ ํด๋น๊ฐ์ ์ง์์ ํด์ฃผ์ง ์์ ๋ฐ์๋ ๋ฌธ์ ์๋ค.
import org.locationtech.jts.geom.Point geom์ kotlinFixture์์ ๋ฐ์ดํฐ๋ฅผ ๋ง๋ค์ด์ฃผ์ง ๋ชปํ๋ ๊ฒ ๊ฐ๋ค.ํด๊ฒฐ๋ฐฉ์์ kotlinFixture์์ ์ง์ํ์ง ์๋ ํ์ (ex:Point ํ์ )์ธ ๊ฒฝ์ฐ ํด๋น ๊ฐ์ผ๋ก ์ด๊ธฐํ๋ฅผ ์ง์ ํ๋ฉด ๋๋ค.
val fixture =
kotlinFixture {
factory<Point> { getPoint(0.0, 0.0) }
}
val fixture =
kotlinFixture {
factory<Point> { getPoint(0.0, 0.0) }
}
///์ค๋ต
val domain: Domain =
fixture<Domain> {
property(Domain::doubleField) { 100.0 }
property(Domain::mutableMapField) {
mutableMapOf(
"key" to "value",
)
}
}
๋ง์ผ Pointํ์ ์ ๋ํด์ ๋ค๋ฅธ ๊ฐ์ผ๋ก ์ง์ ์ ํ๊ณ ์ถ๋ค๋ฉด propery๋ฅผ ์ฌ์ฉํ์ฌ ์ํ๋ ๊ฐ์ผ๋ก ์ง์ ํ๋ฉด factory๋ก ์ง์ ํ ๊ฐ์ด ๋ฎ์ด ์ฐ์ฌ์ง๋ค.