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

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

Introduction

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

Prototype

public Map<String, Object> getDetails() 

Source Link

Document

Return the details 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 shouldReportDownState() {

    // given/*from  w ww.j av a2 s.c o m*/
    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/*  w w  w . ja v  a2  s. c  o m*/
    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"));
}