Example usage for org.springframework.boot.actuate.health Health getStatus

List of usage examples for org.springframework.boot.actuate.health Health getStatus

Introduction

In this page you can find the example usage for org.springframework.boot.actuate.health Health getStatus.

Prototype

@JsonUnwrapped
public Status getStatus() 

Source Link

Document

Return the status of the health.

Usage

From source file:io.pivotal.strepsirrhini.chaosloris.CloudFoundryClientHealthIndicatorTest.java

@Test
public void healthy() throws Exception {
    when(this.cloudFoundryClient.info().get(GetInfoRequest.builder().build()))
            .thenReturn(Mono.just(GetInfoResponse.builder().apiVersion("2.62.0").build()));

    Health.Builder builder = new Health.Builder();

    this.healthIndicator.doHealthCheck(builder);

    Health health = builder.build();
    assertThat(health.getStatus()).isEqualTo(Status.UP);
    assertThat(health.getDetails()).containsEntry("apiVersion", "2.62.0");
}

From source file:io.jmnarloch.spring.cloud.zuul.ZuulRouteHealthIndicatorTest.java

@Test
public void shouldReportUpStateForNoRoutes() {

    // given/* w  w w  .  jav a 2s  . c om*/
    when(discoveryClient.getInstances(Mockito.any(String.class))).thenReturn(new ArrayList<ServiceInstance>());

    // when
    final Health health = zuulRouteHealthIndicator.health();

    // then
    assertNotNull(health);
    assertEquals(Status.UP, health.getStatus());
}

From source file:io.jmnarloch.spring.cloud.zuul.ZuulRouteHealthIndicatorTest.java

@Test
public void shouldReportDownState() {

    // given/*from w  w  w  . j  a  va  2  s.c  om*/
    final ZuulProperties.ZuulRoute route = new ZuulProperties.ZuulRoute("/zuul", "proxied-service");
    zuulProperties.getRoutes().put(route.getId(), route);

    // when
    final Health health = zuulRouteHealthIndicator.health();

    // then
    assertNotNull(health);
    assertEquals(Status.DOWN, health.getStatus());
    assertNull(health.getDetails().get("available"));
    assertFalse(((Collection) health.getDetails().get("unavailable")).isEmpty());
}

From source file:io.jmnarloch.spring.cloud.zuul.ZuulRouteHealthIndicatorTest.java

@Test
public void shouldReportUpState() {

    // given/*from   w  w  w .j av  a  2s.com*/
    final ZuulProperties.ZuulRoute route = new ZuulProperties.ZuulRoute("/zuul", "proxied-service");
    zuulProperties.getRoutes().put(route.getId(), route);

    final List<ServiceInstance> services = new ArrayList<>();
    services.add(mock(ServiceInstance.class));
    when(discoveryClient.getInstances("proxied-service")).thenReturn(services);

    // when
    final Health health = zuulRouteHealthIndicator.health();

    // then
    assertNotNull(health);
    assertEquals(Status.UP, health.getStatus());
    assertFalse(((Collection) health.getDetails().get("available")).isEmpty());
    assertNull(health.getDetails().get("unavailable"));
}