Skip to content

Commit 1fc4864

Browse files
Add test for binding a typed array of String to a collection of domain objects
1 parent 1d5abd2 commit 1fc4864

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

grails-test-suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/GrailsWebDataBinderSpec.groovy

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,25 @@ class GrailsWebDataBinderSpec extends Specification {
11881188
obj.objectIds[3] instanceof ObjectId
11891189
obj.objectIds[3].value == 'eight'
11901190
}
1191+
1192+
void 'Test binding to a typed array of non-domain objects'() {
1193+
given:
1194+
def obj = new DocumentHolder()
1195+
1196+
when:
1197+
binder.bind obj, [objectIds: ['two', 'four', 'six', 'eight'] as String[]] as SimpleMapDataBindingSource
1198+
1199+
then:
1200+
obj.objectIds.size() == 4
1201+
obj.objectIds[0] instanceof ObjectId
1202+
obj.objectIds[0].value == 'two'
1203+
obj.objectIds[1] instanceof ObjectId
1204+
obj.objectIds[1].value == 'four'
1205+
obj.objectIds[2] instanceof ObjectId
1206+
obj.objectIds[2].value == 'six'
1207+
obj.objectIds[3] instanceof ObjectId
1208+
obj.objectIds[3].value == 'eight'
1209+
}
11911210
}
11921211

11931212
@Entity

0 commit comments

Comments
 (0)