mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-08 18:41:37 +00:00
Add nullability annotations to tests in module/spring-boot-micrometer-observation
See gh-47263
This commit is contained in:
@@ -36,3 +36,7 @@ dependencies {
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+6
-2
@@ -115,7 +115,9 @@ class ObservationAutoConfigurationTests {
|
||||
Observation observation = Observation.start("filtered", observationRegistry);
|
||||
observation.stop();
|
||||
observation.getContext().getLowCardinalityKeyValues().forEach((kv) -> System.out.println(kv.getKey()));
|
||||
assertThat(observation.getContext().getLowCardinalityKeyValue("filter").getValue()).isEqualTo("one");
|
||||
KeyValue filter = observation.getContext().getLowCardinalityKeyValue("filter");
|
||||
assertThat(filter).isNotNull();
|
||||
assertThat(filter.getValue()).isEqualTo("one");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,7 +133,9 @@ class ObservationAutoConfigurationTests {
|
||||
ObservationRegistry observationRegistry = context.getBean(ObservationRegistry.class);
|
||||
Observation observation = Observation.start("keyvalues", observationRegistry);
|
||||
observation.stop();
|
||||
assertThat(observation.getContext().getLowCardinalityKeyValue("a").getValue()).isEqualTo("alpha");
|
||||
KeyValue a = observation.getContext().getLowCardinalityKeyValue("a");
|
||||
assertThat(a).isNotNull();
|
||||
assertThat(a.getValue()).isEqualTo("alpha");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -86,8 +86,12 @@ class ObservationHandlerGroupsTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<ObservationHandler<?>> getObservationHandlers(ObservationConfig config) {
|
||||
Method method = ReflectionUtils.findMethod(ObservationConfig.class, "getObservationHandlers");
|
||||
assertThat(method).isNotNull();
|
||||
ReflectionUtils.makeAccessible(method);
|
||||
return (List<ObservationHandler<?>>) ReflectionUtils.invokeMethod(method, config);
|
||||
List<ObservationHandler<?>> observationHandlers = (List<ObservationHandler<?>>) ReflectionUtils
|
||||
.invokeMethod(method, config);
|
||||
assertThat(observationHandlers).isNotNull();
|
||||
return observationHandlers;
|
||||
}
|
||||
|
||||
private static class NamedObservationHandler implements ObservationHandler<Observation.Context> {
|
||||
|
||||
Reference in New Issue
Block a user