fozzie15 commented on code in PR #34426:
URL: https://github.com/apache/beam/pull/34426#discussion_r2017773287
##########
sdks/java/io/kafka/src/test/java/org/apache/beam/sdk/io/kafka/KafkaReadSchemaTransformProviderTest.java:
##########
@@ -340,4 +346,61 @@ public void testManagedMappings() {
assertTrue(configSchemaFieldNames.contains(paramName));
}
}
+
+ @Test
+ public void testGetRawBytesKvToRowFunction() {
+ Schema testSchema =
+ Schema.builder()
+ .addField("key", Schema.FieldType.BYTES)
+ .addField("value", Schema.FieldType.BYTES)
+ .build();
+
+ SerializableFunction<KV<byte[], byte[]>, Row> kvToRow =
+
KafkaReadSchemaTransformProvider.getRawBytesKvToRowFunction(testSchema);
+
+ KV<byte[], byte[]> inputKv =
+ KV.of(
+ "testKey".getBytes(StandardCharsets.UTF_8),
+ "testValue".getBytes(StandardCharsets.UTF_8));
+ Row outputRow = kvToRow.apply(inputKv);
+
+ assertEquals("testKey", new String(outputRow.getBytes("key"),
StandardCharsets.UTF_8));
+ assertEquals("testValue", new String(outputRow.getBytes("value"),
StandardCharsets.UTF_8));
+ }
+
+ @Test
+ public void testGetRawBytesKvToRowFunctionEmptyKey() {
Review Comment:
Can we also add an integration test?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]