Spring cleaning: avoid deprecation warnings

This commit is contained in:
Sam Brannen 2024-02-23 12:36:50 +01:00
parent 122372c580
commit b0d08fe2d4
8 changed files with 17 additions and 11 deletions

View File

@ -42,6 +42,7 @@ import org.springframework.util.MultiValueMap;
import static java.util.Map.entry;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
/**
* @author Juergen Hoeller
@ -201,7 +202,7 @@ class BeanWrapperGenericsTests {
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", 5);
assertThat(bw.getPropertyValue("listOfLists[0][0]")).isEqualTo(5);
assertThat(gb.getListOfLists()).singleElement().asList().containsExactly(5);
assertThat(gb.getListOfLists()).singleElement().asInstanceOf(LIST).containsExactly(5);
}
@Test
@ -213,7 +214,7 @@ class BeanWrapperGenericsTests {
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", "5");
assertThat(bw.getPropertyValue("listOfLists[0][0]")).isEqualTo(5);
assertThat(gb.getListOfLists()).singleElement().asList().containsExactly(5);
assertThat(gb.getListOfLists()).singleElement().asInstanceOf(LIST).containsExactly(5);
}
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -29,6 +29,7 @@ import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
import static org.mockito.Mockito.mock;
/**
@ -123,7 +124,7 @@ class BeanDefinitionMethodGeneratorFactoryTests {
AotServices.factoriesAndBeans(springFactoriesLoader, beanFactory));
BeanDefinitionMethodGenerator methodGenerator = methodGeneratorFactory
.getBeanDefinitionMethodGenerator(registeredBean);
assertThat(methodGenerator).extracting("aotContributions").asList()
assertThat(methodGenerator).extracting("aotContributions").asInstanceOf(LIST)
.containsExactly(beanContribution, loaderContribution);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -64,6 +64,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.entry;
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
import static org.mockito.Mockito.mock;
/**
@ -375,7 +376,7 @@ class BeanInstanceSupplierTests {
RegisteredBean registerBean = source.registerBean(this.beanFactory);
AutowiredArguments arguments = source.getResolver().resolveArguments(registerBean);
assertThat(arguments.toArray()).hasSize(1);
assertThat(arguments.getObject(0)).isInstanceOf(List.class).asList()
assertThat(arguments.getObject(0)).isInstanceOf(List.class).asInstanceOf(LIST)
.containsExactly("1", "2");
}

View File

@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
/**
* Tests for {@link CustomCollectionEditor}.
@ -60,7 +61,7 @@ class CustomCollectionEditorTests {
Object value = editor.getValue();
assertThat(value).isNotNull();
assertThat(value).isInstanceOf(ArrayList.class);
assertThat(value).asList().containsExactly(0, 1, 2);
assertThat(value).asInstanceOf(LIST).containsExactly(0, 1, 2);
}
@Test

View File

@ -37,6 +37,7 @@ import static org.mockito.Mockito.verify;
/**
* @author Alef Arendsen
*/
@SuppressWarnings("deprecation")
class LobSupportTests {
@Test

View File

@ -60,6 +60,7 @@ import static org.mockito.Mockito.verify;
*/
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
@SuppressWarnings("deprecation")
class SqlLobValueTests {
@Mock

View File

@ -37,6 +37,7 @@ import static org.mockito.Mockito.verify;
* @author Juergen Hoeller
* @since 17.12.2003
*/
@SuppressWarnings("deprecation")
class DefaultLobHandlerTests {
private ResultSet rs = mock();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -36,7 +36,6 @@ import org.hibernate.dialect.Informix10Dialect;
import org.hibernate.dialect.MySQL57Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle12cDialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.PostgreSQL95Dialect;
import org.hibernate.dialect.SQLServer2012Dialect;
import org.hibernate.dialect.SQLServerDialect;
@ -177,7 +176,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
* @param database the target database
* @return the Hibernate database dialect class, or {@code null} if none found
*/
@SuppressWarnings("deprecation") // for DerbyDialect and PostgreSQLDialect on Hibernate 6.2
@SuppressWarnings("deprecation") // for OracleDialect on Hibernate 5.6 and DerbyDialect/PostgreSQLDialect on Hibernate 6.2
@Nullable
protected Class<?> determineDatabaseDialectClass(Database database) {
if (oldDialectsPresent) { // Hibernate <6.2
@ -204,7 +203,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
case HANA -> HANAColumnStoreDialect.class;
case HSQL -> HSQLDialect.class;
case MYSQL -> MySQLDialect.class;
case ORACLE -> OracleDialect.class;
case ORACLE -> org.hibernate.dialect.OracleDialect.class;
case POSTGRESQL -> org.hibernate.dialect.PostgreSQLDialect.class;
case SQL_SERVER -> SQLServerDialect.class;
case SYBASE -> SybaseDialect.class;