private AbstractResponse getResponse(ApiKeys apikey, short version) {
        switch (apikey) {
            case PRODUCE: return createProduceResponse();
            case FETCH: return createFetchResponse(version);
            case LIST_OFFSETS: return createListOffsetResponse(version);
            case METADATA: return createMetadataResponse();
            case LEADER_AND_ISR: return createLeaderAndIsrResponse(version);
            case STOP_REPLICA: return createStopReplicaResponse();
            case UPDATE_METADATA: return createUpdateMetadataResponse();
            case CONTROLLED_SHUTDOWN: return createControlledShutdownResponse();
            case OFFSET_COMMIT: return createOffsetCommitResponse();
            case OFFSET_FETCH: return createOffsetFetchResponse(version);
            case FIND_COORDINATOR: return createFindCoordinatorResponse(version);
            case JOIN_GROUP: return createJoinGroupResponse(version);
            case HEARTBEAT: return createHeartBeatResponse();
            case LEAVE_GROUP: return createLeaveGroupResponse();
            case SYNC_GROUP: return createSyncGroupResponse(version);
            case DESCRIBE_GROUPS: return createDescribeGroupResponse();
            case LIST_GROUPS: return createListGroupsResponse(version);
            case SASL_HANDSHAKE: return createSaslHandshakeResponse();
            case API_VERSIONS: return createApiVersionResponse();
            case CREATE_TOPICS: return createCreateTopicResponse();
            case DELETE_TOPICS: return createDeleteTopicsResponse();
            case DELETE_RECORDS: return createDeleteRecordsResponse();
            case INIT_PRODUCER_ID: return createInitPidResponse();
            case OFFSET_FOR_LEADER_EPOCH: return createLeaderEpochResponse();
            case ADD_PARTITIONS_TO_TXN: return createAddPartitionsToTxnResponse(version);
            case ADD_OFFSETS_TO_TXN: return createAddOffsetsToTxnResponse();
            case END_TXN: return createEndTxnResponse();
            case WRITE_TXN_MARKERS: return createWriteTxnMarkersResponse();
            case TXN_OFFSET_COMMIT: return createTxnOffsetCommitResponse();
            case DESCRIBE_ACLS: return createDescribeAclsResponse();
            case CREATE_ACLS: return createCreateAclsResponse();
            case DELETE_ACLS: return createDeleteAclsResponse(version);
            case DESCRIBE_CONFIGS: return createDescribeConfigsResponse(version);
            case ALTER_CONFIGS: return createAlterConfigsResponse();
            case ALTER_REPLICA_LOG_DIRS: return createAlterReplicaLogDirsResponse();
            case DESCRIBE_LOG_DIRS: return createDescribeLogDirsResponse();
            case SASL_AUTHENTICATE: return createSaslAuthenticateResponse();
            case CREATE_PARTITIONS: return createCreatePartitionsResponse();
            case CREATE_DELEGATION_TOKEN: return createCreateTokenResponse();
            case RENEW_DELEGATION_TOKEN: return createRenewTokenResponse();
            case EXPIRE_DELEGATION_TOKEN: return createExpireTokenResponse();
            case DESCRIBE_DELEGATION_TOKEN: return createDescribeTokenResponse(version);
            case DELETE_GROUPS: return createDeleteGroupsResponse();
            case ELECT_LEADERS: return createElectLeadersResponse();
            case INCREMENTAL_ALTER_CONFIGS: return createIncrementalAlterConfigsResponse();
            case ALTER_PARTITION_REASSIGNMENTS: return createAlterPartitionReassignmentsResponse();
            case LIST_PARTITION_REASSIGNMENTS: return createListPartitionReassignmentsResponse();
            case OFFSET_DELETE: return createOffsetDeleteResponse();
            case DESCRIBE_CLIENT_QUOTAS: return createDescribeClientQuotasResponse();
            case ALTER_CLIENT_QUOTAS: return createAlterClientQuotasResponse();
            case DESCRIBE_USER_SCRAM_CREDENTIALS: return createDescribeUserScramCredentialsResponse();
            case ALTER_USER_SCRAM_CREDENTIALS: return createAlterUserScramCredentialsResponse();
            case VOTE: return createVoteResponse();
            case BEGIN_QUORUM_EPOCH: return createBeginQuorumEpochResponse();
            case END_QUORUM_EPOCH: return createEndQuorumEpochResponse();
            case DESCRIBE_QUORUM: return createDescribeQuorumResponse();
            case ALTER_PARTITION: return createAlterPartitionResponse(version);
            case UPDATE_FEATURES: return createUpdateFeaturesResponse();
            case ENVELOPE: return createEnvelopeResponse();
            case FETCH_SNAPSHOT: return createFetchSnapshotResponse();
            case DESCRIBE_CLUSTER: return createDescribeClusterResponse();
            case DESCRIBE_PRODUCERS: return createDescribeProducersResponse();
            case BROKER_REGISTRATION: return createBrokerRegistrationResponse();
            case BROKER_HEARTBEAT: return createBrokerHeartbeatResponse();
            case UNREGISTER_BROKER: return createUnregisterBrokerResponse();
            case DESCRIBE_TRANSACTIONS: return createDescribeTransactionsResponse();
            case LIST_TRANSACTIONS: return createListTransactionsResponse();
            case ALLOCATE_PRODUCER_IDS: return createAllocateProducerIdsResponse();
            case CONSUMER_GROUP_HEARTBEAT: return createConsumerGroupHeartbeatResponse();
            case CONSUMER_GROUP_DESCRIBE: return createConsumerGroupDescribeResponse();
            case CONTROLLER_REGISTRATION: return createControllerRegistrationResponse();
            case GET_TELEMETRY_SUBSCRIPTIONS: return createGetTelemetrySubscriptionsResponse();
            case PUSH_TELEMETRY: return createPushTelemetryResponse();
            case ASSIGN_REPLICAS_TO_DIRS: return createAssignReplicasToDirsResponse();
            case LIST_CLIENT_METRICS_RESOURCES: return createListClientMetricsResourcesResponse();
            case DESCRIBE_TOPIC_PARTITIONS: return createDescribeTopicPartitionsResponse();
            case SHARE_GROUP_HEARTBEAT: return createShareGroupHeartbeatResponse();
            case SHARE_GROUP_DESCRIBE: return createShareGroupDescribeResponse();
            case SHARE_FETCH: return createShareFetchResponse();
            case SHARE_ACKNOWLEDGE: return createShareAcknowledgeResponse();
            case ADD_RAFT_VOTER: return createAddRaftVoterResponse();
            case REMOVE_RAFT_VOTER: return createRemoveRaftVoterResponse();
            case UPDATE_RAFT_VOTER: return createUpdateRaftVoterResponse();
            case INITIALIZE_SHARE_GROUP_STATE: return createInitializeShareGroupStateResponse();
            case READ_SHARE_GROUP_STATE: return createReadShareGroupStateResponse();
            case WRITE_SHARE_GROUP_STATE: return createWriteShareGroupStateResponse();
            case DELETE_SHARE_GROUP_STATE: return createDeleteShareGroupStateResponse();
            case READ_SHARE_GROUP_STATE_SUMMARY: return createReadShareGroupStateSummaryResponse();
            default: throw new IllegalArgumentException("Unknown API key " + apikey);
        }
    }
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