Search in sources :

Example 11 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasHttpCodeStatusMapperPropertyAndGroupSpecificPropertyReturnsInstanceWithPropertyUsedForExpectedGroups.

@Test
void createWhenHasHttpCodeStatusMapperPropertyAndGroupSpecificPropertyReturnsInstanceWithPropertyUsedForExpectedGroups() {
    this.contextRunner.withPropertyValues("management.endpoint.health.status.http-mapping.down=201", "management.endpoint.health.group.a.include=*", "management.endpoint.health.group.a.status.http-mapping.down=202", "management.endpoint.health.group.b.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup primary = groups.getPrimary();
        HealthEndpointGroup groupA = groups.get("a");
        HealthEndpointGroup groupB = groups.get("b");
        assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
        assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(202);
        assertThat(groupB.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 12 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenGroupWithNoShowDetailsOverrideInheritsShowDetails.

@Test
void createWhenGroupWithNoShowDetailsOverrideInheritsShowDetails() {
    this.contextRunner.withPropertyValues("management.endpoint.health.show-details=always", "management.endpoint.health.group.a.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup groupA = groups.get("a");
        assertThat(groupA.showDetails(SecurityContext.NONE)).isTrue();
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 13 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasGroupSpecificHttpCodeStatusMapperPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups.

@Test
void createWhenHasGroupSpecificHttpCodeStatusMapperPropertyAndGroupQualifiedBeanReturnsInstanceWithBeanUsedForExpectedGroups() {
    this.contextRunner.withUserConfiguration(CustomHttpCodeStatusMapperGroupAConfiguration.class).withPropertyValues("management.endpoint.health.group.a.include=*", "management.endpoint.health.group.a.status.http-mapping.down=201", "management.endpoint.health.group.b.include=*", "management.endpoint.health.group.b.status.http-mapping.down=201").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup primary = groups.getPrimary();
        HealthEndpointGroup groupA = groups.get("a");
        HealthEndpointGroup groupB = groups.get("b");
        assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(503);
        assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
        assertThat(groupB.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 14 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasHttpCodeStatusMapperBeanAndGroupSpecificPropertyReturnsInstanceThatUsesBeanOnlyForUnconfiguredGroups.

@Test
void createWhenHasHttpCodeStatusMapperBeanAndGroupSpecificPropertyReturnsInstanceThatUsesBeanOnlyForUnconfiguredGroups() {
    this.contextRunner.withUserConfiguration(CustomHttpCodeStatusMapperConfiguration.class).withPropertyValues("management.endpoint.health.group.a.include=*", "management.endpoint.health.group.a.status.http-mapping.down=201", "management.endpoint.health.group.b.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup primary = groups.getPrimary();
        HealthEndpointGroup groupA = groups.get("a");
        HealthEndpointGroup groupB = groups.get("b");
        assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
        assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
        assertThat(groupB.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

Example 15 with HealthEndpointGroups

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

the class AutoConfiguredHealthEndpointGroupsTests method createWhenHasHttpCodeStatusMapperBeanReturnsInstanceWithMapperUsedForAllGroups.

@Test
void createWhenHasHttpCodeStatusMapperBeanReturnsInstanceWithMapperUsedForAllGroups() {
    this.contextRunner.withUserConfiguration(CustomHttpCodeStatusMapperConfiguration.class).withPropertyValues("management.endpoint.health.status.http-mapping.down=201", "management.endpoint.health.group.a.include=*").run((context) -> {
        HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
        HealthEndpointGroup primary = groups.getPrimary();
        HealthEndpointGroup groupA = groups.get("a");
        assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
        assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
    });
}
Also used : HealthEndpointGroups(org.springframework.boot.actuate.health.HealthEndpointGroups) HealthEndpointGroup(org.springframework.boot.actuate.health.HealthEndpointGroup) Test(org.junit.jupiter.api.Test)

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