Polishing
This commit is contained in:
@@ -38,7 +38,7 @@ public class BeanWrapperAutoGrowingTests {
|
|||||||
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setup() {
|
||||||
wrapper.setAutoGrowNestedPaths(true);
|
wrapper.setAutoGrowNestedPaths(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.springframework.beans;
|
package org.springframework.beans;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -85,7 +84,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericList() throws MalformedURLException {
|
void testGenericList() throws Exception {
|
||||||
GenericBean<?> gb = new GenericBean<>();
|
GenericBean<?> gb = new GenericBean<>();
|
||||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||||
List<String> input = new ArrayList<>();
|
List<String> input = new ArrayList<>();
|
||||||
@@ -97,7 +96,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericListElement() throws MalformedURLException {
|
void testGenericListElement() throws Exception {
|
||||||
GenericBean<?> gb = new GenericBean<>();
|
GenericBean<?> gb = new GenericBean<>();
|
||||||
gb.setResourceList(new ArrayList<>());
|
gb.setResourceList(new ArrayList<>());
|
||||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||||
@@ -162,10 +161,8 @@ class BeanWrapperGenericsTests {
|
|||||||
value2.add(Boolean.TRUE);
|
value2.add(Boolean.TRUE);
|
||||||
input.put("2", value2);
|
input.put("2", value2);
|
||||||
bw.setPropertyValue("collectionMap", input);
|
bw.setPropertyValue("collectionMap", input);
|
||||||
boolean condition1 = gb.getCollectionMap().get(1) instanceof HashSet;
|
assertThat(gb.getCollectionMap().get(1) instanceof HashSet).isTrue();
|
||||||
assertThat(condition1).isTrue();
|
assertThat(gb.getCollectionMap().get(2) instanceof ArrayList).isTrue();
|
||||||
boolean condition = gb.getCollectionMap().get(2) instanceof ArrayList;
|
|
||||||
assertThat(condition).isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -177,8 +174,7 @@ class BeanWrapperGenericsTests {
|
|||||||
HashSet<Integer> value1 = new HashSet<>();
|
HashSet<Integer> value1 = new HashSet<>();
|
||||||
value1.add(1);
|
value1.add(1);
|
||||||
bw.setPropertyValue("collectionMap[1]", value1);
|
bw.setPropertyValue("collectionMap[1]", value1);
|
||||||
boolean condition = gb.getCollectionMap().get(1) instanceof HashSet;
|
assertThat(gb.getCollectionMap().get(1) instanceof HashSet).isTrue();
|
||||||
assertThat(condition).isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -194,7 +190,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericListOfLists() throws MalformedURLException {
|
void testGenericListOfLists() {
|
||||||
GenericBean<String> gb = new GenericBean<>();
|
GenericBean<String> gb = new GenericBean<>();
|
||||||
List<List<Integer>> list = new ArrayList<>();
|
List<List<Integer>> list = new ArrayList<>();
|
||||||
list.add(new ArrayList<>());
|
list.add(new ArrayList<>());
|
||||||
@@ -206,7 +202,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericListOfListsWithElementConversion() throws MalformedURLException {
|
void testGenericListOfListsWithElementConversion() {
|
||||||
GenericBean<String> gb = new GenericBean<>();
|
GenericBean<String> gb = new GenericBean<>();
|
||||||
List<List<Integer>> list = new ArrayList<>();
|
List<List<Integer>> list = new ArrayList<>();
|
||||||
list.add(new ArrayList<>());
|
list.add(new ArrayList<>());
|
||||||
@@ -218,7 +214,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericListOfArrays() throws MalformedURLException {
|
void testGenericListOfArrays() {
|
||||||
GenericBean<String> gb = new GenericBean<>();
|
GenericBean<String> gb = new GenericBean<>();
|
||||||
ArrayList<String[]> list = new ArrayList<>();
|
ArrayList<String[]> list = new ArrayList<>();
|
||||||
list.add(new String[] {"str1", "str2"});
|
list.add(new String[] {"str1", "str2"});
|
||||||
@@ -230,7 +226,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericListOfArraysWithElementConversion() throws MalformedURLException {
|
void testGenericListOfArraysWithElementConversion() {
|
||||||
GenericBean<String> gb = new GenericBean<>();
|
GenericBean<String> gb = new GenericBean<>();
|
||||||
ArrayList<String[]> list = new ArrayList<>();
|
ArrayList<String[]> list = new ArrayList<>();
|
||||||
list.add(new String[] {"str1", "str2"});
|
list.add(new String[] {"str1", "str2"});
|
||||||
@@ -243,7 +239,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericListOfMaps() throws MalformedURLException {
|
void testGenericListOfMaps() {
|
||||||
GenericBean<String> gb = new GenericBean<>();
|
GenericBean<String> gb = new GenericBean<>();
|
||||||
List<Map<Integer, Long>> list = new ArrayList<>();
|
List<Map<Integer, Long>> list = new ArrayList<>();
|
||||||
list.add(new HashMap<>());
|
list.add(new HashMap<>());
|
||||||
@@ -267,7 +263,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericMapOfMaps() throws MalformedURLException {
|
void testGenericMapOfMaps() {
|
||||||
GenericBean<String> gb = new GenericBean<>();
|
GenericBean<String> gb = new GenericBean<>();
|
||||||
Map<String, Map<Integer, Long>> map = new HashMap<>();
|
Map<String, Map<Integer, Long>> map = new HashMap<>();
|
||||||
map.put("mykey", new HashMap<>());
|
map.put("mykey", new HashMap<>());
|
||||||
@@ -279,7 +275,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericMapOfMapsWithElementConversion() throws MalformedURLException {
|
void testGenericMapOfMapsWithElementConversion() {
|
||||||
GenericBean<String> gb = new GenericBean<>();
|
GenericBean<String> gb = new GenericBean<>();
|
||||||
Map<String, Map<Integer, Long>> map = new HashMap<>();
|
Map<String, Map<Integer, Long>> map = new HashMap<>();
|
||||||
map.put("mykey", new HashMap<>());
|
map.put("mykey", new HashMap<>());
|
||||||
@@ -291,7 +287,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericMapOfLists() throws MalformedURLException {
|
void testGenericMapOfLists() {
|
||||||
GenericBean<String> gb = new GenericBean<>();
|
GenericBean<String> gb = new GenericBean<>();
|
||||||
Map<Integer, List<Integer>> map = new HashMap<>();
|
Map<Integer, List<Integer>> map = new HashMap<>();
|
||||||
map.put(1, new ArrayList<>());
|
map.put(1, new ArrayList<>());
|
||||||
@@ -303,7 +299,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericMapOfListsWithElementConversion() throws MalformedURLException {
|
void testGenericMapOfListsWithElementConversion() {
|
||||||
GenericBean<String> gb = new GenericBean<>();
|
GenericBean<String> gb = new GenericBean<>();
|
||||||
Map<Integer, List<Integer>> map = new HashMap<>();
|
Map<Integer, List<Integer>> map = new HashMap<>();
|
||||||
map.put(1, new ArrayList<>());
|
map.put(1, new ArrayList<>());
|
||||||
@@ -315,7 +311,7 @@ class BeanWrapperGenericsTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericTypeNestingMapOfInteger() throws Exception {
|
void testGenericTypeNestingMapOfInteger() {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("testKey", "100");
|
map.put("testKey", "100");
|
||||||
|
|
||||||
@@ -324,12 +320,11 @@ class BeanWrapperGenericsTests {
|
|||||||
bw.setPropertyValue("mapOfInteger", map);
|
bw.setPropertyValue("mapOfInteger", map);
|
||||||
|
|
||||||
Object obj = gb.getMapOfInteger().get("testKey");
|
Object obj = gb.getMapOfInteger().get("testKey");
|
||||||
boolean condition = obj instanceof Integer;
|
assertThat(obj instanceof Integer).isTrue();
|
||||||
assertThat(condition).isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericTypeNestingMapOfListOfInteger() throws Exception {
|
void testGenericTypeNestingMapOfListOfInteger() {
|
||||||
Map<String, List<String>> map = new HashMap<>();
|
Map<String, List<String>> map = new HashMap<>();
|
||||||
List<String> list = Arrays.asList("1", "2", "3");
|
List<String> list = Arrays.asList("1", "2", "3");
|
||||||
map.put("testKey", list);
|
map.put("testKey", list);
|
||||||
@@ -339,13 +334,12 @@ class BeanWrapperGenericsTests {
|
|||||||
bw.setPropertyValue("mapOfListOfInteger", map);
|
bw.setPropertyValue("mapOfListOfInteger", map);
|
||||||
|
|
||||||
Object obj = gb.getMapOfListOfInteger().get("testKey").get(0);
|
Object obj = gb.getMapOfListOfInteger().get("testKey").get(0);
|
||||||
boolean condition = obj instanceof Integer;
|
assertThat(obj instanceof Integer).isTrue();
|
||||||
assertThat(condition).isTrue();
|
|
||||||
assertThat(((Integer) obj).intValue()).isEqualTo(1);
|
assertThat(((Integer) obj).intValue()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericTypeNestingListOfMapOfInteger() throws Exception {
|
void testGenericTypeNestingListOfMapOfInteger() {
|
||||||
List<Map<String, String>> list = new ArrayList<>();
|
List<Map<String, String>> list = new ArrayList<>();
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("testKey", "5");
|
map.put("testKey", "5");
|
||||||
@@ -356,13 +350,12 @@ class BeanWrapperGenericsTests {
|
|||||||
bw.setPropertyValue("listOfMapOfInteger", list);
|
bw.setPropertyValue("listOfMapOfInteger", list);
|
||||||
|
|
||||||
Object obj = gb.getListOfMapOfInteger().get(0).get("testKey");
|
Object obj = gb.getListOfMapOfInteger().get(0).get("testKey");
|
||||||
boolean condition = obj instanceof Integer;
|
assertThat(obj instanceof Integer).isTrue();
|
||||||
assertThat(condition).isTrue();
|
|
||||||
assertThat(((Integer) obj).intValue()).isEqualTo(5);
|
assertThat(((Integer) obj).intValue()).isEqualTo(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception {
|
void testGenericTypeNestingMapOfListOfListOfInteger() {
|
||||||
Map<String, List<List<String>>> map = new HashMap<>();
|
Map<String, List<List<String>>> map = new HashMap<>();
|
||||||
List<String> list = Arrays.asList("1", "2", "3");
|
List<String> list = Arrays.asList("1", "2", "3");
|
||||||
map.put("testKey", Collections.singletonList(list));
|
map.put("testKey", Collections.singletonList(list));
|
||||||
@@ -372,8 +365,7 @@ class BeanWrapperGenericsTests {
|
|||||||
bw.setPropertyValue("mapOfListOfListOfInteger", map);
|
bw.setPropertyValue("mapOfListOfListOfInteger", map);
|
||||||
|
|
||||||
Object obj = gb.getMapOfListOfListOfInteger().get("testKey").get(0).get(0);
|
Object obj = gb.getMapOfListOfListOfInteger().get("testKey").get(0).get(0);
|
||||||
boolean condition = obj instanceof Integer;
|
assertThat(obj instanceof Integer).isTrue();
|
||||||
assertThat(condition).isTrue();
|
|
||||||
assertThat(((Integer) obj).intValue()).isEqualTo(1);
|
assertThat(((Integer) obj).intValue()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user