Use modern language features in tests
This commit is contained in:
parent
32cd73261a
commit
b3f786728e
|
|
@ -195,14 +195,22 @@ public class PagedListHolderTests {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MockFilter)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof MockFilter mockFilter)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final MockFilter mockFilter = (MockFilter) o;
|
||||
|
||||
if (!age.equals(mockFilter.age)) return false;
|
||||
if (!extendedInfo.equals(mockFilter.extendedInfo)) return false;
|
||||
if (!name.equals(mockFilter.name)) return false;
|
||||
if (!age.equals(mockFilter.age)) {
|
||||
return false;
|
||||
}
|
||||
if (!extendedInfo.equals(mockFilter.extendedInfo)) {
|
||||
return false;
|
||||
}
|
||||
if (!name.equals(mockFilter.name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,9 @@ public class NestedTestBean implements INestedTestBean {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof NestedTestBean)) {
|
||||
if (!(obj instanceof NestedTestBean ntb)) {
|
||||
return false;
|
||||
}
|
||||
NestedTestBean ntb = (NestedTestBean) obj;
|
||||
return this.company.equals(ntb.company);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,10 +64,9 @@ public class SerializablePerson implements Person, Serializable {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof SerializablePerson)) {
|
||||
if (!(other instanceof SerializablePerson p)) {
|
||||
return false;
|
||||
}
|
||||
SerializablePerson p = (SerializablePerson) other;
|
||||
return p.age == age && ObjectUtils.nullSafeEquals(name, p.name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -468,10 +468,9 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
|||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof TestBean)) {
|
||||
if (!(other instanceof TestBean tb2)) {
|
||||
return false;
|
||||
}
|
||||
TestBean tb2 = (TestBean) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.name, tb2.name) && this.age == tb2.age);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -261,11 +261,9 @@ public abstract class AbstractBeanFactoryTests {
|
|||
@Test
|
||||
public void aliasing() {
|
||||
BeanFactory bf = getBeanFactory();
|
||||
if (!(bf instanceof ConfigurableBeanFactory)) {
|
||||
if (!(bf instanceof ConfigurableBeanFactory cbf)) {
|
||||
return;
|
||||
}
|
||||
ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) bf;
|
||||
|
||||
String alias = "rods alias";
|
||||
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
|
||||
|
|
|
|||
|
|
@ -1358,7 +1358,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
|
||||
@Bean
|
||||
public Repository<String> stringRepo() {
|
||||
return new Repository<String>() {
|
||||
return new Repository<>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Repository<String>";
|
||||
|
|
@ -1368,7 +1368,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
|
||||
@Bean
|
||||
public Repository<Integer> integerRepo() {
|
||||
return new Repository<Integer>() {
|
||||
return new Repository<>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Repository<Integer>";
|
||||
|
|
@ -1378,7 +1378,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
|
||||
@Bean
|
||||
public Repository<?> genericRepo() {
|
||||
return new Repository<Object>() {
|
||||
return new Repository<>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Repository<Object>";
|
||||
|
|
@ -1423,7 +1423,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
@Bean
|
||||
@Scope("prototype")
|
||||
public Repository<String> stringRepo() {
|
||||
return new Repository<String>() {
|
||||
return new Repository<>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Repository<String>";
|
||||
|
|
@ -1434,7 +1434,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
@Bean
|
||||
@Scope("prototype")
|
||||
public Repository<Integer> integerRepo() {
|
||||
return new Repository<Integer>() {
|
||||
return new Repository<>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Repository<Integer>";
|
||||
|
|
@ -1446,7 +1446,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
@Scope("prototype")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Repository genericRepo() {
|
||||
return new Repository<Object>() {
|
||||
return new Repository<>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Repository<Object>";
|
||||
|
|
@ -1468,7 +1468,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
@Bean
|
||||
@Scope(scopeName = "prototype", proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public Repository<String> stringRepo() {
|
||||
return new Repository<String>() {
|
||||
return new Repository<>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Repository<String>";
|
||||
|
|
@ -1479,7 +1479,7 @@ class ConfigurationClassPostProcessorTests {
|
|||
@Bean
|
||||
@PrototypeScoped
|
||||
public Repository<Integer> integerRepo() {
|
||||
return new Repository<Integer>() {
|
||||
return new Repository<>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Repository<Integer>";
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class ConfigurationWithFactoryBeanBeanEarlyDeductionTests {
|
|||
beanDefinition.setFactoryBeanName("factoryBean");
|
||||
beanDefinition.setFactoryMethodName("myBean");
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
try {
|
||||
try (context) {
|
||||
context.registerBeanDefinition("factoryBean", factoryBeanDefinition);
|
||||
context.registerBeanDefinition("myBean", beanDefinition);
|
||||
NameCollectingBeanFactoryPostProcessor postProcessor = new NameCollectingBeanFactoryPostProcessor();
|
||||
|
|
@ -103,9 +103,6 @@ public class ConfigurationWithFactoryBeanBeanEarlyDeductionTests {
|
|||
context.refresh();
|
||||
assertContainsMyBeanName(postProcessor.getNames());
|
||||
}
|
||||
finally {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertPostFreeze(Class<?> configurationClass) {
|
||||
|
|
@ -118,16 +115,13 @@ public class ConfigurationWithFactoryBeanBeanEarlyDeductionTests {
|
|||
BeanFactoryPostProcessor... postProcessors) {
|
||||
NameCollectingBeanFactoryPostProcessor postProcessor = new NameCollectingBeanFactoryPostProcessor();
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
try {
|
||||
try (context) {
|
||||
Arrays.stream(postProcessors).forEach(context::addBeanFactoryPostProcessor);
|
||||
context.addBeanFactoryPostProcessor(postProcessor);
|
||||
context.register(configurationClass);
|
||||
context.refresh();
|
||||
assertContainsMyBeanName(postProcessor.getNames());
|
||||
}
|
||||
finally {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertContainsMyBeanName(AnnotationConfigApplicationContext context) {
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ class PropertySourceAnnotationTests {
|
|||
@Bean
|
||||
FactoryBean<TestBean> testBean() {
|
||||
final String name = env.getProperty("testbean.name");
|
||||
return new FactoryBean<TestBean>() {
|
||||
return new FactoryBean<>() {
|
||||
@Override
|
||||
public TestBean getObject() {
|
||||
return new TestBean(name);
|
||||
|
|
@ -417,7 +417,7 @@ class PropertySourceAnnotationTests {
|
|||
@Override
|
||||
public org.springframework.core.env.PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
|
||||
Properties props = PropertiesLoaderUtils.loadProperties(resource);
|
||||
return new org.springframework.core.env.PropertySource<Properties>("my" + name, props) {
|
||||
return new org.springframework.core.env.PropertySource<>("my" + name, props) {
|
||||
@Override
|
||||
public Object getProperty(String name) {
|
||||
String value = props.getProperty(name);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class Spr15275Tests {
|
|||
|
||||
@Bean
|
||||
public FactoryBean<Foo> foo() {
|
||||
return new FactoryBean<Foo>() {
|
||||
return new FactoryBean<>() {
|
||||
@Override
|
||||
public Foo getObject() {
|
||||
return new Foo("x");
|
||||
|
|
@ -103,7 +103,7 @@ public class Spr15275Tests {
|
|||
|
||||
@Bean
|
||||
public FactoryBean<Foo> foo() {
|
||||
return new AbstractFactoryBean<Foo>() {
|
||||
return new AbstractFactoryBean<>() {
|
||||
@Override
|
||||
public Foo createInstance() {
|
||||
return new Foo("x");
|
||||
|
|
@ -128,7 +128,7 @@ public class Spr15275Tests {
|
|||
|
||||
@Bean
|
||||
public FactoryBean<FooInterface> foo() {
|
||||
return new AbstractFactoryBean<FooInterface>() {
|
||||
return new AbstractFactoryBean<>() {
|
||||
@Override
|
||||
public FooInterface createInstance() {
|
||||
return new Foo("x");
|
||||
|
|
@ -153,7 +153,7 @@ public class Spr15275Tests {
|
|||
|
||||
@Bean
|
||||
public AbstractFactoryBean<FooInterface> foo() {
|
||||
return new AbstractFactoryBean<FooInterface>() {
|
||||
return new AbstractFactoryBean<>() {
|
||||
@Override
|
||||
public FooInterface createInstance() {
|
||||
return new Foo("x");
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class Spr16179Tests {
|
|||
|
||||
@Bean
|
||||
Assembler<SomeType> someAssembler() {
|
||||
return new Assembler<SomeType>() {};
|
||||
return new Assembler<>() {};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -774,8 +774,7 @@ class AnnotationDrivenEventListenerTests {
|
|||
if (event.content == null) {
|
||||
return null;
|
||||
}
|
||||
else if (event.content instanceof String) {
|
||||
String s = (String) event.content;
|
||||
else if (event.content instanceof String s) {
|
||||
if (s.equals("String")) {
|
||||
return event.content;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class ConversionServiceFactoryBeanTests {
|
|||
converters.add(new ConverterFactory<String, Bar>() {
|
||||
@Override
|
||||
public <T extends Bar> Converter<String, T> getConverter(Class<T> targetType) {
|
||||
return new Converter<String, T> () {
|
||||
return new Converter<> () {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T convert(String source) {
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ public class PropertySourcesPlaceholderConfigurerTests {
|
|||
|
||||
PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
|
||||
|
||||
PropertySource<?> ps = new PropertySource<Object>("simplePropertySource", new Object()) {
|
||||
PropertySource<?> ps = new PropertySource<>("simplePropertySource", new Object()) {
|
||||
@Override
|
||||
public Object getProperty(String key) {
|
||||
return "bar";
|
||||
|
|
|
|||
|
|
@ -168,8 +168,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
|
|||
NotificationListenerBean listenerBean = new NotificationListenerBean();
|
||||
listenerBean.setNotificationListener(listener);
|
||||
listenerBean.setNotificationFilter(notification -> {
|
||||
if (notification instanceof AttributeChangeNotification) {
|
||||
AttributeChangeNotification changeNotification = (AttributeChangeNotification) notification;
|
||||
if (notification instanceof AttributeChangeNotification changeNotification) {
|
||||
return "Name".equals(changeNotification.getAttributeName());
|
||||
}
|
||||
else {
|
||||
|
|
@ -450,8 +449,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
|
|||
|
||||
@Override
|
||||
public void handleNotification(Notification notification, Object handback) {
|
||||
if (notification instanceof AttributeChangeNotification) {
|
||||
AttributeChangeNotification attNotification = (AttributeChangeNotification) notification;
|
||||
if (notification instanceof AttributeChangeNotification attNotification) {
|
||||
String attributeName = attNotification.getAttributeName();
|
||||
|
||||
Integer currentCount = (Integer) this.attributeCounts.get(attributeName);
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class BitsCronFieldTests {
|
|||
}
|
||||
|
||||
private static Condition<BitsCronField> set(int... indices) {
|
||||
return new Condition<BitsCronField>(String.format("set bits %s", Arrays.toString(indices))) {
|
||||
return new Condition<>(String.format("set bits %s", Arrays.toString(indices))) {
|
||||
@Override
|
||||
public boolean matches(BitsCronField value) {
|
||||
for (int index : indices) {
|
||||
|
|
@ -122,7 +122,7 @@ class BitsCronFieldTests {
|
|||
}
|
||||
|
||||
private static Condition<BitsCronField> setRange(int min, int max) {
|
||||
return new Condition<BitsCronField>(String.format("set range %d-%d", min, max)) {
|
||||
return new Condition<>(String.format("set range %d-%d", min, max)) {
|
||||
@Override
|
||||
public boolean matches(BitsCronField value) {
|
||||
for (int i = min; i < max; i++) {
|
||||
|
|
@ -136,7 +136,7 @@ class BitsCronFieldTests {
|
|||
}
|
||||
|
||||
private static Condition<BitsCronField> clear(int... indices) {
|
||||
return new Condition<BitsCronField>(String.format("clear bits %s", Arrays.toString(indices))) {
|
||||
return new Condition<>(String.format("clear bits %s", Arrays.toString(indices))) {
|
||||
@Override
|
||||
public boolean matches(BitsCronField value) {
|
||||
for (int index : indices) {
|
||||
|
|
@ -150,7 +150,7 @@ class BitsCronFieldTests {
|
|||
}
|
||||
|
||||
private static Condition<BitsCronField> clearRange(int min, int max) {
|
||||
return new Condition<BitsCronField>(String.format("clear range %d-%d", min, max)) {
|
||||
return new Condition<>(String.format("clear range %d-%d", min, max)) {
|
||||
@Override
|
||||
public boolean matches(BitsCronField value) {
|
||||
for (int i = min; i < max; i++) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
class CronExpressionTests {
|
||||
|
||||
private static final Condition<Temporal> weekday = new Condition<Temporal>("weekday") {
|
||||
private static final Condition<Temporal> weekday = new Condition<>("weekday") {
|
||||
|
||||
@Override
|
||||
public boolean matches(Temporal value) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class LobSupportTests {
|
|||
}
|
||||
|
||||
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) {
|
||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<Void>() {
|
||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<>() {
|
||||
|
||||
@Override
|
||||
protected void streamData(ResultSet rs) throws SQLException, IOException {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public class SqlQueryTests {
|
|||
given(resultSet.next()).willReturn(true, false);
|
||||
given(resultSet.getInt(1)).willReturn(1);
|
||||
|
||||
SqlQuery<Integer> query = new MappingSqlQueryWithParameters<Integer>() {
|
||||
SqlQuery<Integer> query = new MappingSqlQueryWithParameters<>() {
|
||||
@Override
|
||||
protected Integer mapRow(ResultSet rs, int rownum, @Nullable Object[] params, @Nullable Map<? ,?> context)
|
||||
throws SQLException {
|
||||
|
|
@ -129,7 +129,7 @@ public class SqlQueryTests {
|
|||
|
||||
@Test
|
||||
public void testQueryWithoutEnoughParams() {
|
||||
MappingSqlQuery<Integer> query = new MappingSqlQuery<Integer>() {
|
||||
MappingSqlQuery<Integer> query = new MappingSqlQuery<>() {
|
||||
@Override
|
||||
protected Integer mapRow(ResultSet rs, int rownum) throws SQLException {
|
||||
return rs.getInt(1);
|
||||
|
|
@ -147,7 +147,7 @@ public class SqlQueryTests {
|
|||
|
||||
@Test
|
||||
public void testQueryWithMissingMapParams() {
|
||||
MappingSqlQuery<Integer> query = new MappingSqlQuery<Integer>() {
|
||||
MappingSqlQuery<Integer> query = new MappingSqlQuery<>() {
|
||||
@Override
|
||||
protected Integer mapRow(ResultSet rs, int rownum) throws SQLException {
|
||||
return rs.getInt(1);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.jdbc.support;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -69,12 +68,7 @@ class KeyHolderTests {
|
|||
|
||||
@Test
|
||||
void getKeyWithMultipleKeysInMap() {
|
||||
@SuppressWarnings("serial")
|
||||
Map<String, Object> m = new HashMap<String, Object>() {{
|
||||
put("key", 1);
|
||||
put("seq", 2);
|
||||
}};
|
||||
kh.getKeyList().add(m);
|
||||
kh.getKeyList().add(Map.of("key", 1, "seq", 2));
|
||||
|
||||
assertThat(kh.getKeys()).as("two keys should be in the map").hasSize(2);
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
|
||||
|
|
@ -110,10 +104,7 @@ class KeyHolderTests {
|
|||
@Test
|
||||
void getKeysWithMultipleKeyRows() {
|
||||
@SuppressWarnings("serial")
|
||||
Map<String, Object> m = new HashMap<String, Object>() {{
|
||||
put("key", 1);
|
||||
put("seq", 2);
|
||||
}};
|
||||
Map<String, Object> m = Map.of("key", 1, "seq", 2);
|
||||
kh.getKeyList().addAll(asList(m, m));
|
||||
|
||||
assertThat(kh.getKeyList()).as("two rows should be in the list").hasSize(2);
|
||||
|
|
|
|||
|
|
@ -61,10 +61,9 @@ public class TestSimpSubscription implements SimpSubscription {
|
|||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof SimpSubscription)) {
|
||||
if (!(other instanceof SimpSubscription otherSubscription)) {
|
||||
return false;
|
||||
}
|
||||
SimpSubscription otherSubscription = (SimpSubscription) other;
|
||||
return (ObjectUtils.nullSafeEquals(getSession(), otherSubscription.getSession()) &&
|
||||
this.id.equals(otherSubscription.getId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,8 +89,7 @@ abstract class AbstractHttpRequestFactoryTests extends AbstractMockWebServerTest
|
|||
final byte[] body = "Hello World".getBytes(StandardCharsets.UTF_8);
|
||||
request.getHeaders().setContentLength(body.length);
|
||||
|
||||
if (request instanceof StreamingHttpOutputMessage) {
|
||||
StreamingHttpOutputMessage streamingRequest = (StreamingHttpOutputMessage) request;
|
||||
if (request instanceof StreamingHttpOutputMessage streamingRequest) {
|
||||
streamingRequest.setBody(outputStream -> StreamUtils.copy(body, outputStream));
|
||||
}
|
||||
else {
|
||||
|
|
@ -111,8 +110,7 @@ abstract class AbstractHttpRequestFactoryTests extends AbstractMockWebServerTest
|
|||
ClientHttpRequest request = factory.createRequest(new URI(baseUrl + "/echo"), HttpMethod.POST);
|
||||
|
||||
final byte[] body = "Hello World".getBytes(StandardCharsets.UTF_8);
|
||||
if (request instanceof StreamingHttpOutputMessage) {
|
||||
StreamingHttpOutputMessage streamingRequest = (StreamingHttpOutputMessage) request;
|
||||
if (request instanceof StreamingHttpOutputMessage streamingRequest) {
|
||||
streamingRequest.setBody(outputStream -> {
|
||||
StreamUtils.copy(body, outputStream);
|
||||
outputStream.flush();
|
||||
|
|
|
|||
|
|
@ -289,8 +289,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof TypePojo) {
|
||||
TypePojo other = (TypePojo) o;
|
||||
if (o instanceof TypePojo other) {
|
||||
return this.foo.equals(other.foo) && this.bar.equals(other.bar);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ public class GsonHttpMessageConverterTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void readAndWriteParameterizedType() throws Exception {
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<List<MyBean>>() {
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<>() {
|
||||
};
|
||||
|
||||
String body = "[{\"bytes\":[1,2],\"array\":[\"Foo\",\"Bar\"]," +
|
||||
|
|
@ -234,8 +234,8 @@ public class GsonHttpMessageConverterTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void writeParameterizedBaseType() throws Exception {
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<List<MyBean>>() {};
|
||||
ParameterizedTypeReference<List<MyBase>> baseList = new ParameterizedTypeReference<List<MyBase>>() {};
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<>() {};
|
||||
ParameterizedTypeReference<List<MyBase>> baseList = new ParameterizedTypeReference<>() {};
|
||||
|
||||
String body = "[{\"bytes\":[1,2],\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}]";
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ public class JsonbHttpMessageConverterTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void readAndWriteParameterizedType() throws Exception {
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<List<MyBean>>() {};
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<>() {};
|
||||
|
||||
String body = "[{\"bytes\":[1,2],\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}]";
|
||||
|
|
@ -233,8 +233,8 @@ public class JsonbHttpMessageConverterTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void writeParameterizedBaseType() throws Exception {
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<List<MyBean>>() {};
|
||||
ParameterizedTypeReference<List<MyBase>> baseList = new ParameterizedTypeReference<List<MyBase>>() {};
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<>() {};
|
||||
ParameterizedTypeReference<List<MyBase>> baseList = new ParameterizedTypeReference<>() {};
|
||||
|
||||
String body = "[{\"bytes\":[1,2],\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}]";
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void readAndWriteParameterizedType() throws Exception {
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<List<MyBean>>() {};
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<>() {};
|
||||
|
||||
String body = "[{" +
|
||||
"\"bytes\":\"AQI=\"," +
|
||||
|
|
@ -312,8 +312,8 @@ public class MappingJackson2HttpMessageConverterTests {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void writeParameterizedBaseType() throws Exception {
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<List<MyBean>>() {};
|
||||
ParameterizedTypeReference<List<MyBase>> baseList = new ParameterizedTypeReference<List<MyBase>>() {};
|
||||
ParameterizedTypeReference<List<MyBean>> beansList = new ParameterizedTypeReference<>() {};
|
||||
ParameterizedTypeReference<List<MyBase>> baseList = new ParameterizedTypeReference<>() {};
|
||||
|
||||
String body = "[{" +
|
||||
"\"bytes\":\"AQI=\"," +
|
||||
|
|
@ -468,7 +468,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
|||
bar.setNumber(123);
|
||||
beans.add(bar);
|
||||
ParameterizedTypeReference<List<MyInterface>> typeReference =
|
||||
new ParameterizedTypeReference<List<MyInterface>>() {};
|
||||
new ParameterizedTypeReference<>() {};
|
||||
|
||||
this.converter.writeInternal(beans, typeReference.getType(), outputMessage);
|
||||
|
||||
|
|
|
|||
|
|
@ -224,8 +224,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof RootElement) {
|
||||
RootElement other = (RootElement) o;
|
||||
if (o instanceof RootElement other) {
|
||||
return this.type.equals(other.type);
|
||||
}
|
||||
return false;
|
||||
|
|
@ -256,8 +255,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof TestType) {
|
||||
TestType other = (TestType) o;
|
||||
if (o instanceof TestType other) {
|
||||
return this.s.equals(other.s);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public class ChannelSendOperatorTests {
|
|||
return Mono.never();
|
||||
});
|
||||
|
||||
BaseSubscriber<Void> subscriber = new BaseSubscriber<Void>() {};
|
||||
BaseSubscriber<Void> subscriber = new BaseSubscriber<>() {};
|
||||
operator.subscribe(subscriber);
|
||||
subscriber.cancel();
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class HttpMessageConverterExtractorTests {
|
|||
void generics() throws IOException {
|
||||
responseHeaders.setContentType(contentType);
|
||||
String expected = "Foo";
|
||||
ParameterizedTypeReference<List<String>> reference = new ParameterizedTypeReference<List<String>>() {};
|
||||
ParameterizedTypeReference<List<String>> reference = new ParameterizedTypeReference<>() {};
|
||||
Type type = reference.getType();
|
||||
|
||||
GenericHttpMessageConverter<String> converter = mock(GenericHttpMessageConverter.class);
|
||||
|
|
|
|||
|
|
@ -115,8 +115,7 @@ class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
|
|||
*/
|
||||
@RegisterExtension
|
||||
TestExecutionExceptionHandler serverErrorToAssertionErrorConverter = (context, throwable) -> {
|
||||
if (throwable instanceof HttpServerErrorException) {
|
||||
HttpServerErrorException ex = (HttpServerErrorException) throwable;
|
||||
if (throwable instanceof HttpServerErrorException ex) {
|
||||
String responseBody = ex.getResponseBodyAsString();
|
||||
String prefix = AssertionError.class.getName() + ": ";
|
||||
if (responseBody.startsWith(prefix)) {
|
||||
|
|
|
|||
|
|
@ -646,7 +646,7 @@ class RestTemplateTests {
|
|||
void exchangeParameterizedType() throws Exception {
|
||||
GenericHttpMessageConverter converter = mock(GenericHttpMessageConverter.class);
|
||||
template.setMessageConverters(Collections.<HttpMessageConverter<?>>singletonList(converter));
|
||||
ParameterizedTypeReference<List<Integer>> intList = new ParameterizedTypeReference<List<Integer>>() {};
|
||||
ParameterizedTypeReference<List<Integer>> intList = new ParameterizedTypeReference<>() {};
|
||||
given(converter.canRead(intList.getType(), null, null)).willReturn(true);
|
||||
given(converter.getSupportedMediaTypes(any())).willReturn(Collections.singletonList(MediaType.TEXT_PLAIN));
|
||||
given(converter.canWrite(String.class, String.class, null)).willReturn(true);
|
||||
|
|
|
|||
|
|
@ -52,8 +52,7 @@ public abstract class AbstractHttpHandlerIntegrationTests {
|
|||
*/
|
||||
@RegisterExtension
|
||||
TestExecutionExceptionHandler serverErrorToAssertionErrorConverter = (context, throwable) -> {
|
||||
if (throwable instanceof HttpServerErrorException) {
|
||||
HttpServerErrorException ex = (HttpServerErrorException) throwable;
|
||||
if (throwable instanceof HttpServerErrorException ex) {
|
||||
String responseBody = ex.getResponseBodyAsString();
|
||||
if (StringUtils.hasText(responseBody)) {
|
||||
String prefix = AssertionError.class.getName() + ": ";
|
||||
|
|
|
|||
|
|
@ -1282,8 +1282,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
|||
|
||||
public void setSession(HttpSession session) {
|
||||
this.session = session;
|
||||
if (session instanceof MockHttpSession) {
|
||||
MockHttpSession mockSession = ((MockHttpSession) session);
|
||||
if (session instanceof MockHttpSession mockSession) {
|
||||
mockSession.access();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -447,8 +447,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||
if (cookie.isHttpOnly()) {
|
||||
buf.append("; HttpOnly");
|
||||
}
|
||||
if (cookie instanceof MockCookie) {
|
||||
MockCookie mockCookie = (MockCookie) cookie;
|
||||
if (cookie instanceof MockCookie mockCookie) {
|
||||
if (StringUtils.hasText(mockCookie.getSameSite())) {
|
||||
buf.append("; SameSite=").append(mockCookie.getSameSite());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ public class Pojo {
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof Pojo) {
|
||||
Pojo other = (Pojo) o;
|
||||
if (o instanceof Pojo other) {
|
||||
return this.foo.equals(other.foo) && this.bar.equals(other.bar);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ public class DefaultClientRequestBuilderTests {
|
|||
public void bodyParameterizedTypeReference() {
|
||||
String body = "foo";
|
||||
Publisher<String> publisher = Mono.just(body);
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<>() {};
|
||||
ClientRequest result = ClientRequest.create(POST, DEFAULT_URL).body(publisher, typeReference).build();
|
||||
|
||||
List<HttpMessageWriter<?>> messageWriters = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class ClientResponseWrapperTests {
|
|||
@Test
|
||||
public void bodyToMonoParameterizedTypeReference() {
|
||||
Mono<String> result = Mono.just("foo");
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<>() {};
|
||||
given(mockResponse.bodyToMono(reference)).willReturn(result);
|
||||
|
||||
assertThat(wrapper.bodyToMono(reference)).isSameAs(result);
|
||||
|
|
@ -128,7 +128,7 @@ public class ClientResponseWrapperTests {
|
|||
@Test
|
||||
public void bodyToFluxParameterizedTypeReference() {
|
||||
Flux<String> result = Flux.just("foo");
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<>() {};
|
||||
given(mockResponse.bodyToFlux(reference)).willReturn(result);
|
||||
|
||||
assertThat(wrapper.bodyToFlux(reference)).isSameAs(result);
|
||||
|
|
@ -145,7 +145,7 @@ public class ClientResponseWrapperTests {
|
|||
@Test
|
||||
public void toEntityParameterizedTypeReference() {
|
||||
Mono<ResponseEntity<String>> result = Mono.just(new ResponseEntity<>("foo", HttpStatus.OK));
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<>() {};
|
||||
given(mockResponse.toEntity(reference)).willReturn(result);
|
||||
|
||||
assertThat(wrapper.toEntity(reference)).isSameAs(result);
|
||||
|
|
@ -162,7 +162,7 @@ public class ClientResponseWrapperTests {
|
|||
@Test
|
||||
public void toEntityListParameterizedTypeReference() {
|
||||
Mono<ResponseEntity<List<String>>> result = Mono.just(new ResponseEntity<>(singletonList("foo"), HttpStatus.OK));
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<>() {};
|
||||
given(mockResponse.toEntityList(reference)).willReturn(result);
|
||||
|
||||
assertThat(wrapper.toEntityList(reference)).isSameAs(result);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class DefaultEntityResponseBuilderTests {
|
|||
@Test
|
||||
public void fromPublisher() {
|
||||
Flux<String> body = Flux.just("foo", "bar");
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<>() {};
|
||||
EntityResponse<Flux<String>> response = EntityResponse.fromPublisher(body, typeReference).build().block();
|
||||
assertThat(response.entity()).isSameAs(body);
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ public class DefaultEntityResponseBuilderTests {
|
|||
@Test
|
||||
public void fromProducer() {
|
||||
Single<String> body = Single.just("foo");
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<>() {};
|
||||
EntityResponse<Single<String>> response = EntityResponse.fromProducer(body, typeReference).build().block();
|
||||
assertThat(response.entity()).isSameAs(body);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ public class DefaultServerRequestTests {
|
|||
.body(body);
|
||||
DefaultServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), messageReaders);
|
||||
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<>() {};
|
||||
Mono<String> resultMono = request.bodyToMono(typeReference);
|
||||
assertThat(resultMono.block()).isEqualTo("foo");
|
||||
}
|
||||
|
|
@ -346,7 +346,7 @@ public class DefaultServerRequestTests {
|
|||
.body(body);
|
||||
DefaultServerRequest request = new DefaultServerRequest(MockServerWebExchange.from(mockRequest), messageReaders);
|
||||
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<>() {};
|
||||
Flux<String> resultFlux = request.bodyToFlux(typeReference);
|
||||
assertThat(resultFlux.collectList().block()).isEqualTo(Collections.singletonList("foo"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTe
|
|||
void flux(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
ParameterizedTypeReference<List<Person>> reference = new ParameterizedTypeReference<List<Person>>() {};
|
||||
ParameterizedTypeReference<List<Person>> reference = new ParameterizedTypeReference<>() {};
|
||||
ResponseEntity<List<Person>> result =
|
||||
this.restTemplate
|
||||
.exchange("http://localhost:" + this.port + "/flux", HttpMethod.GET, null, reference);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class PublisherHandlerFunctionIntegrationTests extends AbstractRouterFunctionInt
|
|||
void flux(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
ParameterizedTypeReference<List<Person>> reference = new ParameterizedTypeReference<List<Person>>() {};
|
||||
ParameterizedTypeReference<List<Person>> reference = new ParameterizedTypeReference<>() {};
|
||||
ResponseEntity<List<Person>> result =
|
||||
restTemplate.exchange("http://localhost:" + super.port + "/flux", HttpMethod.GET, null, reference);
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ public class ServerRequestWrapperTests {
|
|||
@Test
|
||||
public void bodyToMonoParameterizedTypeReference() {
|
||||
Mono<String> result = Mono.just("foo");
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<>() {};
|
||||
given(mockRequest.bodyToMono(reference)).willReturn(result);
|
||||
|
||||
assertThat(wrapper.bodyToMono(reference)).isSameAs(result);
|
||||
|
|
@ -176,7 +176,7 @@ public class ServerRequestWrapperTests {
|
|||
@Test
|
||||
public void bodyToFluxParameterizedTypeReference() {
|
||||
Flux<String> result = Flux.just("foo");
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {};
|
||||
ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<>() {};
|
||||
given(mockRequest.bodyToFlux(reference)).willReturn(result);
|
||||
|
||||
assertThat(wrapper.bodyToFlux(reference)).isSameAs(result);
|
||||
|
|
|
|||
|
|
@ -353,8 +353,7 @@ public class MessageReaderArgumentResolverTests {
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof TestBean) {
|
||||
TestBean other = (TestBean) o;
|
||||
if (o instanceof TestBean other) {
|
||||
return this.foo.equals(other.foo) && this.bar.equals(other.bar);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ import static org.springframework.http.MediaType.APPLICATION_XML;
|
|||
public class RequestMappingMessageConversionIntegrationTests extends AbstractRequestMappingIntegrationTests {
|
||||
|
||||
private static final ParameterizedTypeReference<List<Person>> PERSON_LIST =
|
||||
new ParameterizedTypeReference<List<Person>>() {};
|
||||
new ParameterizedTypeReference<>() {};
|
||||
|
||||
private static final MediaType JSON = MediaType.APPLICATION_JSON;
|
||||
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ class ContextLoaderTests {
|
|||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
ConfigurableEnvironment environment = applicationContext.getEnvironment();
|
||||
environment.getPropertySources().addFirst(new PropertySource<Object>("testPropertySource") {
|
||||
environment.getPropertySources().addFirst(new PropertySource<>("testPropertySource") {
|
||||
@Override
|
||||
public Object getProperty(String key) {
|
||||
return "name".equals(key) ? "testName" : null;
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ public class XmlWebApplicationContextTests extends AbstractApplicationContextTes
|
|||
root.addBeanFactoryPostProcessor(beanFactory -> beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
|
||||
if (bean instanceof TestBean) {
|
||||
((TestBean) bean).getFriends().add("myFriend");
|
||||
if (bean instanceof TestBean testBean) {
|
||||
testBean.getFriends().add("myFriend");
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,8 +182,7 @@ public class InterceptorRegistryTests {
|
|||
PathMatcher pathMatcher = new AntPathMatcher();
|
||||
List<HandlerInterceptor> result = new ArrayList<>();
|
||||
for (Object interceptor : this.registry.getInterceptors()) {
|
||||
if (interceptor instanceof MappedInterceptor) {
|
||||
MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor;
|
||||
if (interceptor instanceof MappedInterceptor mappedInterceptor) {
|
||||
if (mappedInterceptor.matches(lookupPath, pathMatcher)) {
|
||||
result.add(mappedInterceptor.getInterceptor());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,8 +83,7 @@ public class LocaleResolverTests {
|
|||
}
|
||||
|
||||
// check LocaleContext
|
||||
if (localeResolver instanceof LocaleContextResolver) {
|
||||
LocaleContextResolver localeContextResolver = (LocaleContextResolver) localeResolver;
|
||||
if (localeResolver instanceof LocaleContextResolver localeContextResolver) {
|
||||
LocaleContext localeContext = localeContextResolver.resolveLocaleContext(request);
|
||||
if (shouldSet) {
|
||||
assertThat(localeContext.getLocale()).isEqualTo(Locale.GERMANY);
|
||||
|
|
|
|||
|
|
@ -46,10 +46,9 @@ public class ItemPet {
|
|||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ItemPet)) {
|
||||
if (!(other instanceof ItemPet otherPet)) {
|
||||
return false;
|
||||
}
|
||||
ItemPet otherPet = (ItemPet) other;
|
||||
return (this.name != null && this.name.equals(otherPet.getName()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -556,8 +556,7 @@ class OptionTagTests extends AbstractHtmlElementTagTests {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof RulesVariant) {
|
||||
RulesVariant other = (RulesVariant) obj;
|
||||
if (obj instanceof RulesVariant other) {
|
||||
return this.toId().equals(other.toId());
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public class UndertowTestServer implements WebSocketTestServer {
|
|||
|
||||
@Override
|
||||
public InstanceHandle<Servlet> createInstance() throws InstantiationException {
|
||||
return new InstanceHandle<Servlet>() {
|
||||
return new InstanceHandle<>() {
|
||||
@Override
|
||||
public Servlet getInstance() {
|
||||
return new DispatcherServlet(wac);
|
||||
|
|
@ -167,7 +167,7 @@ public class UndertowTestServer implements WebSocketTestServer {
|
|||
|
||||
@Override
|
||||
public InstanceHandle<Filter> createInstance() throws InstantiationException {
|
||||
return new InstanceHandle<Filter>() {
|
||||
return new InstanceHandle<>() {
|
||||
@Override
|
||||
public Filter getInstance() {
|
||||
return filter;
|
||||
|
|
|
|||
Loading…
Reference in New Issue