private FetchResponse fetchResponse2(TopicIdPartition tp1, MemoryRecords records1, long hw1,
                                         TopicIdPartition tp2, MemoryRecords records2, long hw2) {
        Map<TopicIdPartition, FetchResponseData.PartitionData> partitions = new HashMap<>();
        partitions.put(tp1,
                new FetchResponseData.PartitionData()
                        .setPartitionIndex(tp1.topicPartition().partition())
                        .setErrorCode(Errors.NONE.code())
                        .setHighWatermark(hw1)
                        .setLastStableOffset(FetchResponse.INVALID_LAST_STABLE_OFFSET)
                        .setLogStartOffset(0)
                        .setRecords(records1));
        partitions.put(tp2,
                new FetchResponseData.PartitionData()
                        .setPartitionIndex(tp2.topicPartition().partition())
                        .setErrorCode(Errors.NONE.code())
                        .setHighWatermark(hw2)
                        .setLastStableOffset(FetchResponse.INVALID_LAST_STABLE_OFFSET)
                        .setLogStartOffset(0)
                        .setRecords(records2));
        return FetchResponse.of(Errors.NONE, 0, INVALID_SESSION_ID, new LinkedHashMap<>(partitions));
    }
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/FetcherTest.java