Use modern language features in tests
This commit is contained in:
@@ -85,8 +85,8 @@ public class GenericConversionService implements ConfigurableConversionService {
|
||||
@Override
|
||||
public void addConverter(Converter<?, ?> converter) {
|
||||
ResolvableType[] typeInfo = getRequiredTypeInfo(converter.getClass(), Converter.class);
|
||||
if (typeInfo == null && converter instanceof DecoratingProxy) {
|
||||
typeInfo = getRequiredTypeInfo(((DecoratingProxy) converter).getDecoratedClass(), Converter.class);
|
||||
if (typeInfo == null && converter instanceof DecoratingProxy decoratingProxy) {
|
||||
typeInfo = getRequiredTypeInfo(decoratingProxy.getDecoratedClass(), Converter.class);
|
||||
}
|
||||
if (typeInfo == null) {
|
||||
throw new IllegalArgumentException("Unable to determine source type <S> and target type <T> for your " +
|
||||
|
||||
@@ -85,8 +85,8 @@ final class SimpleAnnotationMetadataReadingVisitor extends ClassVisitor {
|
||||
if (supername != null && !isInterface(access)) {
|
||||
this.superClassName = toClassName(supername);
|
||||
}
|
||||
for (int i = 0; i < interfaces.length; i++) {
|
||||
this.interfaceNames.add(toClassName(interfaces[i]));
|
||||
for (String element : interfaces) {
|
||||
this.interfaceNames.add(toClassName(element));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class CustomEnvironmentTests {
|
||||
@Override
|
||||
@SuppressWarnings("serial")
|
||||
protected Set<String> getReservedDefaultProfiles() {
|
||||
return new HashSet<String>() {{
|
||||
return new HashSet<>() {{
|
||||
add("rd1");
|
||||
add("rd2");
|
||||
}};
|
||||
|
||||
@@ -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");
|
||||
}};
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -41,10 +41,9 @@ public class TestPrincipal implements Principal {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof TestPrincipal)) {
|
||||
if (!(obj instanceof TestPrincipal p)) {
|
||||
return false;
|
||||
}
|
||||
TestPrincipal p = (TestPrincipal) obj;
|
||||
return this.name.equals(p.name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user