Search in sources :

Example 1 with Status

use of org.springframework.boot.actuate.health.Status in project spring-boot by spring-projects.

the class HealthMvcEndpointTests method customMapping.

@Test
@SuppressWarnings("unchecked")
public void customMapping() {
    given(this.endpoint.invoke()).willReturn(new Health.Builder().status("OK").build());
    this.mvc.setStatusMapping(Collections.singletonMap("OK", HttpStatus.INTERNAL_SERVER_ERROR));
    Object result = this.mvc.invoke(this.request, null);
    assertThat(result instanceof ResponseEntity).isTrue();
    ResponseEntity<Health> response = (ResponseEntity<Health>) result;
    assertThat(response.getBody().getStatus().equals(new Status("OK"))).isTrue();
    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
}
Also used : Status(org.springframework.boot.actuate.health.Status) HttpStatus(org.springframework.http.HttpStatus) ResponseEntity(org.springframework.http.ResponseEntity) Health(org.springframework.boot.actuate.health.Health) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Health (org.springframework.boot.actuate.health.Health)1 Status (org.springframework.boot.actuate.health.Status)1 HttpStatus (org.springframework.http.HttpStatus)1 ResponseEntity (org.springframework.http.ResponseEntity)1