use of org.apache.beam.sdk.io.kafka.KafkaCommitOffset.CommitOffsetDoFn in project beam by apache.
the class KafkaCommitOffsetTest method testCommitOffsetDoFn.
@Test
public void testCommitOffsetDoFn() {
Map<String, Object> configMap = new HashMap<>();
configMap.put(ConsumerConfig.GROUP_ID_CONFIG, "group1");
ReadSourceDescriptors<Object, Object> descriptors = ReadSourceDescriptors.read().withBootstrapServers("bootstrap_server").withConsumerConfigUpdates(configMap).withConsumerFactoryFn(new SerializableFunction<Map<String, Object>, Consumer<byte[], byte[]>>() {
@Override
public Consumer<byte[], byte[]> apply(Map<String, Object> input) {
Assert.assertEquals("group1", input.get(ConsumerConfig.GROUP_ID_CONFIG));
return consumer;
}
});
CommitOffsetDoFn doFn = new CommitOffsetDoFn(descriptors);
doFn.processElement(KV.of(KafkaSourceDescriptor.of(partition, null, null, null, null, null), 1L));
Assert.assertEquals(2L, consumer.commit.get(partition).offset());
}
Aggregations