Browse Source

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

See gh-47263
pull/47665/head
Moritz Halbritter 2 months ago
parent
commit
4d476b1a66
  1. 8
      smoke-test/spring-boot-smoke-test-cache/build.gradle
  2. 5
      smoke-test/spring-boot-smoke-test-cache/src/dockerTest/java/smoketest/cache/SampleCacheApplicationRedisTests.java
  3. 5
      smoke-test/spring-boot-smoke-test-cache/src/test/java/smoketest/cache/SampleCacheApplicationTests.java

8
smoke-test/spring-boot-smoke-test-cache/build.gradle vendored

@ -107,3 +107,11 @@ def testInfinispan = tasks.register("testInfinispan", Test) { @@ -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"
}

5
smoke-test/spring-boot-smoke-test-cache/src/dockerTest/java/smoketest/cache/SampleCacheApplicationRedisTests.java vendored

@ -26,6 +26,7 @@ import org.springframework.boot.test.context.SpringBootTest; @@ -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 { @@ -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);
}
}

5
smoke-test/spring-boot-smoke-test-cache/src/test/java/smoketest/cache/SampleCacheApplicationTests.java vendored

@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test; @@ -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 { @@ -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);
}
}

Loading…
Cancel
Save