@Test
    public void testUseDefaultLeaderEpochV0ToV7() {
        final Optional<Integer> emptyLeaderEpoch = Optional.empty();
        partitionDataMap.clear();

        partitionDataMap.put(new TopicPartition(topicOne, partitionOne),
                             new PartitionData(
                                 offset,
                                 emptyLeaderEpoch,
                                 metadata,
                                 Errors.UNKNOWN_TOPIC_OR_PARTITION)
        );

        OffsetFetchResponse response = new OffsetFetchResponse(throttleTimeMs, Errors.NOT_COORDINATOR, partitionDataMap);
        OffsetFetchResponseData expectedData =
            new OffsetFetchResponseData()
                .setErrorCode(Errors.NOT_COORDINATOR.code())
                .setThrottleTimeMs(throttleTimeMs)
                .setTopics(Collections.singletonList(
                new OffsetFetchResponseTopic()
                    .setName(topicOne)
                    .setPartitions(Collections.singletonList(
                        new OffsetFetchResponsePartition()
                            .setPartitionIndex(partitionOne)
                            .setCommittedOffset(offset)
                            .setCommittedLeaderEpoch(RecordBatch.NO_PARTITION_LEADER_EPOCH)
                            .setErrorCode(Errors.UNKNOWN_TOPIC_OR_PARTITION.code())
                            .setMetadata(metadata))
                    ))
                );
        assertEquals(expectedData, response.data());
    }
Test behavior changes over the versions. Refer to resources.common.messages.OffsetFetchResponse.json
clients/src/test/java/org/apache/kafka/common/requests/OffsetFetchResponseTest.java