@Override
    public Collection<RequestAndKeys<CoordinatorKey>> buildRequest(int brokerId, Set<CoordinatorKey> groupIds) {
        validateKeys(groupIds);

        // When the OffsetFetchRequest fails with NoBatchedOffsetFetchRequestException, we completely disable
        // the batching end-to-end, including the FindCoordinatorRequest.
        if (lookupStrategy.batch()) {
            return Collections.singletonList(new RequestAndKeys<>(buildBatchedRequest(groupIds), groupIds));
        } else {
            return groupIds.stream().map(groupId -> {
                Set<CoordinatorKey> keys = Collections.singleton(groupId);
                return new RequestAndKeys<>(buildBatchedRequest(keys), keys);
            }).collect(Collectors.toList());
        }
    }
@Test
    public void testBuildRequest() {
        ListConsumerGroupOffsetsHandler handler =
            new ListConsumerGroupOffsetsHandler(singleRequestMap, false, logContext);
        OffsetFetchRequest request = handler.buildBatchedRequest(coordinatorKeys(groupZero)).build();
        assertEquals(groupZero, request.data().groups().get(0).groupId());
        assertEquals(2, request.data().groups().get(0).topics().size());
        assertEquals(2, request.data().groups().get(0).topics().get(0).partitionIndexes().size());
        assertEquals(2, request.data().groups().get(0).topics().get(1).partitionIndexes().size());
    }