private AbstractRequest getRequest(ApiKeys apikey, short version) {
        switch (apikey) {
            case PRODUCE: return createProduceRequest(version);
            case FETCH: return createFetchRequest(version);
            case LIST_OFFSETS: return createListOffsetRequest(version);
            case METADATA: return createMetadataRequest(version, singletonList("topic1"));
            case LEADER_AND_ISR: return createLeaderAndIsrRequest(version);
            case STOP_REPLICA: return createStopReplicaRequest(version, true);
            case UPDATE_METADATA: return createUpdateMetadataRequest(version, "rack1");
            case CONTROLLED_SHUTDOWN: return createControlledShutdownRequest(version);
            case OFFSET_COMMIT: return createOffsetCommitRequest(version);
            case OFFSET_FETCH: return createOffsetFetchRequest(version, true);
            case FIND_COORDINATOR: return createFindCoordinatorRequest(version);
            case JOIN_GROUP: return createJoinGroupRequest(version);
            case HEARTBEAT: return createHeartBeatRequest(version);
            case LEAVE_GROUP: return createLeaveGroupRequest(version);
            case SYNC_GROUP: return createSyncGroupRequest(version);
            case DESCRIBE_GROUPS: return createDescribeGroupRequest(version);
            case LIST_GROUPS: return createListGroupsRequest(version);
            case SASL_HANDSHAKE: return createSaslHandshakeRequest(version);
            case API_VERSIONS: return createApiVersionRequest(version);
            case CREATE_TOPICS: return createCreateTopicRequest(version);
            case DELETE_TOPICS: return createDeleteTopicsRequest(version);
            case DELETE_RECORDS: return createDeleteRecordsRequest(version);
            case INIT_PRODUCER_ID: return createInitPidRequest(version);
            case OFFSET_FOR_LEADER_EPOCH: return createLeaderEpochRequestForReplica(version, 1);
            case ADD_PARTITIONS_TO_TXN: return createAddPartitionsToTxnRequest(version);
            case ADD_OFFSETS_TO_TXN: return createAddOffsetsToTxnRequest(version);
            case END_TXN: return createEndTxnRequest(version);
            case WRITE_TXN_MARKERS: return createWriteTxnMarkersRequest(version);
            case TXN_OFFSET_COMMIT: return createTxnOffsetCommitRequest(version);
            case DESCRIBE_ACLS: return createDescribeAclsRequest(version);
            case CREATE_ACLS: return createCreateAclsRequest(version);
            case DELETE_ACLS: return createDeleteAclsRequest(version);
            case DESCRIBE_CONFIGS: return createDescribeConfigsRequest(version);
            case ALTER_CONFIGS: return createAlterConfigsRequest(version);
            case ALTER_REPLICA_LOG_DIRS: return createAlterReplicaLogDirsRequest(version);
            case DESCRIBE_LOG_DIRS: return createDescribeLogDirsRequest(version);
            case SASL_AUTHENTICATE: return createSaslAuthenticateRequest(version);
            case CREATE_PARTITIONS: return createCreatePartitionsRequest(version);
            case CREATE_DELEGATION_TOKEN: return createCreateTokenRequest(version);
            case RENEW_DELEGATION_TOKEN: return createRenewTokenRequest(version);
            case EXPIRE_DELEGATION_TOKEN: return createExpireTokenRequest(version);
            case DESCRIBE_DELEGATION_TOKEN: return createDescribeTokenRequest(version);
            case DELETE_GROUPS: return createDeleteGroupsRequest(version);
            case ELECT_LEADERS: return createElectLeadersRequest(version);
            case INCREMENTAL_ALTER_CONFIGS: return createIncrementalAlterConfigsRequest(version);
            case ALTER_PARTITION_REASSIGNMENTS: return createAlterPartitionReassignmentsRequest(version);
            case LIST_PARTITION_REASSIGNMENTS: return createListPartitionReassignmentsRequest(version);
            case OFFSET_DELETE: return createOffsetDeleteRequest(version);
            case DESCRIBE_CLIENT_QUOTAS: return createDescribeClientQuotasRequest(version);
            case ALTER_CLIENT_QUOTAS: return createAlterClientQuotasRequest(version);
            case DESCRIBE_USER_SCRAM_CREDENTIALS: return createDescribeUserScramCredentialsRequest(version);
            case ALTER_USER_SCRAM_CREDENTIALS: return createAlterUserScramCredentialsRequest(version);
            case VOTE: return createVoteRequest(version);
            case BEGIN_QUORUM_EPOCH: return createBeginQuorumEpochRequest(version);
            case END_QUORUM_EPOCH: return createEndQuorumEpochRequest(version);
            case DESCRIBE_QUORUM: return createDescribeQuorumRequest(version);
            case ALTER_PARTITION: return createAlterPartitionRequest(version);
            case UPDATE_FEATURES: return createUpdateFeaturesRequest(version);
            case ENVELOPE: return createEnvelopeRequest(version);
            case FETCH_SNAPSHOT: return createFetchSnapshotRequest(version);
            case DESCRIBE_CLUSTER: return createDescribeClusterRequest(version);
            case DESCRIBE_PRODUCERS: return createDescribeProducersRequest(version);
            case BROKER_REGISTRATION: return createBrokerRegistrationRequest(version);
            case BROKER_HEARTBEAT: return createBrokerHeartbeatRequest(version);
            case UNREGISTER_BROKER: return createUnregisterBrokerRequest(version);
            case DESCRIBE_TRANSACTIONS: return createDescribeTransactionsRequest(version);
            case LIST_TRANSACTIONS: return createListTransactionsRequest(version);
            case ALLOCATE_PRODUCER_IDS: return createAllocateProducerIdsRequest(version);
            case CONSUMER_GROUP_HEARTBEAT: return createConsumerGroupHeartbeatRequest(version);
            case CONSUMER_GROUP_DESCRIBE: return createConsumerGroupDescribeRequest(version);
            case CONTROLLER_REGISTRATION: return createControllerRegistrationRequest(version);
            case GET_TELEMETRY_SUBSCRIPTIONS: return createGetTelemetrySubscriptionsRequest(version);
            case PUSH_TELEMETRY: return createPushTelemetryRequest(version);
            case ASSIGN_REPLICAS_TO_DIRS: return createAssignReplicasToDirsRequest(version);
            case LIST_CLIENT_METRICS_RESOURCES: return createListClientMetricsResourcesRequest(version);
            case DESCRIBE_TOPIC_PARTITIONS: return createDescribeTopicPartitionsRequest(version);
            case SHARE_GROUP_HEARTBEAT: return createShareGroupHeartbeatRequest(version);
            case SHARE_GROUP_DESCRIBE: return createShareGroupDescribeRequest(version);
            case SHARE_FETCH: return createShareFetchRequest(version);
            case SHARE_ACKNOWLEDGE: return createShareAcknowledgeRequest(version);
            case ADD_RAFT_VOTER: return createAddRaftVoterRequest(version);
            case REMOVE_RAFT_VOTER: return createRemoveRaftVoterRequest(version);
            case UPDATE_RAFT_VOTER: return createUpdateRaftVoterRequest(version);
            case INITIALIZE_SHARE_GROUP_STATE: return createInitializeShareGroupStateRequest(version);
            case READ_SHARE_GROUP_STATE: return createReadShareGroupStateRequest(version);
            case WRITE_SHARE_GROUP_STATE: return createWriteShareGroupStateRequest(version);
            case DELETE_SHARE_GROUP_STATE: return createDeleteShareGroupStateRequest(version);
            case READ_SHARE_GROUP_STATE_SUMMARY: return createReadShareGroupStateSummaryRequest(version);
            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