Skip to content

Commit

Permalink
Expand test [2]
Browse files Browse the repository at this point in the history
  • Loading branch information
akarashchuk committed Nov 20, 2023
1 parent 5619456 commit 1e1a1c6
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/test/kotlin/org/onliner/kafka/transforms/ConcatFieldsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,25 @@ internal class ConcatFieldsTest {
xformValue.close()
}

@Test
fun handlesNullValue() {
configure(xformValue)
val given = SourceRecord(
null,
null,
"topic",
0,
null,
null
)
val expected = null
val actual: Any? = xformValue.apply(given).value()
Assertions.assertEquals(expected, actual)
}

@Test
fun schemalessValueConcatFields() {
configure(xformValue, listOf("latitude", "longitude"), ",", "location")
configure(xformValue)

val original = mapOf(
"id" to 1,
Expand All @@ -39,7 +55,7 @@ internal class ConcatFieldsTest {

@Test
fun copyValueSchemaAndConvertFields() {
configure(xformValue, listOf("latitude", "longitude"), ",", "location")
configure(xformValue)

val schema = SchemaBuilder
.struct()
Expand Down Expand Up @@ -76,13 +92,8 @@ internal class ConcatFieldsTest {
Assertions.assertEquals((-27.5666700).toFloat(), (transformed.value() as Struct).getFloat32("longitude"))
}

private fun configure(
transform: ConcatFields<SourceRecord>,
fields: List<String>,
delimiter: String,
output: String
) {
val props = mapOf("fields" to fields, "delimiter" to delimiter, "output" to output)
private fun configure(transform: ConcatFields<SourceRecord>) {
val props = mapOf("fields" to listOf("latitude", "longitude"), "delimiter" to ",", "output" to "location")

transform.configure(props.toMap())
}
Expand Down

0 comments on commit 1e1a1c6

Please sign in to comment.