test_class.declarator: client = mock(ElasticsearchClient.class)
test_class.modifier: private final
test_class.original_string: private final ElasticsearchClient client = mock(ElasticsearchClient.class);
test_class.type: ElasticsearchClient
test_class.var_name: client
test_class.declarator: healthCheck
test_class.modifier: private
test_class.original_string: private ElasticsearchClientHealthCheck healthCheck;
test_class.type: ElasticsearchClientHealthCheck
test_class.var_name: healthCheck
test_class.file: harahachibu/src/test/java/uk/co/flax/harahachibu/health/ElasticsearchClientHealthCheckTest.java
test_class.identifier: ElasticsearchClientHealthCheckTest
test_case.body: @Test
  	public void returnsUnhealthyWhenClusterStateUnknown() throws Exception {
  		ElasticsearchClusterStats stats = mock(ElasticsearchClusterStats.class);
  		when(stats.getStatus()).thenReturn("blah");
  		when(client.getClusterStats()).thenReturn(stats);
  
  		HealthCheck.Result result = healthCheck.check();
  		assertThat(result.isHealthy()).isFalse();
  
  		verify(client).getClusterStats();
  	}
test_case.class_method_signature: ElasticsearchClientHealthCheckTest.returnsUnhealthyWhenClusterStateUnknown()
test_case.full_signature: @Test public void returnsUnhealthyWhenClusterStateUnknown()
test_case.identifier: returnsUnhealthyWhenClusterStateUnknown
test_case.invocations: mock thenReturn when getStatus thenReturn when getClusterStats check isFalse assertThat isHealthy getClusterStats verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void returnsUnhealthyWhenClusterStateUnknown()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(ElasticsearchClientHealthCheck.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchClientHealthCheck.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: CLUSTER_HEALTH_MSG = "Cluster status: %s"
focal_class.modifier: private static final
focal_class.original_string: private static final String CLUSTER_HEALTH_MSG = "Cluster status: %s";
focal_class.type: String
focal_class.var_name: CLUSTER_HEALTH_MSG
focal_class.declarator: client
focal_class.modifier: private final
focal_class.original_string: private final ElasticsearchClient client;
focal_class.type: ElasticsearchClient
focal_class.var_name: client
focal_class.file: harahachibu/src/main/java/uk/co/flax/harahachibu/health/ElasticsearchClientHealthCheck.java
focal_class.identifier: ElasticsearchClientHealthCheck
focal_class.class_method_signature: ElasticsearchClientHealthCheck.ElasticsearchClientHealthCheck(ElasticsearchClient client)
focal_class.full_signature: public  ElasticsearchClientHealthCheck(ElasticsearchClient client)
focal_class.identifier: ElasticsearchClientHealthCheck
focal_class.modifiers: public
focal_class.parameters: (ElasticsearchClient client)
focal_class.signature:  ElasticsearchClientHealthCheck(ElasticsearchClient client)
focal_class.class_method_signature: ElasticsearchClientHealthCheck.check()
focal_class.full_signature: @Override protected Result check()
focal_class.identifier: check
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: Result
focal_class.signature: Result check()
focal_class.superclass: extends HealthCheck
focal_method.body: @Override
  	protected Result check() throws Exception {
  		final Result result;
  
  		try {
  			ElasticsearchClusterStats clusterStats = client.getClusterStats();
  			String message = String.format(CLUSTER_HEALTH_MSG, clusterStats.getStatus());
  
  			switch (clusterStats.getStatus()) {
  				case "red":
  					result = Result.unhealthy(message);
  					break;
  				case "yellow":
  				case "green":
  					result = Result.healthy(message);
  					break;
  				default:
  					result = Result.unhealthy("Unrecognized cluster status: " + clusterStats.getStatus());
  			}
  		} catch (DiskSpaceCheckerException e) {
  			LOGGER.error("Exception caught checking ES cluster health: {}", e.getMessage());
  			return Result.unhealthy(e);
  		}
  
  		return result;
  	}
focal_method.class_method_signature: ElasticsearchClientHealthCheck.check()
focal_method.full_signature: @Override protected Result check()
focal_method.identifier: check
focal_method.invocations: getClusterStats format getStatus getStatus unhealthy healthy unhealthy getStatus error getMessage unhealthy
focal_method.modifiers: @Override protected
focal_method.parameters: ()
focal_method.return: Result
focal_method.signature: Result check()