mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Add nullability annotations to tests in smoke-test/spring-boot-smoke-test-cache
See gh-47263
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
+4
-1
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-1
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user