use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class ElasticsearchRestHealthIndicatorTests method elasticsearchIsOutOfServiceByStatus.
@Test
void elasticsearchIsOutOfServiceByStatus() throws IOException {
BasicHttpEntity httpEntity = new BasicHttpEntity();
httpEntity.setContent(new ByteArrayInputStream(createJsonResult(200, "red").getBytes()));
Response response = mock(Response.class);
StatusLine statusLine = mock(StatusLine.class);
given(statusLine.getStatusCode()).willReturn(200);
given(response.getStatusLine()).willReturn(statusLine);
given(response.getEntity()).willReturn(httpEntity);
given(this.restClient.performRequest(any(Request.class))).willReturn(response);
Health health = this.elasticsearchRestHealthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.OUT_OF_SERVICE);
assertHealthDetailsWithStatus(health.getDetails(), "red");
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class ElasticsearchRestHealthIndicatorTests method elasticsearchIsDownByResponseCode.
@Test
void elasticsearchIsDownByResponseCode() throws IOException {
Response response = mock(Response.class);
StatusLine statusLine = mock(StatusLine.class);
given(statusLine.getStatusCode()).willReturn(500);
given(statusLine.getReasonPhrase()).willReturn("Internal server error");
given(response.getStatusLine()).willReturn(statusLine);
given(this.restClient.performRequest(any(Request.class))).willReturn(response);
Health health = this.elasticsearchRestHealthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails()).contains(entry("statusCode", 500), entry("reasonPhrase", "Internal server error"));
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneForcedDownNodeShouldReturnDown.
@Test
void healthWithOneForcedDownNodeShouldReturnDown() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.FORCED_DOWN);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneHealthyNodeAndOneUnknownNodeShouldReturnUp.
@Test
void healthWithOneHealthyNodeAndOneUnknownNodeShouldReturnUp() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP, NodeState.UNKNOWN);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class CassandraDriverHealthIndicatorTests method healthWithOneHealthyNodeShouldReturnUp.
@Test
void healthWithOneHealthyNodeShouldReturnUp() {
CqlSession session = mockCqlSessionWithNodeState(NodeState.UP);
CassandraDriverHealthIndicator healthIndicator = new CassandraDriverHealthIndicator(session);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
}
Aggregations