diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/User.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/User.java index c0e00e69576..2dc158101c6 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/User.java +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/User.java @@ -21,6 +21,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; import jakarta.persistence.Table; +import org.jspecify.annotations.Nullable; import org.springframework.util.Assert; @@ -35,11 +36,13 @@ public class User { @Id @GeneratedValue - private Long id; + private @Nullable Long id; @Column(unique = true) + @SuppressWarnings("NullAway.Init") private String username; + @SuppressWarnings("NullAway.Init") private VehicleIdentificationNumber vin; protected User() { @@ -52,7 +55,7 @@ public class User { this.vin = vin; } - public Long getId() { + public @Nullable Long getId() { return this.id; } diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/UserRepository.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/UserRepository.java index 7e32e43c208..ebe4fcef113 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/UserRepository.java +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/UserRepository.java @@ -16,6 +16,8 @@ package smoketest.test.domain; +import org.jspecify.annotations.Nullable; + import org.springframework.data.repository.Repository; /** @@ -25,6 +27,6 @@ import org.springframework.data.repository.Repository; */ public interface UserRepository extends Repository { - User findByUsername(String username); + @Nullable User findByUsername(String username); } diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/VehicleIdentificationNumber.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/VehicleIdentificationNumber.java index bdc5a1e9b4b..d74a0d9d634 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/VehicleIdentificationNumber.java +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/VehicleIdentificationNumber.java @@ -16,6 +16,8 @@ package smoketest.test.domain; +import org.jspecify.annotations.Nullable; + import org.springframework.util.Assert; /** @@ -34,7 +36,7 @@ public final class VehicleIdentificationNumber { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/package-info.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/package-info.java new file mode 100644 index 00000000000..25d56314721 --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/domain/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.test.domain; + +import org.jspecify.annotations.NullMarked; diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/package-info.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/package-info.java new file mode 100644 index 00000000000..377fd00ebc9 --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.test; + +import org.jspecify.annotations.NullMarked; diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/RemoteVehicleDetailsService.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/RemoteVehicleDetailsService.java index 23c58264d31..7fb5bb87cd3 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/RemoteVehicleDetailsService.java +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/RemoteVehicleDetailsService.java @@ -49,7 +49,10 @@ public class RemoteVehicleDetailsService implements VehicleDetailsService { Assert.notNull(vin, "'vin' must not be null"); logger.debug("Retrieving vehicle data for: " + vin); try { - return this.restTemplate.getForObject("/vehicle/{vin}/details", VehicleDetails.class, vin); + VehicleDetails response = this.restTemplate.getForObject("/vehicle/{vin}/details", VehicleDetails.class, + vin); + Assert.state(response != null, "'response' must not be null"); + return response; } catch (HttpStatusCodeException ex) { if (HttpStatus.NOT_FOUND.equals(ex.getStatusCode())) { diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/VehicleDetails.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/VehicleDetails.java index c2110303a73..8dab1672122 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/VehicleDetails.java +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/VehicleDetails.java @@ -18,6 +18,7 @@ package smoketest.test.service; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import org.jspecify.annotations.Nullable; import org.springframework.util.Assert; @@ -49,7 +50,7 @@ public class VehicleDetails { } @Override - public boolean equals(Object obj) { + public boolean equals(@Nullable Object obj) { if (obj == this) { return true; } diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/VehicleIdentificationNumberNotFoundException.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/VehicleIdentificationNumberNotFoundException.java index 20101701ae1..3f913eb141a 100644 --- a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/VehicleIdentificationNumberNotFoundException.java +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/VehicleIdentificationNumberNotFoundException.java @@ -16,6 +16,7 @@ package smoketest.test.service; +import org.jspecify.annotations.Nullable; import smoketest.test.domain.VehicleIdentificationNumber; /** @@ -31,7 +32,7 @@ public class VehicleIdentificationNumberNotFoundException extends RuntimeExcepti this(vin, null); } - public VehicleIdentificationNumberNotFoundException(VehicleIdentificationNumber vin, Throwable cause) { + public VehicleIdentificationNumberNotFoundException(VehicleIdentificationNumber vin, @Nullable Throwable cause) { super("Unable to find VehicleIdentificationNumber " + vin, cause); this.vehicleIdentificationNumber = vin; } diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/package-info.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/package-info.java new file mode 100644 index 00000000000..4681269e45b --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/service/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.test.service; + +import org.jspecify.annotations.NullMarked; diff --git a/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/web/package-info.java b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/web/package-info.java new file mode 100644 index 00000000000..91a0441959b --- /dev/null +++ b/smoke-test/spring-boot-smoke-test-test/src/main/java/smoketest/test/web/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@NullMarked +package smoketest.test.web; + +import org.jspecify.annotations.NullMarked;