Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Kafka sink connector to work with CUD ingestion strategy and Avro format data.

See neo4j-contrib/neo4j-streams#582
  • Loading branch information
conker84 authored and fbiville committed Nov 3, 2023
1 parent a9a96e2 commit 4116057
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import org.apache.kafka.connect.data.SchemaBuilder
import org.apache.kafka.connect.data.Struct
import org.junit.jupiter.api.Test
import org.neo4j.connectors.kafka.utils.JSONUtils
import org.neo4j.driver.Values

@Suppress("UNCHECKED_CAST")
class Neo4jValueConverterNestedStructTest {
Expand Down Expand Up @@ -125,9 +124,7 @@ class Neo4jValueConverterNestedStructTest {
}

fun getExpectedMap(): Map<String, Any?> {
return JSONUtils.readValue<Map<String, Any?>>(data).mapValues(::convertDateNew).mapValues {
Values.value(it.value)
}
return JSONUtils.readValue<Map<String, Any?>>(data).mapValues(::convertDateNew)
}

fun convertDate(it: Map.Entry<String, Any?>): Any? =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import org.apache.kafka.connect.data.Struct
import org.apache.kafka.connect.data.Time
import org.apache.kafka.connect.data.Timestamp
import org.junit.jupiter.api.Test
import org.neo4j.driver.Value
import org.neo4j.driver.Values

class Neo4jValueConverterTest {

Expand Down Expand Up @@ -458,33 +456,24 @@ class Neo4jValueConverterTest {
return Struct(BODY_SCHEMA).put("ul", ulList).put("p", pList)
}

fun getExpectedMap(): Map<String, Value> {
fun getExpectedMap(): Map<String, Any?> {
val firstULMap =
mapOf(
"value" to
listOf(
mapOf("value" to "First UL - First Element", "class" to null),
mapOf(
"value" to Values.value("First UL - First Element"),
"class" to Values.NULL),
mapOf(
"value" to Values.value("First UL - Second Element"),
"class" to Values.value(listOf("ClassA", "ClassB")))))
"value" to "First UL - Second Element",
"class" to listOf("ClassA", "ClassB"))))
val secondULMap =
mapOf(
"value" to
listOf(
mapOf(
"value" to Values.value("Second UL - First Element"),
"class" to Values.NULL),
mapOf(
"value" to Values.value("Second UL - Second Element"),
"class" to Values.NULL)))
val ulListMap = Values.value(listOf(firstULMap, secondULMap))
mapOf("value" to "Second UL - First Element", "class" to null),
mapOf("value" to "Second UL - Second Element", "class" to null)))
val ulListMap = listOf(firstULMap, secondULMap)
val pListMap =
Values.value(
listOf(
mapOf("value" to Values.value("First Paragraph")),
mapOf("value" to Values.value("Second Paragraph"))))
listOf(mapOf("value" to "First Paragraph"), mapOf("value" to "Second Paragraph"))
return mapOf("ul" to ulListMap, "p" to pListMap)
}

Expand Down

0 comments on commit 4116057

Please sign in to comment.