Add test for enum interface

This commit is contained in:
Korna 2022-11-08 12:33:14 +03:00
parent 24aed8cc8b
commit 761bd5750f
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
package ru.touchin.push.message.provider.hpk.base.enums
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
class ValueableSerializableEnumTest {
private val objectMapper = jacksonObjectMapper()
@Test
fun toValue_correctJacksonSerialization() {
val enum = TestEnum.VALUE1
val expected = enum.toValue()
val actual = objectMapper.writeValueAsString(enum)
.let(objectMapper::readTree)
.textValue()
Assertions.assertEquals(
expected,
actual
)
}
private enum class TestEnum(override val value: String) : ValueableSerializableEnum<String> {
VALUE1("testValue1"),
}
}