private OffsetsForLeaderEpochResponse prepareOffsetsForLeaderEpochResponse(
            TopicPartition topicPartition,
            Errors error,
            int leaderEpoch,
            long endOffset
    ) {
        OffsetForLeaderEpochResponseData data = new OffsetForLeaderEpochResponseData();
        data.topics().add(new OffsetForLeaderTopicResult()
                .setTopic(topicPartition.topic())
                .setPartitions(Collections.singletonList(new EpochEndOffset()
                        .setPartition(topicPartition.partition())
                        .setErrorCode(error.code())
                        .setLeaderEpoch(leaderEpoch)
                        .setEndOffset(endOffset))));
        return new OffsetsForLeaderEpochResponse(data);
    }
Test the scenario that FetchResponse returns with an error indicating leadership change for the partition, along with
new leader info(defined in KIP-951).
clients/src/test/java/org/apache/kafka/clients/consumer/internals/FetchRequestManagerTest.java