Skip to content

Commit

Permalink
Reuse iterator to return list adhering to table semantics in case of
Browse files Browse the repository at this point in the history
TableOutput
  • Loading branch information
JakobEdding committed Apr 11, 2024
1 parent b1ed9cb commit 7461741
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

package com.bakdata.fluent_kafka_streams_tests;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.Serde;
import org.apache.kafka.streams.TestOutputTopic;
Expand Down Expand Up @@ -118,12 +118,9 @@ public TestOutput<K, V> asStream() {

@Override
public List<ProducerRecord<K, V>> toList() {
return this.testOutputTopic
.readRecordsToList()
.stream()
.map(testRecord -> new ProducerRecord<>(this.topic, 0, testRecord.timestamp(), testRecord.key(),
testRecord.value(), testRecord.getHeaders()))
.collect(Collectors.toList());
final List<ProducerRecord<K, V>> list = new ArrayList<>();
this.iterator().forEachRemaining(list::add);
return list;
}

// ==================
Expand Down

0 comments on commit 7461741

Please sign in to comment.