use of org.springframework.boot.actuate.health.HttpCodeStatusMapper in project spring-boot by spring-projects.
the class HealthEndpointAutoConfigurationTests method runWhenHasHttpCodeStatusMapperBeanIgnoresProperties.
@Test
void runWhenHasHttpCodeStatusMapperBeanIgnoresProperties() {
this.contextRunner.withUserConfiguration(HttpCodeStatusMapperConfiguration.class).withPropertyValues("management.health.status.http-mapping.up=123").run((context) -> {
HttpCodeStatusMapper mapper = context.getBean(HttpCodeStatusMapper.class);
assertThat(mapper.getStatusCode(Status.UP)).isEqualTo(456);
});
}
use of org.springframework.boot.actuate.health.HttpCodeStatusMapper in project spring-boot by spring-projects.
the class AutoConfiguredHealthEndpointGroups method createGroups.
private Map<String, HealthEndpointGroup> createGroups(Map<String, Group> groupProperties, BeanFactory beanFactory, StatusAggregator defaultStatusAggregator, HttpCodeStatusMapper defaultHttpCodeStatusMapper, Show defaultShowComponents, Show defaultShowDetails, Set<String> defaultRoles) {
Map<String, HealthEndpointGroup> groups = new LinkedHashMap<>();
groupProperties.forEach((groupName, group) -> {
Status status = group.getStatus();
Show showComponents = (group.getShowComponents() != null) ? group.getShowComponents() : defaultShowComponents;
Show showDetails = (group.getShowDetails() != null) ? group.getShowDetails() : defaultShowDetails;
Set<String> roles = !CollectionUtils.isEmpty(group.getRoles()) ? group.getRoles() : defaultRoles;
StatusAggregator statusAggregator = getQualifiedBean(beanFactory, StatusAggregator.class, groupName, () -> {
if (!CollectionUtils.isEmpty(status.getOrder())) {
return new SimpleStatusAggregator(status.getOrder());
}
return defaultStatusAggregator;
});
HttpCodeStatusMapper httpCodeStatusMapper = getQualifiedBean(beanFactory, HttpCodeStatusMapper.class, groupName, () -> {
if (!CollectionUtils.isEmpty(status.getHttpMapping())) {
return new SimpleHttpCodeStatusMapper(status.getHttpMapping());
}
return defaultHttpCodeStatusMapper;
});
Predicate<String> members = new IncludeExcludeGroupMemberPredicate(group.getInclude(), group.getExclude());
AdditionalHealthEndpointPath additionalPath = (group.getAdditionalPath() != null) ? AdditionalHealthEndpointPath.from(group.getAdditionalPath()) : null;
groups.put(groupName, new AutoConfiguredHealthEndpointGroup(members, statusAggregator, httpCodeStatusMapper, showComponents, showDetails, roles, additionalPath));
});
return Collections.unmodifiableMap(groups);
}
use of org.springframework.boot.actuate.health.HttpCodeStatusMapper in project spring-boot by spring-projects.
the class HealthEndpointAutoConfigurationTests method runCreatesHttpCodeStatusMapperFromProperties.
@Test
void runCreatesHttpCodeStatusMapperFromProperties() {
this.contextRunner.withPropertyValues("management.endpoint.health.status.http-mapping.up=123").run((context) -> {
HttpCodeStatusMapper mapper = context.getBean(HttpCodeStatusMapper.class);
assertThat(mapper.getStatusCode(Status.UP)).isEqualTo(123);
});
}
Aggregations