private ListOffsetsResponse createListOffsetResponse(short version) {
        if (version == 0) {
            ListOffsetsResponseData data = new ListOffsetsResponseData()
                    .setTopics(singletonList(new ListOffsetsTopicResponse()
                            .setName("test")
                            .setPartitions(singletonList(new ListOffsetsPartitionResponse()
                                    .setPartitionIndex(0)
                                    .setErrorCode(Errors.NONE.code())
                                    .setOldStyleOffsets(singletonList(100L))))));
            return new ListOffsetsResponse(data);
        } else if (version >= 1 && version <= LIST_OFFSETS.latestVersion()) {
            ListOffsetsPartitionResponse partition = new ListOffsetsPartitionResponse()
                    .setPartitionIndex(0)
                    .setErrorCode(Errors.NONE.code())
                    .setTimestamp(10000L)
                    .setOffset(100L);
            if (version >= 4) {
                partition.setLeaderEpoch(27);
            }
            ListOffsetsResponseData data = new ListOffsetsResponseData()
                    .setTopics(singletonList(new ListOffsetsTopicResponse()
                            .setName("test")
                            .setPartitions(singletonList(partition))));
            return new ListOffsetsResponse(data);
        } else {
            throw new IllegalArgumentException("Illegal ListOffsetResponse version " + version);
        }
    }
Check that all error codes in the response get included in {@link AbstractResponse#errorCounts()}.
clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java