private Mono<Collection<TopicPartition>> filterPartitionsWithLeaderCheck(Collection<TopicPartition> partitions,
                                                                           boolean failOnUnknownLeader) {
    var targetTopics = partitions.stream().map(TopicPartition::topic).collect(Collectors.toSet());
    return describeTopicsImpl(targetTopics)
        .map(descriptions ->
            filterPartitionsWithLeaderCheck(
                descriptions.values(), partitions::contains, failOnUnknownLeader));
  }
@Test
  void filterPartitionsWithLeaderCheckThrowExceptionIfThereIsSomePartitionsWithoutLeaderAndFlagSet() {
    ThrowingCallable call = () -> ReactiveAdminClient.filterPartitionsWithLeaderCheck(
        List.of(
            // contains partitions with no leader
            new TopicDescription("t1", false,
                List.of(
                    new TopicPartitionInfo(0, new Node(1, "n1", 9092), List.of(), List.of()),
                    new TopicPartitionInfo(1, null, List.of(), List.of()))),
            new TopicDescription("t2", false,
                List.of(
                    new TopicPartitionInfo(0, new Node(1, "n1", 9092), List.of(), List.of()))
            )),
        p -> true,
        // setting failOnNoLeader flag
        true
    );
    assertThatThrownBy(call).isInstanceOf(ValidationException.class);
  }