mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Use modern language features in tests
This commit is contained in:
+3
-3
@@ -34,21 +34,21 @@ class ParameterizedTypeReferenceTests {
|
||||
|
||||
@Test
|
||||
void stringTypeReference() {
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<>() {};
|
||||
assertThat(typeReference.getType()).isEqualTo(String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapTypeReference() throws Exception {
|
||||
Type mapType = getClass().getMethod("mapMethod").getGenericReturnType();
|
||||
ParameterizedTypeReference<Map<Object,String>> typeReference = new ParameterizedTypeReference<Map<Object,String>>() {};
|
||||
ParameterizedTypeReference<Map<Object,String>> typeReference = new ParameterizedTypeReference<>() {};
|
||||
assertThat(typeReference.getType()).isEqualTo(mapType);
|
||||
}
|
||||
|
||||
@Test
|
||||
void listTypeReference() throws Exception {
|
||||
Type listType = getClass().getMethod("listMethod").getGenericReturnType();
|
||||
ParameterizedTypeReference<List<String>> typeReference = new ParameterizedTypeReference<List<String>>() {};
|
||||
ParameterizedTypeReference<List<String>> typeReference = new ParameterizedTypeReference<>() {};
|
||||
assertThat(typeReference.getType()).isEqualTo(listType);
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -1096,10 +1096,9 @@ class DefaultConversionServiceTests {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof SSN)) {
|
||||
if (!(o instanceof SSN ssn)) {
|
||||
return false;
|
||||
}
|
||||
SSN ssn = (SSN) o;
|
||||
return this.value.equals(ssn.value);
|
||||
}
|
||||
|
||||
@@ -1137,10 +1136,9 @@ class DefaultConversionServiceTests {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof ISBN)) {
|
||||
if (!(o instanceof ISBN isbn)) {
|
||||
return false;
|
||||
}
|
||||
ISBN isbn = (ISBN) o;
|
||||
return this.value.equals(isbn.value);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ class CustomEnvironmentTests {
|
||||
@Override
|
||||
@SuppressWarnings("serial")
|
||||
protected Set<String> getReservedDefaultProfiles() {
|
||||
return new HashSet<String>() {{
|
||||
return new HashSet<>() {{
|
||||
add("rd1");
|
||||
add("rd2");
|
||||
}};
|
||||
|
||||
+4
-4
@@ -37,10 +37,10 @@ class PropertySourceTests {
|
||||
@Test
|
||||
@SuppressWarnings("serial")
|
||||
void equals() {
|
||||
Map<String, Object> map1 = new HashMap<String, Object>() {{
|
||||
Map<String, Object> map1 = new HashMap<>() {{
|
||||
put("a", "b");
|
||||
}};
|
||||
Map<String, Object> map2 = new HashMap<String, Object>() {{
|
||||
Map<String, Object> map2 = new HashMap<>() {{
|
||||
put("c", "d");
|
||||
}};
|
||||
Properties props1 = new Properties() {{
|
||||
@@ -69,10 +69,10 @@ class PropertySourceTests {
|
||||
@Test
|
||||
@SuppressWarnings("serial")
|
||||
void collectionsOperations() {
|
||||
Map<String, Object> map1 = new HashMap<String, Object>() {{
|
||||
Map<String, Object> map1 = new HashMap<>() {{
|
||||
put("a", "b");
|
||||
}};
|
||||
Map<String, Object> map2 = new HashMap<String, Object>() {{
|
||||
Map<String, Object> map2 = new HashMap<>() {{
|
||||
put("c", "d");
|
||||
}};
|
||||
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ class FutureAdapterTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
void setUp() {
|
||||
adaptee = mock(Future.class);
|
||||
adapter = new FutureAdapter<String, Integer>(adaptee) {
|
||||
adapter = new FutureAdapter<>(adaptee) {
|
||||
@Override
|
||||
protected String adapt(Integer adapteeResult) throws ExecutionException {
|
||||
return adapteeResult.toString();
|
||||
|
||||
Reference in New Issue
Block a user