@Override
  public ClusterHealth checkCluster() {
    checkState(!nodeInformation.isStandalone(), "Clustering is not enabled");
    checkState(sharedHealthState != null, "HealthState instance can't be null when clustering is enabled");

    Set<NodeHealth> nodeHealths = sharedHealthState.readAll();
    Health health = clusterHealthChecks.stream()
      .map(clusterHealthCheck -> clusterHealthCheck.check(nodeHealths))
      .reduce(Health.GREEN, HealthReducer::merge);
    return new ClusterHealth(health, nodeHealths);
  }
@Test
  public void checkCluster_returns_causes_of_all_ClusterHealthChecks_whichever_their_status() {
    when(nodeInformation.isStandalone()).thenReturn(false);
    List<String[]> causesGroups = IntStream.range(0, 1 + random.nextInt(20))
      .mapToObj(s -> IntStream.range(0, random.nextInt(3)).mapToObj(i -> randomAlphanumeric(3)).toArray(String[]::new))
      .toList();
    ClusterHealthCheck[] clusterHealthChecks = causesGroups.stream()
      .map(HardcodedHealthClusterCheck::new)
      .map(ClusterHealthCheck.class::cast)
      .toArray(ClusterHealthCheck[]::new);
    String[] expectedCauses = causesGroups.stream().flatMap(Arrays::stream).toArray(String[]::new);

    HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], clusterHealthChecks, sharedHealthState);

    assertThat(underTest.checkCluster().getHealth().getCauses()).containsOnly(expectedCauses);
  }