Add nullability annotations to tests in module/spring-boot-actuator-autoconfigure
See gh-47263
This commit is contained in:
parent
3c3726b89e
commit
4af0d6d747
|
@ -47,5 +47,11 @@ dependencies {
|
|||
testImplementation(testFixtures(project(":module:spring-boot-web-server")))
|
||||
testImplementation("org.springframework:spring-webflux")
|
||||
|
||||
testCompileOnly("com.google.code.findbugs:jsr305")
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
|
|
@ -84,7 +84,9 @@ class AvailabilityProbesHealthEndpointGroupsPostProcessorTests {
|
|||
void postProcessHealthEndpointGroupsWhenAdditionalPathPropertyIsTrue() {
|
||||
HealthEndpointGroups postProcessed = getPostProcessed("true");
|
||||
HealthEndpointGroup liveness = postProcessed.get("liveness");
|
||||
assertThat(liveness).isNotNull();
|
||||
HealthEndpointGroup readiness = postProcessed.get("readiness");
|
||||
assertThat(readiness).isNotNull();
|
||||
assertThat(liveness.getAdditionalPath()).hasToString("server:/livez");
|
||||
assertThat(readiness.getAdditionalPath()).hasToString("server:/readyz");
|
||||
}
|
||||
|
@ -103,7 +105,9 @@ class AvailabilityProbesHealthEndpointGroupsPostProcessorTests {
|
|||
environment);
|
||||
HealthEndpointGroups postProcessed = postProcessor.postProcessHealthEndpointGroups(groups);
|
||||
HealthEndpointGroup liveness = postProcessed.get("liveness");
|
||||
assertThat(liveness).isNotNull();
|
||||
HealthEndpointGroup readiness = postProcessed.get("readiness");
|
||||
assertThat(readiness).isNotNull();
|
||||
assertThat(liveness.getAdditionalPath()).hasToString("server:/livez");
|
||||
assertThat(readiness.getAdditionalPath()).hasToString("server:/readyz");
|
||||
}
|
||||
|
@ -154,7 +158,9 @@ class AvailabilityProbesHealthEndpointGroupsPostProcessorTests {
|
|||
void postProcessHealthEndpointGroupsWhenAdditionalPathPropertyIsFalse() {
|
||||
HealthEndpointGroups postProcessed = getPostProcessed("false");
|
||||
HealthEndpointGroup liveness = postProcessed.get("liveness");
|
||||
assertThat(liveness).isNotNull();
|
||||
HealthEndpointGroup readiness = postProcessed.get("readiness");
|
||||
assertThat(readiness).isNotNull();
|
||||
assertThat(liveness.getAdditionalPath()).isNull();
|
||||
assertThat(readiness.getAdditionalPath()).isNull();
|
||||
}
|
||||
|
@ -164,7 +170,9 @@ class AvailabilityProbesHealthEndpointGroupsPostProcessorTests {
|
|||
HealthEndpointGroups groups = mock(HealthEndpointGroups.class);
|
||||
HealthEndpointGroups postProcessed = this.postProcessor.postProcessHealthEndpointGroups(groups);
|
||||
HealthEndpointGroup liveness = postProcessed.get("liveness");
|
||||
assertThat(liveness).isNotNull();
|
||||
HealthEndpointGroup readiness = postProcessed.get("readiness");
|
||||
assertThat(readiness).isNotNull();
|
||||
assertThat(liveness.getAdditionalPath()).isNull();
|
||||
assertThat(readiness.getAdditionalPath()).isNull();
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ class AvailabilityProbesHealthEndpointGroupsTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("NullAway") // Test null check
|
||||
void createWhenGroupsIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new AvailabilityProbesHealthEndpointGroups(null, false))
|
||||
.withMessage("'groups' must not be null");
|
||||
|
@ -87,15 +88,22 @@ class AvailabilityProbesHealthEndpointGroupsTests {
|
|||
given(this.delegate.get("liveness")).willReturn(group);
|
||||
HealthEndpointGroups availabilityProbes = new AvailabilityProbesHealthEndpointGroups(this.delegate, true);
|
||||
HealthEndpointGroup liveness = availabilityProbes.get("liveness");
|
||||
assertThat(liveness).isNotNull();
|
||||
assertThat(liveness).isEqualTo(group);
|
||||
assertThat(liveness.getAdditionalPath().getValue()).isEqualTo("test");
|
||||
AdditionalHealthEndpointPath additionalPath = liveness.getAdditionalPath();
|
||||
assertThat(additionalPath).isNotNull();
|
||||
assertThat(additionalPath.getValue()).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWhenProbeInDelegateAndAdditionalPathReturnsGroupWithAdditionalPath() {
|
||||
given(this.delegate.get("liveness")).willReturn(this.group);
|
||||
HealthEndpointGroups availabilityProbes = new AvailabilityProbesHealthEndpointGroups(this.delegate, true);
|
||||
assertThat(availabilityProbes.get("liveness").getAdditionalPath().getValue()).isEqualTo("/livez");
|
||||
HealthEndpointGroup liveness = availabilityProbes.get("liveness");
|
||||
assertThat(liveness).isNotNull();
|
||||
AdditionalHealthEndpointPath additionalPath = liveness.getAdditionalPath();
|
||||
assertThat(additionalPath).isNotNull();
|
||||
assertThat(additionalPath.getValue()).isEqualTo("/livez");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -114,6 +122,7 @@ class AvailabilityProbesHealthEndpointGroupsTests {
|
|||
void getLivenessProbeHasOnlyLivenessStateAsMember() {
|
||||
HealthEndpointGroups availabilityProbes = new AvailabilityProbesHealthEndpointGroups(this.delegate, false);
|
||||
HealthEndpointGroup probeGroup = availabilityProbes.get("liveness");
|
||||
assertThat(probeGroup).isNotNull();
|
||||
assertThat(probeGroup.isMember("livenessState")).isTrue();
|
||||
assertThat(probeGroup.isMember("readinessState")).isFalse();
|
||||
}
|
||||
|
@ -122,6 +131,7 @@ class AvailabilityProbesHealthEndpointGroupsTests {
|
|||
void getReadinessProbeHasOnlyReadinessStateAsMember() {
|
||||
HealthEndpointGroups availabilityProbes = new AvailabilityProbesHealthEndpointGroups(this.delegate, false);
|
||||
HealthEndpointGroup probeGroup = availabilityProbes.get("readiness");
|
||||
assertThat(probeGroup).isNotNull();
|
||||
assertThat(probeGroup.isMember("livenessState")).isFalse();
|
||||
assertThat(probeGroup.isMember("readinessState")).isTrue();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.availability;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.SecurityContext;
|
||||
import org.springframework.boot.actuate.health.AdditionalHealthEndpointPath;
|
||||
import org.springframework.boot.actuate.health.HealthEndpointGroup;
|
||||
import org.springframework.boot.actuate.health.HttpCodeStatusMapper;
|
||||
|
@ -61,8 +62,8 @@ class DelegatingAvailabilityProbesHealthEndpointGroupTests {
|
|||
assertThat(this.group.getHttpCodeStatusMapper()).isEqualTo(this.mapper);
|
||||
assertThat(this.group.getStatusAggregator()).isEqualTo(this.aggregator);
|
||||
assertThat(this.group.isMember("test")).isTrue();
|
||||
assertThat(this.group.showDetails(null)).isFalse();
|
||||
assertThat(this.group.showComponents(null)).isTrue();
|
||||
assertThat(this.group.showDetails(SecurityContext.NONE)).isFalse();
|
||||
assertThat(this.group.showComponents(SecurityContext.NONE)).isTrue();
|
||||
assertThat(this.group.getAdditionalPath().getValue()).isEqualTo("test");
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ class ConditionsReportEndpointTests {
|
|||
.conditions()
|
||||
.getContexts()
|
||||
.get(context.getId());
|
||||
assertThat(report).isNotNull();
|
||||
assertThat(report.getPositiveMatches()).isEmpty();
|
||||
assertThat(report.getNegativeMatches()).containsKey("a");
|
||||
assertThat(report.getUnconditionalClasses()).contains("b");
|
||||
|
|
|
@ -19,10 +19,13 @@ package org.springframework.boot.actuate.autoconfigure.context.properties;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint;
|
||||
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesBeanDescriptor;
|
||||
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ConfigurationPropertiesDescriptor;
|
||||
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpoint.ContextConfigurationPropertiesDescriptor;
|
||||
import org.springframework.boot.actuate.context.properties.ConfigurationPropertiesReportEndpointWebExtension;
|
||||
import org.springframework.boot.actuate.endpoint.SanitizingFunction;
|
||||
import org.springframework.boot.actuate.endpoint.Show;
|
||||
|
@ -117,11 +120,11 @@ class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
|
|||
ConfigurationPropertiesReportEndpoint endpoint = context
|
||||
.getBean(ConfigurationPropertiesReportEndpoint.class);
|
||||
ConfigurationPropertiesDescriptor properties = endpoint.configurationProperties();
|
||||
Map<String, Object> nestedProperties = properties.getContexts()
|
||||
.get(context.getId())
|
||||
.getBeans()
|
||||
.get("testProperties")
|
||||
.getProperties();
|
||||
ContextConfigurationPropertiesDescriptor contextDescriptor = properties.getContexts().get(context.getId());
|
||||
assertThat(contextDescriptor).isNotNull();
|
||||
ConfigurationPropertiesBeanDescriptor testProperties = contextDescriptor.getBeans().get("testProperties");
|
||||
assertThat(testProperties).isNotNull();
|
||||
Map<String, @Nullable Object> nestedProperties = testProperties.getProperties();
|
||||
assertThat(nestedProperties).isNotNull();
|
||||
assertThat(nestedProperties).containsEntry("dbPassword", dbPassword);
|
||||
assertThat(nestedProperties).containsEntry("myTestProperty", myTestProperty);
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.lang.annotation.Annotation;
|
|||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.annotation.EndpointConverter;
|
||||
|
@ -103,6 +104,7 @@ class EndpointAutoConfigurationTests {
|
|||
@Override
|
||||
public Person convert(String source) {
|
||||
String[] content = StringUtils.split(source, " ");
|
||||
assertThat(content).isNotNull();
|
||||
return new Person(content[0], content[1]);
|
||||
}
|
||||
|
||||
|
@ -116,8 +118,9 @@ class EndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
String[] content = StringUtils.split((String) source, " ");
|
||||
assertThat(content).isNotNull();
|
||||
return new Person(content[0], content[1]);
|
||||
}
|
||||
|
||||
|
@ -202,7 +205,7 @@ class EndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T extends Annotation> T getAnnotation(Class<T> annotation) {
|
||||
public <T extends Annotation> @Nullable T getAnnotation(Class<T> annotation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.endpoint;
|
|||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||
|
@ -35,7 +36,8 @@ class EndpointIdTimeToLivePropertyFunctionTests {
|
|||
|
||||
private final MockEnvironment environment = new MockEnvironment();
|
||||
|
||||
private final Function<EndpointId, Long> timeToLive = new EndpointIdTimeToLivePropertyFunction(this.environment);
|
||||
private final Function<EndpointId, @Nullable Long> timeToLive = new EndpointIdTimeToLivePropertyFunction(
|
||||
this.environment);
|
||||
|
||||
@Test
|
||||
void defaultConfiguration() {
|
||||
|
|
|
@ -223,7 +223,11 @@ class ConditionalOnAvailableEndpointTests {
|
|||
.withPropertyValues("management.endpoints.web.exposure.include=*")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure().getCause().getMessage())
|
||||
Throwable startupFailure = context.getStartupFailure();
|
||||
assertThat(startupFailure).isNotNull();
|
||||
Throwable cause = startupFailure.getCause();
|
||||
assertThat(cause).isNotNull();
|
||||
assertThat(cause.getMessage())
|
||||
.contains("No endpoint is specified and the return type of the @Bean method "
|
||||
+ "is neither an @Endpoint, nor an @EndpointExtension");
|
||||
});
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.springframework.boot.actuate.autoconfigure.endpoint.expose;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
@ -39,9 +40,10 @@ import static org.mockito.Mockito.mock;
|
|||
@ExtendWith(MockitoExtension.class)
|
||||
class IncludeExcludeEndpointFilterTests {
|
||||
|
||||
private IncludeExcludeEndpointFilter<?> filter;
|
||||
private @Nullable IncludeExcludeEndpointFilter<?> filter;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("NullAway") // Test null check
|
||||
void createWhenEndpointTypeIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new IncludeExcludeEndpointFilter<>(null, new MockEnvironment(), "foo"))
|
||||
|
@ -49,6 +51,7 @@ class IncludeExcludeEndpointFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("NullAway") // Test null check
|
||||
void createWhenEnvironmentIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new IncludeExcludeEndpointFilter<>(ExposableEndpoint.class, null, "foo"))
|
||||
|
@ -56,6 +59,7 @@ class IncludeExcludeEndpointFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("NullAway") // Test null check
|
||||
void createWhenPrefixIsNullShouldThrowException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new IncludeExcludeEndpointFilter<>(ExposableEndpoint.class, new MockEnvironment(), null))
|
||||
|
@ -160,12 +164,14 @@ class IncludeExcludeEndpointFilterTests {
|
|||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private boolean match(EndpointId id) {
|
||||
private boolean match(@Nullable EndpointId id) {
|
||||
ExposableEndpoint<?> endpoint = mock(TestExposableWebEndpoint.class);
|
||||
if (id != null) {
|
||||
given(endpoint.getEndpointId()).willReturn(id);
|
||||
}
|
||||
return ((EndpointFilter) this.filter).match(endpoint);
|
||||
EndpointFilter filter = this.filter;
|
||||
assertThat(filter).isNotNull();
|
||||
return filter.match(endpoint);
|
||||
}
|
||||
|
||||
abstract static class TestExposableWebEndpoint implements ExposableWebEndpoint {
|
||||
|
|
|
@ -105,7 +105,7 @@ class JacksonEndpointAutoConfigurationTests {
|
|||
|
||||
@Override
|
||||
public JsonMapper get() {
|
||||
return null;
|
||||
return new JsonMapper();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.management.MBeanServer;
|
|||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||
|
@ -46,7 +47,7 @@ class DefaultEndpointObjectNameFactoryTests {
|
|||
|
||||
private final MBeanServer mBeanServer = mock(MBeanServer.class);
|
||||
|
||||
private String contextId;
|
||||
private @Nullable String contextId;
|
||||
|
||||
@Test
|
||||
void generateObjectName() {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
|
||||
|
@ -128,7 +129,7 @@ class WebEndpointAutoConfigurationTests {
|
|||
static class TestPathMatcher implements PathMapper {
|
||||
|
||||
@Override
|
||||
public String getRootPath(EndpointId endpointId) {
|
||||
public @Nullable String getRootPath(EndpointId endpointId) {
|
||||
if (endpointId.toString().endsWith("one")) {
|
||||
return "1/" + endpointId;
|
||||
}
|
||||
|
|
|
@ -79,8 +79,12 @@ class EnvironmentEndpointAutoConfigurationTests {
|
|||
EnvironmentDescriptor env = endpoint.environment(null);
|
||||
Map<String, PropertyValueDescriptor> systemProperties = getSource("systemProperties", env)
|
||||
.getProperties();
|
||||
assertThat(systemProperties.get("custom").getValue()).isEqualTo("$$$111$$$");
|
||||
assertThat(systemProperties.get("password").getValue()).isEqualTo("$$$222$$$");
|
||||
PropertyValueDescriptor custom = systemProperties.get("custom");
|
||||
assertThat(custom).isNotNull();
|
||||
assertThat(custom.getValue()).isEqualTo("$$$111$$$");
|
||||
PropertyValueDescriptor password = systemProperties.get("password");
|
||||
assertThat(password).isNotNull();
|
||||
assertThat(password.getValue()).isEqualTo("$$$222$$$");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -122,14 +126,19 @@ class EnvironmentEndpointAutoConfigurationTests {
|
|||
.doesNotHaveBean(EnvironmentEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> validateSystemProperties(String dbPassword, String apiKey) {
|
||||
private ContextConsumer<AssertableApplicationContext> validateSystemProperties(String expectedPassword,
|
||||
String expectedApiKey) {
|
||||
return (context) -> {
|
||||
assertThat(context).hasSingleBean(EnvironmentEndpoint.class);
|
||||
EnvironmentEndpoint endpoint = context.getBean(EnvironmentEndpoint.class);
|
||||
EnvironmentDescriptor env = endpoint.environment(null);
|
||||
Map<String, PropertyValueDescriptor> systemProperties = getSource("systemProperties", env).getProperties();
|
||||
assertThat(systemProperties.get("dbPassword").getValue()).isEqualTo(dbPassword);
|
||||
assertThat(systemProperties.get("apiKey").getValue()).isEqualTo(apiKey);
|
||||
PropertyValueDescriptor dbPassword = systemProperties.get("dbPassword");
|
||||
assertThat(dbPassword).isNotNull();
|
||||
assertThat(dbPassword.getValue()).isEqualTo(expectedPassword);
|
||||
PropertyValueDescriptor apiKey = systemProperties.get("apiKey");
|
||||
assertThat(apiKey).isNotNull();
|
||||
assertThat(apiKey.getValue()).isEqualTo(expectedApiKey);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -45,15 +45,19 @@ import static org.mockito.Mockito.mock;
|
|||
class AutoConfiguredHealthEndpointGroupTests {
|
||||
|
||||
@Mock
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
private StatusAggregator statusAggregator;
|
||||
|
||||
@Mock
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
private HttpCodeStatusMapper httpCodeStatusMapper;
|
||||
|
||||
@Mock
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
private SecurityContext securityContext;
|
||||
|
||||
@Mock
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
private Principal principal;
|
||||
|
||||
@Test
|
||||
|
|
|
@ -122,6 +122,7 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupA = groups.get("a");
|
||||
assertThat(primary.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UNKNOWN);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UNKNOWN);
|
||||
});
|
||||
|
@ -140,8 +141,10 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupB = groups.get("b");
|
||||
assertThat(primary.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UNKNOWN);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UP);
|
||||
assertThat(groupB).isNotNull();
|
||||
assertThat(groupB.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UNKNOWN);
|
||||
});
|
||||
|
@ -158,6 +161,7 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupA = groups.get("a");
|
||||
assertThat(primary.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN))
|
||||
.isEqualTo(Status.UP);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN))
|
||||
.isEqualTo(Status.UP);
|
||||
});
|
||||
|
@ -177,8 +181,10 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupB = groups.get("b");
|
||||
assertThat(primary.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UP);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UNKNOWN);
|
||||
assertThat(groupB).isNotNull();
|
||||
assertThat(groupB.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UP);
|
||||
});
|
||||
|
@ -198,8 +204,10 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupB = groups.get("b");
|
||||
assertThat(primary.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UP);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UNKNOWN);
|
||||
assertThat(groupB).isNotNull();
|
||||
assertThat(groupB.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UP);
|
||||
});
|
||||
|
@ -219,8 +227,10 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupB = groups.get("b");
|
||||
assertThat(primary.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.DOWN);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UNKNOWN);
|
||||
assertThat(groupB).isNotNull();
|
||||
assertThat(groupB.getStatusAggregator().getAggregateStatus(Status.UP, Status.DOWN, Status.UNKNOWN))
|
||||
.isEqualTo(Status.UP);
|
||||
});
|
||||
|
@ -236,6 +246,7 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup primary = groups.getPrimary();
|
||||
HealthEndpointGroup groupA = groups.get("a");
|
||||
assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
|
||||
});
|
||||
}
|
||||
|
@ -252,7 +263,9 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupA = groups.get("a");
|
||||
HealthEndpointGroup groupB = groups.get("b");
|
||||
assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
|
||||
assertThat(groupB).isNotNull();
|
||||
assertThat(groupB.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
|
||||
});
|
||||
}
|
||||
|
@ -267,6 +280,7 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup primary = groups.getPrimary();
|
||||
HealthEndpointGroup groupA = groups.get("a");
|
||||
assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
|
||||
});
|
||||
}
|
||||
|
@ -284,7 +298,9 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupA = groups.get("a");
|
||||
HealthEndpointGroup groupB = groups.get("b");
|
||||
assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(202);
|
||||
assertThat(groupB).isNotNull();
|
||||
assertThat(groupB.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
|
||||
});
|
||||
}
|
||||
|
@ -302,7 +318,9 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupA = groups.get("a");
|
||||
HealthEndpointGroup groupB = groups.get("b");
|
||||
assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
|
||||
assertThat(groupB).isNotNull();
|
||||
assertThat(groupB.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
|
||||
});
|
||||
}
|
||||
|
@ -320,7 +338,9 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
HealthEndpointGroup groupA = groups.get("a");
|
||||
HealthEndpointGroup groupB = groups.get("b");
|
||||
assertThat(primary.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(503);
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(200);
|
||||
assertThat(groupB).isNotNull();
|
||||
assertThat(groupB.getHttpCodeStatusMapper().getStatusCode(Status.DOWN)).isEqualTo(201);
|
||||
});
|
||||
}
|
||||
|
@ -333,6 +353,7 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
.run((context) -> {
|
||||
HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
|
||||
HealthEndpointGroup groupA = groups.get("a");
|
||||
assertThat(groupA).isNotNull();
|
||||
assertThat(groupA.showDetails(SecurityContext.NONE)).isTrue();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -223,6 +223,7 @@ class HealthEndpointAutoConfigurationTests {
|
|||
this.contextRunner.withPropertyValues("management.endpoint.health.show-details=always").run((context) -> {
|
||||
HealthEndpoint endpoint = context.getBean(HealthEndpoint.class);
|
||||
IndicatedHealthDescriptor descriptor = (IndicatedHealthDescriptor) endpoint.healthForPath("simple");
|
||||
assertThat(descriptor).isNotNull();
|
||||
assertThat(descriptor.getDetails()).containsEntry("counter", 42);
|
||||
});
|
||||
}
|
||||
|
@ -263,6 +264,7 @@ class HealthEndpointAutoConfigurationTests {
|
|||
WebServerNamespace.SERVER, SecurityContext.NONE, true, "simple");
|
||||
IndicatedHealthDescriptor descriptor = (IndicatedHealthDescriptor) response.getBody();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(descriptor).isNotNull();
|
||||
assertThat(descriptor.getDetails()).containsEntry("counter", 42);
|
||||
});
|
||||
}
|
||||
|
@ -281,9 +283,12 @@ class HealthEndpointAutoConfigurationTests {
|
|||
void runCreatesReactiveHealthEndpointWebExtension() {
|
||||
this.reactiveContextRunner.run((context) -> {
|
||||
ReactiveHealthEndpointWebExtension webExtension = context.getBean(ReactiveHealthEndpointWebExtension.class);
|
||||
Mono<WebEndpointResponse<? extends HealthDescriptor>> response = webExtension.health(ApiVersion.V3,
|
||||
Mono<WebEndpointResponse<? extends HealthDescriptor>> responseMono = webExtension.health(ApiVersion.V3,
|
||||
WebServerNamespace.SERVER, SecurityContext.NONE, true, "simple");
|
||||
IndicatedHealthDescriptor descriptor = (IndicatedHealthDescriptor) (response.block().getBody());
|
||||
WebEndpointResponse<? extends HealthDescriptor> response = responseMono.block();
|
||||
assertThat(response).isNotNull();
|
||||
IndicatedHealthDescriptor descriptor = (IndicatedHealthDescriptor) (response.getBody());
|
||||
assertThat(descriptor).isNotNull();
|
||||
assertThat(descriptor.getDetails()).containsEntry("counter", 42);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.LinkedHashSet;
|
|||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -134,7 +135,7 @@ class IncludeExcludeGroupMemberPredicateTests {
|
|||
return new IncludeExcludeGroupMemberPredicate(asSet(this.include), asSet(exclude));
|
||||
}
|
||||
|
||||
private Set<String> asSet(String[] names) {
|
||||
private @Nullable Set<String> asSet(String @Nullable [] names) {
|
||||
return (names != null) ? new LinkedHashSet<>(Arrays.asList(names)) : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,10 @@ class SslHealthContributorAutoConfigurationTests {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<CertificateChainInfo> getInvalidChains(Health health) {
|
||||
return (List<CertificateChainInfo>) health.getDetails().get("invalidChains");
|
||||
List<CertificateChainInfo> invalidChains = (List<CertificateChainInfo>) health.getDetails()
|
||||
.get("invalidChains");
|
||||
assertThat(invalidChains).isNotNull();
|
||||
return invalidChains;
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
|
Loading…
Reference in New Issue