Add nullability annotations to tests in smoke-test/spring-boot-smoke-test-cache

See gh-47263
This commit is contained in:
Moritz Halbritter
2025-10-16 11:24:43 +02:00
parent ad075ae2af
commit 4d476b1a66
3 changed files with 16 additions and 2 deletions
@@ -107,3 +107,11 @@ def testInfinispan = tasks.register("testInfinispan", Test) {
tasks.named("check").configure {
dependsOn testCaffeine, testCouchbase, testEhcache, testHazelcast, testInfinispan
}
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}
tasks.named("compileDockerTestJava") {
options.nullability.checking = "tests"
}
@@ -26,6 +26,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.boot.testsupport.container.TestImage;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import static org.assertj.core.api.Assertions.assertThat;
@@ -51,7 +52,9 @@ class SampleCacheApplicationRedisTests {
countries.clear(); // Simple test assuming the cache is empty
assertThat(countries.get("BE")).isNull();
Country be = this.countryRepository.findByCode("BE");
assertThat((Country) countries.get("BE").get()).isEqualTo(be);
ValueWrapper belgium = countries.get("BE");
assertThat(belgium).isNotNull();
assertThat((Country) belgium.get()).isEqualTo(be);
}
}
@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import static org.assertj.core.api.Assertions.assertThat;
@@ -41,7 +42,9 @@ class SampleCacheApplicationTests {
countries.clear(); // Simple test assuming the cache is empty
assertThat(countries.get("BE")).isNull();
Country be = this.countryRepository.findByCode("BE");
assertThat((Country) countries.get("BE").get()).isEqualTo(be);
ValueWrapper belgium = countries.get("BE");
assertThat(belgium).isNotNull();
assertThat((Country) belgium.get()).isEqualTo(be);
}
}