@@ -95,7 +95,9 @@ class SdkScalaTypeTest {
95
95
datetime : SdkBindingData [Instant ],
96
96
duration : SdkBindingData [Duration ],
97
97
blob : SdkBindingData [Blob ],
98
- generic : SdkBindingData [ScalarNested ]
98
+ generic : SdkBindingData [ScalarNested ],
99
+ none : SdkBindingData [Option [String ]],
100
+ some : SdkBindingData [Option [String ]]
99
101
)
100
102
101
103
case class CollectionInput (
@@ -105,7 +107,8 @@ class SdkScalaTypeTest {
105
107
booleans : SdkBindingData [List [Boolean ]],
106
108
datetimes : SdkBindingData [List [Instant ]],
107
109
durations : SdkBindingData [List [Duration ]],
108
- generics : SdkBindingData [List [ScalarNested ]]
110
+ generics : SdkBindingData [List [ScalarNested ]],
111
+ options : SdkBindingData [List [Option [String ]]]
109
112
)
110
113
111
114
case class MapInput (
@@ -115,7 +118,8 @@ class SdkScalaTypeTest {
115
118
booleanMap : SdkBindingData [Map [String , Boolean ]],
116
119
datetimeMap : SdkBindingData [Map [String , Instant ]],
117
120
durationMap : SdkBindingData [Map [String , Duration ]],
118
- genericMap : SdkBindingData [Map [String , ScalarNested ]]
121
+ genericMap : SdkBindingData [Map [String , ScalarNested ]],
122
+ optionMap : SdkBindingData [Map [String , Option [String ]]]
119
123
)
120
124
121
125
case class ComplexInput (
@@ -196,7 +200,9 @@ class SdkScalaTypeTest {
196
200
.literalType(LiteralType .ofBlobType(BlobType .DEFAULT ))
197
201
.description(" " )
198
202
.build(),
199
- " generic" -> createVar(SimpleType .STRUCT )
203
+ " generic" -> createVar(SimpleType .STRUCT ),
204
+ " none" -> createVar(SimpleType .STRUCT ),
205
+ " some" -> createVar(SimpleType .STRUCT )
200
206
).asJava
201
207
202
208
val output = SdkScalaType [ScalarInput ].getVariableMap
@@ -274,6 +280,16 @@ class SdkScalaTypeTest {
274
280
).asJava
275
281
)
276
282
)
283
+ ),
284
+ " none" -> Literal .ofScalar(
285
+ Scalar .ofGeneric(
286
+ Struct .of(Map .empty[String , Struct .Value ].asJava)
287
+ )
288
+ ),
289
+ " some" -> Literal .ofScalar(
290
+ Scalar .ofGeneric(
291
+ Struct .of(Map (" value" -> Struct .Value .ofStringValue(" hello" )).asJava)
292
+ )
277
293
)
278
294
).asJava
279
295
@@ -295,6 +311,14 @@ class SdkScalaTypeTest {
295
311
List (ScalarNestedNested (" foo" , Some (" bar" ))),
296
312
Map (" foo" -> ScalarNestedNested (" foo" , Some (" bar" )))
297
313
)
314
+ ),
315
+ none = SdkBindingDataFactory .of(
316
+ SdkLiteralTypes .generics[Option [String ]](),
317
+ Option (null )
318
+ ),
319
+ some = SdkBindingDataFactory .of(
320
+ SdkLiteralTypes .generics[Option [String ]](),
321
+ Option (" hello" )
298
322
)
299
323
)
300
324
@@ -323,7 +347,11 @@ class SdkScalaTypeTest {
323
347
List (ScalarNestedNested (" foo" , Some (" bar" ))),
324
348
Map (" foo" -> ScalarNestedNested (" foo" , Some (" bar" )))
325
349
)
326
- )
350
+ ),
351
+ none =
352
+ SdkBindingDataFactory .of(SdkLiteralTypes .generics(), Option (null )),
353
+ some =
354
+ SdkBindingDataFactory .of(SdkLiteralTypes .generics(), Option (" hello" ))
327
355
)
328
356
329
357
val expected = Map (
@@ -399,6 +427,23 @@ class SdkScalaTypeTest {
399
427
).asJava
400
428
)
401
429
)
430
+ ),
431
+ " none" -> Literal .ofScalar(
432
+ Scalar .ofGeneric(
433
+ Struct .of(
434
+ Map (__TYPE -> Struct .Value .ofStringValue(" scala.None$" )).asJava
435
+ )
436
+ )
437
+ ),
438
+ " some" -> Literal .ofScalar(
439
+ Scalar .ofGeneric(
440
+ Struct .of(
441
+ Map (
442
+ " value" -> Struct .Value .ofStringValue(" hello" ),
443
+ __TYPE -> Struct .Value .ofStringValue(" scala.Some" )
444
+ ).asJava
445
+ )
446
+ )
402
447
)
403
448
).asJava
404
449
@@ -416,7 +461,8 @@ class SdkScalaTypeTest {
416
461
" booleans" -> createCollectionVar(SimpleType .BOOLEAN ),
417
462
" datetimes" -> createCollectionVar(SimpleType .DATETIME ),
418
463
" durations" -> createCollectionVar(SimpleType .DURATION ),
419
- " generics" -> createCollectionVar(SimpleType .STRUCT )
464
+ " generics" -> createCollectionVar(SimpleType .STRUCT ),
465
+ " options" -> createCollectionVar(SimpleType .STRUCT )
420
466
).asJava
421
467
422
468
val output = SdkScalaType [CollectionInput ].getVariableMap
@@ -443,6 +489,14 @@ class SdkScalaTypeTest {
443
489
List (ScalarNestedNested (" foo" , Some (" bar" ))),
444
490
Map (" foo" -> ScalarNestedNested (" foo" , Some (" bar" )))
445
491
)
492
+ ),
493
+ none = SdkBindingDataFactory .of(
494
+ SdkLiteralTypes .generics[Option [String ]](),
495
+ Option (null )
496
+ ),
497
+ some = SdkBindingDataFactory .of(
498
+ SdkLiteralTypes .generics[Option [String ]](),
499
+ Option (" hello" )
446
500
)
447
501
)
448
502
@@ -465,6 +519,14 @@ class SdkScalaTypeTest {
465
519
List (ScalarNestedNested (" foo" , Some (" bar" ))),
466
520
Map (" foo" -> ScalarNestedNested (" foo" , Some (" bar" )))
467
521
)
522
+ ),
523
+ " none" -> SdkBindingDataFactory .of(
524
+ SdkLiteralTypes .generics[Option [String ]](),
525
+ Option (null )
526
+ ),
527
+ " some" -> SdkBindingDataFactory .of(
528
+ SdkLiteralTypes .generics[Option [String ]](),
529
+ Option (" hello" )
468
530
)
469
531
).asJava
470
532
@@ -531,6 +593,10 @@ class SdkScalaTypeTest {
531
593
Map (" foo2" -> ScalarNestedNested (" foo2" , Some (" bar2" )))
532
594
)
533
595
)
596
+ ),
597
+ options = SdkBindingDataFactory .of(
598
+ SdkLiteralTypes .generics[Option [String ]](),
599
+ List (Option (" hello" ), Option (null ))
534
600
)
535
601
)
536
602
@@ -550,7 +616,8 @@ class SdkScalaTypeTest {
550
616
" booleanMap" -> createMapVar(SimpleType .BOOLEAN ),
551
617
" datetimeMap" -> createMapVar(SimpleType .DATETIME ),
552
618
" durationMap" -> createMapVar(SimpleType .DURATION ),
553
- " genericMap" -> createMapVar(SimpleType .STRUCT )
619
+ " genericMap" -> createMapVar(SimpleType .STRUCT ),
620
+ " optionMap" -> createMapVar(SimpleType .STRUCT )
554
621
).asJava
555
622
556
623
val output = SdkScalaType [MapInput ].getVariableMap
@@ -598,6 +665,10 @@ class SdkScalaTypeTest {
598
665
Map (" foo2" -> ScalarNestedNested (" foo2" , Some (" bar2" )))
599
666
)
600
667
)
668
+ ),
669
+ optionMap = SdkBindingDataFactory .of(
670
+ SdkLiteralTypes .generics[Option [String ]](),
671
+ Map (" none" -> Option (null ), " some" -> Option (" hello" ))
601
672
)
602
673
)
603
674
0 commit comments