@Override
  public NodeHealth get() {
    NodeHealth.Builder builder = NodeHealth.newNodeHealthBuilder();
    if (clusterAppState.isOperational(ProcessId.ELASTICSEARCH, true)) {
      builder.setStatus(NodeHealth.Status.GREEN);
    } else {
      builder.setStatus(NodeHealth.Status.RED)
        .addCause("Elasticsearch is not operational");
    }
    return builder
      .setDetails(nodeDetails)
      .build();
  }
@Test
  public void get_returns_status_RED_with_cause_if_elasticsearch_process_is_not_operational_in_ClusterAppState() {
    Properties properties = new Properties();
    setRequiredPropertiesAndMocks(properties);
    when(clusterAppState.isOperational(ProcessId.ELASTICSEARCH, true)).thenReturn(false);
    SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock);

    NodeHealth nodeHealth = underTest.get();

    assertThat(nodeHealth.getStatus()).isEqualTo(NodeHealth.Status.RED);
    assertThat(nodeHealth.getCauses()).containsOnly("Elasticsearch is not operational");
  }