From b2eaa7c1c3025dddd197df62a46d80ee2a84b8dd Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 2 Sep 2021 22:59:33 +0200 Subject: [PATCH] Polishing --- .../beans/BeanWrapperAutoGrowingTests.java | 2 +- .../beans/BeanWrapperGenericsTests.java | 52 ++++++++----------- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java index 2dddf884e3..78524e632b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java @@ -38,7 +38,7 @@ public class BeanWrapperAutoGrowingTests { @BeforeEach - public void setUp() { + public void setup() { wrapper.setAutoGrowNestedPaths(true); } diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java index f5fef0b04a..760e98cf93 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java @@ -16,7 +16,6 @@ package org.springframework.beans; -import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -85,7 +84,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericList() throws MalformedURLException { + void testGenericList() throws Exception { GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); List input = new ArrayList<>(); @@ -97,7 +96,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericListElement() throws MalformedURLException { + void testGenericListElement() throws Exception { GenericBean gb = new GenericBean<>(); gb.setResourceList(new ArrayList<>()); BeanWrapper bw = new BeanWrapperImpl(gb); @@ -162,10 +161,8 @@ class BeanWrapperGenericsTests { value2.add(Boolean.TRUE); input.put("2", value2); bw.setPropertyValue("collectionMap", input); - boolean condition1 = gb.getCollectionMap().get(1) instanceof HashSet; - assertThat(condition1).isTrue(); - boolean condition = gb.getCollectionMap().get(2) instanceof ArrayList; - assertThat(condition).isTrue(); + assertThat(gb.getCollectionMap().get(1) instanceof HashSet).isTrue(); + assertThat(gb.getCollectionMap().get(2) instanceof ArrayList).isTrue(); } @Test @@ -177,8 +174,7 @@ class BeanWrapperGenericsTests { HashSet value1 = new HashSet<>(); value1.add(1); bw.setPropertyValue("collectionMap[1]", value1); - boolean condition = gb.getCollectionMap().get(1) instanceof HashSet; - assertThat(condition).isTrue(); + assertThat(gb.getCollectionMap().get(1) instanceof HashSet).isTrue(); } @Test @@ -194,7 +190,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericListOfLists() throws MalformedURLException { + void testGenericListOfLists() { GenericBean gb = new GenericBean<>(); List> list = new ArrayList<>(); list.add(new ArrayList<>()); @@ -206,7 +202,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericListOfListsWithElementConversion() throws MalformedURLException { + void testGenericListOfListsWithElementConversion() { GenericBean gb = new GenericBean<>(); List> list = new ArrayList<>(); list.add(new ArrayList<>()); @@ -218,7 +214,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericListOfArrays() throws MalformedURLException { + void testGenericListOfArrays() { GenericBean gb = new GenericBean<>(); ArrayList list = new ArrayList<>(); list.add(new String[] {"str1", "str2"}); @@ -230,7 +226,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericListOfArraysWithElementConversion() throws MalformedURLException { + void testGenericListOfArraysWithElementConversion() { GenericBean gb = new GenericBean<>(); ArrayList list = new ArrayList<>(); list.add(new String[] {"str1", "str2"}); @@ -243,7 +239,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericListOfMaps() throws MalformedURLException { + void testGenericListOfMaps() { GenericBean gb = new GenericBean<>(); List> list = new ArrayList<>(); list.add(new HashMap<>()); @@ -267,7 +263,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericMapOfMaps() throws MalformedURLException { + void testGenericMapOfMaps() { GenericBean gb = new GenericBean<>(); Map> map = new HashMap<>(); map.put("mykey", new HashMap<>()); @@ -279,7 +275,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericMapOfMapsWithElementConversion() throws MalformedURLException { + void testGenericMapOfMapsWithElementConversion() { GenericBean gb = new GenericBean<>(); Map> map = new HashMap<>(); map.put("mykey", new HashMap<>()); @@ -291,7 +287,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericMapOfLists() throws MalformedURLException { + void testGenericMapOfLists() { GenericBean gb = new GenericBean<>(); Map> map = new HashMap<>(); map.put(1, new ArrayList<>()); @@ -303,7 +299,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericMapOfListsWithElementConversion() throws MalformedURLException { + void testGenericMapOfListsWithElementConversion() { GenericBean gb = new GenericBean<>(); Map> map = new HashMap<>(); map.put(1, new ArrayList<>()); @@ -315,7 +311,7 @@ class BeanWrapperGenericsTests { } @Test - void testGenericTypeNestingMapOfInteger() throws Exception { + void testGenericTypeNestingMapOfInteger() { Map map = new HashMap<>(); map.put("testKey", "100"); @@ -324,12 +320,11 @@ class BeanWrapperGenericsTests { bw.setPropertyValue("mapOfInteger", map); Object obj = gb.getMapOfInteger().get("testKey"); - boolean condition = obj instanceof Integer; - assertThat(condition).isTrue(); + assertThat(obj instanceof Integer).isTrue(); } @Test - void testGenericTypeNestingMapOfListOfInteger() throws Exception { + void testGenericTypeNestingMapOfListOfInteger() { Map> map = new HashMap<>(); List list = Arrays.asList("1", "2", "3"); map.put("testKey", list); @@ -339,13 +334,12 @@ class BeanWrapperGenericsTests { bw.setPropertyValue("mapOfListOfInteger", map); Object obj = gb.getMapOfListOfInteger().get("testKey").get(0); - boolean condition = obj instanceof Integer; - assertThat(condition).isTrue(); + assertThat(obj instanceof Integer).isTrue(); assertThat(((Integer) obj).intValue()).isEqualTo(1); } @Test - void testGenericTypeNestingListOfMapOfInteger() throws Exception { + void testGenericTypeNestingListOfMapOfInteger() { List> list = new ArrayList<>(); Map map = new HashMap<>(); map.put("testKey", "5"); @@ -356,13 +350,12 @@ class BeanWrapperGenericsTests { bw.setPropertyValue("listOfMapOfInteger", list); Object obj = gb.getListOfMapOfInteger().get(0).get("testKey"); - boolean condition = obj instanceof Integer; - assertThat(condition).isTrue(); + assertThat(obj instanceof Integer).isTrue(); assertThat(((Integer) obj).intValue()).isEqualTo(5); } @Test - void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception { + void testGenericTypeNestingMapOfListOfListOfInteger() { Map>> map = new HashMap<>(); List list = Arrays.asList("1", "2", "3"); map.put("testKey", Collections.singletonList(list)); @@ -372,8 +365,7 @@ class BeanWrapperGenericsTests { bw.setPropertyValue("mapOfListOfListOfInteger", map); Object obj = gb.getMapOfListOfListOfInteger().get("testKey").get(0).get(0); - boolean condition = obj instanceof Integer; - assertThat(condition).isTrue(); + assertThat(obj instanceof Integer).isTrue(); assertThat(((Integer) obj).intValue()).isEqualTo(1); }