use of org.apache.kafka.common.message.ListOffsetsRequestData.ListOffsetsTopic in project kafka by apache.
the class FetcherTest method listOffsetMatchesExpectedReset.
private boolean listOffsetMatchesExpectedReset(TopicPartition tp, OffsetResetStrategy strategy, AbstractRequest request) {
assertTrue(request instanceof ListOffsetsRequest);
ListOffsetsRequest req = (ListOffsetsRequest) request;
assertEquals(singleton(tp.topic()), req.data().topics().stream().map(ListOffsetsTopic::name).collect(Collectors.toSet()));
ListOffsetsTopic listTopic = req.data().topics().get(0);
assertEquals(singleton(tp.partition()), listTopic.partitions().stream().map(ListOffsetsPartition::partitionIndex).collect(Collectors.toSet()));
ListOffsetsPartition listPartition = listTopic.partitions().get(0);
if (strategy == OffsetResetStrategy.EARLIEST) {
assertEquals(ListOffsetsRequest.EARLIEST_TIMESTAMP, listPartition.timestamp());
} else if (strategy == OffsetResetStrategy.LATEST) {
assertEquals(ListOffsetsRequest.LATEST_TIMESTAMP, listPartition.timestamp());
}
return true;
}
Aggregations