Search in sources :

Example 16 with HealthEndpointGroups

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

the class HealthEndpointAutoConfigurationTests method runWhenHasHealthEndpointGroupsPostProcessorPerformsProcessing.

@Test
void runWhenHasHealthEndpointGroupsPostProcessorPerformsProcessing() {
    this.contextRunner.withPropertyValues("management.endpoint.health.group.ready.include=*").withUserConfiguration(HealthEndpointGroupsConfiguration.class, TestHealthEndpointGroupsPostProcessor.class).run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> groups.get("test")).withMessage("postprocessed");
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) Test(org.junit.jupiter.api.Test)

Example 17 with HealthEndpointGroups

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

the class HealthEndpointAutoConfigurationTests method runWhenHasHealthEndpointGroupsBeanDoesNotCreateAdditionalHealthEndpointGroups.

@Test
void runWhenHasHealthEndpointGroupsBeanDoesNotCreateAdditionalHealthEndpointGroups() {
    this.contextRunner.withUserConfiguration(HealthEndpointGroupsConfiguration.class).withPropertyValues("management.endpoint.health.group.ready.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        assertThat(groups.getNames()).containsOnly("mock");
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) Test(org.junit.jupiter.api.Test)

Example 18 with HealthEndpointGroups

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

the class AvailabilityProbesHealthEndpointGroupsPostProcessorTests method postProcessHealthEndpointGroupsWhenGroupContainsOneReturnsPostProcessed.

@Test
void postProcessHealthEndpointGroupsWhenGroupContainsOneReturnsPostProcessed() {
    HealthEndpointGroups groups = mock(HealthEndpointGroups.class);
    Set<String> names = new LinkedHashSet<>();
    names.add("test");
    names.add("readiness");
    given(groups.getNames()).willReturn(names);
    assertThat(this.postProcessor.postProcessHealthEndpointGroups(groups)).isInstanceOf(AvailabilityProbesHealthEndpointGroups.class);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) Test(org.junit.jupiter.api.Test)

Example 19 with HealthEndpointGroups

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

the class AvailabilityProbesHealthEndpointGroupsPostProcessorTests method postProcessHealthEndpointGroupsWhenGroupsContainsNoneReturnsProcessed.

@Test
void postProcessHealthEndpointGroupsWhenGroupsContainsNoneReturnsProcessed() {
    HealthEndpointGroups groups = mock(HealthEndpointGroups.class);
    Set<String> names = new LinkedHashSet<>();
    names.add("test");
    names.add("spring");
    names.add("boot");
    given(groups.getNames()).willReturn(names);
    assertThat(this.postProcessor.postProcessHealthEndpointGroups(groups)).isInstanceOf(AvailabilityProbesHealthEndpointGroups.class);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) Test(org.junit.jupiter.api.Test)

Example 20 with HealthEndpointGroups

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

the class AvailabilityProbesHealthEndpointGroupsPostProcessorTests method getPostProcessed.

private HealthEndpointGroups getPostProcessed(String value) {
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty("management.endpoint.health.probes.add-additional-paths", value);
    AvailabilityProbesHealthEndpointGroupsPostProcessor postProcessor = new AvailabilityProbesHealthEndpointGroupsPostProcessor(environment);
    HealthEndpointGroups groups = mock(HealthEndpointGroups.class);
    return postProcessor.postProcessHealthEndpointGroups(groups);
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) MockEnvironment(org.springframework.mock.env.MockEnvironment)

Aggregations

HealthEndpointGroups (org.springframework.boot.actuate.health.HealthEndpointGroups)35 Test (org.junit.jupiter.api.Test)34 HealthEndpointGroup (org.springframework.boot.actuate.health.HealthEndpointGroup)22 LinkedHashSet (java.util.LinkedHashSet)3 MockEnvironment (org.springframework.mock.env.MockEnvironment)1