diff --git a/smoke-test/spring-boot-smoke-test-cache/build.gradle b/smoke-test/spring-boot-smoke-test-cache/build.gradle index da837c4bcb5..cd51f36cc5f 100644 --- a/smoke-test/spring-boot-smoke-test-cache/build.gradle +++ b/smoke-test/spring-boot-smoke-test-cache/build.gradle @@ -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" +} diff --git a/smoke-test/spring-boot-smoke-test-cache/src/dockerTest/java/smoketest/cache/SampleCacheApplicationRedisTests.java b/smoke-test/spring-boot-smoke-test-cache/src/dockerTest/java/smoketest/cache/SampleCacheApplicationRedisTests.java index 3653c8e472b..7517b02720a 100644 --- a/smoke-test/spring-boot-smoke-test-cache/src/dockerTest/java/smoketest/cache/SampleCacheApplicationRedisTests.java +++ b/smoke-test/spring-boot-smoke-test-cache/src/dockerTest/java/smoketest/cache/SampleCacheApplicationRedisTests.java @@ -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); } } diff --git a/smoke-test/spring-boot-smoke-test-cache/src/test/java/smoketest/cache/SampleCacheApplicationTests.java b/smoke-test/spring-boot-smoke-test-cache/src/test/java/smoketest/cache/SampleCacheApplicationTests.java index 28b4065c8d9..d5afc85c01a 100644 --- a/smoke-test/spring-boot-smoke-test-cache/src/test/java/smoketest/cache/SampleCacheApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-cache/src/test/java/smoketest/cache/SampleCacheApplicationTests.java @@ -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); } }