GeezerVison is showing github.com — MINOR: Deduplicate share fetch test helpers (#23953) · coderbruis/kafka@c4480af
File treeExpand file treeCollapse file tree Open diff view settings core/src/test/java/kafka/server/share
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: core/src/test/java/kafka/server/share/DelayedShareFetchTest.java +1-7Lines changed: 1 addition & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3458,13 +3458,7 @@ private static LinkedHashMap<TopicIdPartition, LogReadResult> toLogReadResultMap | 3458 | 3458 | } | 3459 | 3459 |
| 3460 | 3460 | private static LinkedHashMap<TopicIdPartition, LogReadResult> buildLogReadResultMap(List<TopicIdPartition> topicIdPartitions, Records records) { | 3461 | | - return CollectionConverters.asJava(buildLogReadResult(topicIdPartitions, records)).stream() | 3462 | | - .collect(Collectors.toMap( | 3463 | | - Tuple2::_1, | 3464 | | - Tuple2::_2, | 3465 | | - (oldValue, newValue) -> oldValue, | 3466 | | - LinkedHashMap::new | 3467 | | - )); | | 3461 | + return toLogReadResultMap(buildLogReadResult(topicIdPartitions, records)); | 3468 | 3462 | } | 3469 | 3463 |
| 3470 | 3464 | @SuppressWarnings("unchecked") | |
Collapse file Copy file name to clipboardExpand all lines: core/src/test/java/kafka/server/share/SharePartitionManagerTest.java +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3261,13 +3261,15 @@ private void validateBrokerTopicStatsMetrics( | 3261 | 3261 | } | 3262 | 3262 |
| 3263 | 3263 | static Seq<Tuple2<TopicIdPartition, LogReadResult>> buildLogReadResult(List<TopicIdPartition> topicIdPartitions) { | 3264 | | - return buildLogReadResult(topicIdPartitions, MemoryRecords.withRecords( | 3265 | | - Compression.NONE, new SimpleRecord("test-key".getBytes(), "test-value".getBytes()))); | | 3264 | + return buildLogReadResult(topicIdPartitions, defaultTestRecords()); | 3266 | 3265 | } | 3267 | 3266 |
| 3268 | 3267 | static Seq<Tuple2<TopicIdPartition, LogReadResult>> buildLogReadResult(Map<TopicIdPartition, LogOffsetMetadata> fetchOffsetMetadata) { | 3269 | | - return buildLogReadResult(fetchOffsetMetadata, MemoryRecords.withRecords( | 3270 | | - Compression.NONE, new SimpleRecord("test-key".getBytes(), "test-value".getBytes()))); | | 3268 | + return buildLogReadResult(fetchOffsetMetadata, defaultTestRecords()); | | 3269 | + } | | 3270 | + | | 3271 | + private static MemoryRecords defaultTestRecords() { | | 3272 | + return MemoryRecords.withRecords(Compression.NONE, new SimpleRecord("test-key".getBytes(), "test-value".getBytes())); | 3271 | 3273 | } | 3272 | 3274 |
| 3273 | 3275 | static Seq<Tuple2<TopicIdPartition, LogReadResult>> buildEmptyLogReadResult(List<TopicIdPartition> topicIdPartitions) { | |
|