From f768641c080a1352e2bb2b5cf64ad1a867769046 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:50:45 +0200 Subject: [PATCH] Polish contribution See gh-37254 --- .../CollectionToCollectionConverterTests.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java index 806949f278f..125631b7234 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java @@ -162,23 +162,20 @@ class CollectionToCollectionConverterTests { @Test void convertEmptyVector_shouldReturnEmptyArrayList() { - Vector vector = new Vector<>(); - CollectionToCollectionConverter converter = new CollectionToCollectionConverter(new GenericConversionService()); - Object convertedValue = converter.convert( - vector, TypeDescriptor.forObject(vector), TypeDescriptor.valueOf(ArrayList.class)); - assertThat(convertedValue).isInstanceOf(ArrayList.class); - assertThat(convertedValue).asInstanceOf(LIST).isEmpty(); + Object convertedValue = convertVectorToArrayList(new Vector<>()); + assertThat(convertedValue) + .isInstanceOf(ArrayList.class) + .asInstanceOf(LIST).isEmpty(); } @Test void convertNonEmptyVector_shouldReturnNonEmptyArrayList() { Vector vector = new Vector<>(); vector.add("Element"); - CollectionToCollectionConverter converter = new CollectionToCollectionConverter(new GenericConversionService()); - Object convertedValue = converter.convert( - vector, TypeDescriptor.forObject(vector), TypeDescriptor.valueOf(ArrayList.class)); - assertThat(convertedValue).isInstanceOf(ArrayList.class); - assertThat(convertedValue).asInstanceOf(LIST).isNotEmpty(); + Object convertedValue = convertVectorToArrayList(vector); + assertThat(convertedValue) + .isInstanceOf(ArrayList.class) + .asInstanceOf(LIST).containsOnly("Element"); } @Test @@ -255,6 +252,12 @@ class CollectionToCollectionConverterTests { } + private static Object convertVectorToArrayList(Vector vector) { + CollectionToCollectionConverter converter = new CollectionToCollectionConverter(new GenericConversionService()); + return converter.convert(vector, TypeDescriptor.forObject(vector), TypeDescriptor.valueOf(ArrayList.class)); + } + + public ArrayList scalarListTarget; public List emptyListTarget;