mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Add nullability annotations to smoke-test/spring-boot-smoke-test-test
See gh-46587
This commit is contained in:
+5
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -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, Long> {
|
||||
|
||||
User findByUsername(String username);
|
||||
@Nullable User findByUsername(String username);
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -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;
|
||||
}
|
||||
|
||||
+20
@@ -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;
|
||||
@@ -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;
|
||||
+4
-1
@@ -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())) {
|
||||
|
||||
+2
-1
@@ -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;
|
||||
}
|
||||
|
||||
+2
-1
@@ -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;
|
||||
}
|
||||
|
||||
+20
@@ -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;
|
||||
+20
@@ -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;
|
||||
Reference in New Issue
Block a user