Add TestUtils.propertyValue() based on generics#3305
Add TestUtils.propertyValue() based on generics#3305cppwfs merged 4 commits intospring-projects:mainfrom
TestUtils.propertyValue() based on generics#3305Conversation
* Deprecate `TestUtils.getPropertyValue()` based on a `Class` param
* Optimize `TestUtils.getPropertyValue()` to not create extra `DirectFieldAccessor`
if we are at the end of the nested path
* Refactor project code to use a new `TestUtils.propertyValue()`
* Remove unnecessary now `@SuppressWarnings("unchecked")` from those tests
* Some other code clean up in affected test classes
|
A lot of changes in this PR are about migrating from deprecated API. |
|
Now, when I look into this from PR perspective, it feels like we don't need that |
cppwfs
left a comment
There was a problem hiding this comment.
Nice update to TestUtils! Made the test code easier to read. Great cleanup work!
spring-amqp/src/main/java/org/springframework/amqp/utils/test/TestUtils.java
Outdated
Show resolved
Hide resolved
spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/AdminParserTests.java
Outdated
Show resolved
Hide resolved
spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/AdminParserTests.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactoryTests.java
Show resolved
Hide resolved
spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/SSLConnectionTests.java
Outdated
Show resolved
Hide resolved
Turned out we don't need a new method with generics. And we don't need an extra argument to resolve the type. There is just enough to have a simple cast to generic argument. In the end we are talking only about tests. * Remove redundant (just created `TestUtils.propertyValue()`) * Change `TestUtils.getPropertyValue()` signature for generic argument * Refactor affected tests With a new style we don't have a paradox of choice for this or that method. The generic argument on the method is enough to cover all use-cases, even if we have to add `<Object>` to satisfy `assertThat()` expectations. We don't need an extra `Class` argument to verify value compatibility. The simple cast to generic type is enough got tests environment. This is slightly breaking change in the API, but that is only for tests anyway
|
OK. I've changed my mind and now it is not a new Thanks |
TestUtils.getPropertyValue()based on aClassparamTestUtils.getPropertyValue()to not create extraDirectFieldAccessorif we are at the end of the nested pathTestUtils.propertyValue()@SuppressWarnings("unchecked")from those tests