@Override
    public LookupResult<BrokerKey> handleResponse(Set<BrokerKey> keys, AbstractResponse abstractResponse) {
        validateLookupKeys(keys);

        MetadataResponse response = (MetadataResponse) abstractResponse;
        MetadataResponseData.MetadataResponseBrokerCollection brokers = response.data().brokers();

        if (brokers.isEmpty()) {
            log.debug("Metadata response contained no brokers. Will backoff and retry");
            return LookupResult.empty();
        } else {
            log.debug("Discovered all brokers {} to send requests to", brokers);
        }

        Map<BrokerKey, Integer> brokerKeys = brokers.stream().collect(Collectors.toMap(
            broker -> new BrokerKey(OptionalInt.of(broker.nodeId())),
            MetadataResponseData.MetadataResponseBroker::nodeId
        ));

        return new LookupResult<>(
            Collections.singletonList(ANY_BROKER),
            Collections.emptyMap(),
            brokerKeys
        );
    }
@Test
    public void testHandleResponse() {
        AllBrokersStrategy strategy = new AllBrokersStrategy(logContext);

        MetadataResponseData response = new MetadataResponseData();
        response.brokers().add(new MetadataResponseData.MetadataResponseBroker()
            .setNodeId(1)
            .setHost("host1")
            .setPort(9092)
        );
        response.brokers().add(new MetadataResponseData.MetadataResponseBroker()
            .setNodeId(2)
            .setHost("host2")
            .setPort(9092)
        );

        AdminApiLookupStrategy.LookupResult<AllBrokersStrategy.BrokerKey> lookupResult = strategy.handleResponse(
            AllBrokersStrategy.LOOKUP_KEYS,
            new MetadataResponse(response, ApiKeys.METADATA.latestVersion())
        );

        assertEquals(Collections.emptyMap(), lookupResult.failedKeys);

        Set<AllBrokersStrategy.BrokerKey> expectedMappedKeys = mkSet(
            new AllBrokersStrategy.BrokerKey(OptionalInt.of(1)),
            new AllBrokersStrategy.BrokerKey(OptionalInt.of(2))
        );

        assertEquals(expectedMappedKeys, lookupResult.mappedKeys.keySet());
        lookupResult.mappedKeys.forEach((brokerKey, brokerId) ->
            assertEquals(OptionalInt.of(brokerId), brokerKey.brokerId)
        );
    }