@@ -69,6 +69,7 @@ class DocumentSpecification extends Specification {
69
69
when :
70
70
Document doc = Document . parse(" {x: 1, y: ['two', 'three'], z: [{a: 'one'}, {b:2}], w: {a: ['One', 'Two']}}" )
71
71
.append(' numberList' , [10 , 20.5d , 30L ])
72
+ .append(' listWithNullElement' , [10 , null , 20 ])
72
73
List<String > defaultList = [' a' , ' b' , ' c' ]
73
74
74
75
then :
@@ -84,6 +85,9 @@ class DocumentSpecification extends Specification {
84
85
doc. getList(' numberList' , Number ). get(0 ) == 10
85
86
doc. getList(' numberList' , Number ). get(1 ) == 20.5d
86
87
doc. getList(' numberList' , Number ). get(2 ) == 30L
88
+ doc. getList(' listWithNullElement' , Number ). get(0 ) == 10
89
+ doc. getList(' listWithNullElement' , Number ). get(1 ) == null
90
+ doc. getList(' listWithNullElement' , Number ). get(2 ) == 20
87
91
}
88
92
89
93
def ' should return null list when key is not found' () {
@@ -103,6 +107,7 @@ class DocumentSpecification extends Specification {
103
107
doc. getList(' a' , String , defaultList) == defaultList
104
108
}
105
109
110
+
106
111
def ' should throw an exception when the list elements are not objects of the specified class' () {
107
112
given :
108
113
Document doc = Document . parse(' {x: 1, y: [{a: 1}, {b: 2}], z: [1, 2]}' )
0 commit comments