barber
barber copied to clipboard
Add validation & tests for only supporting specific types in DocumentData
Especially once field stemming is supported, we want to explicitly indicate which types are supported and which aren't.
@Disabled @Test
fun `Fails on a non supported DocumentData unit`() {
data class StrangeUnitDocumentData(
val strange: Unit
) : DocumentData
val strangeUnitEN_US = DocumentTemplate(
fields = mapOf(
"sms_body" to "That's {{ strange }}"
),
source = StrangeUnitDocumentData::class,
targets = setOf(TransactionalSmsDocument::class),
locale = Locale.EN_US
)
val exception = assertFailsWith<BarberException> {
BarbershopBuilder()
.installDocument<TransactionalEmailDocument>()
.installDocument<TransactionalSmsDocument>()
.installDocumentTemplate<StrangeUnitDocumentData>(strangeUnitEN_US)
.build()
}
assertEquals(
"""
|Problems
|1) ...
|
""".trimMargin(),
exception.toString())
}