@@ -23,6 +23,7 @@ import org.bson.codecs.DecoderContext
23
23
import org.bson.codecs.EncoderContext
24
24
import org.bson.codecs.configuration.CodecConfigurationException
25
25
import org.bson.codecs.configuration.CodecRegistries.fromProviders
26
+ import org.bson.codecs.kotlin.samples.Box
26
27
import org.bson.codecs.kotlin.samples.DataClassEmbedded
27
28
import org.bson.codecs.kotlin.samples.DataClassListOfDataClasses
28
29
import org.bson.codecs.kotlin.samples.DataClassListOfListOfDataClasses
@@ -55,6 +56,7 @@ import org.bson.codecs.kotlin.samples.DataClassWithMutableMap
55
56
import org.bson.codecs.kotlin.samples.DataClassWithMutableSet
56
57
import org.bson.codecs.kotlin.samples.DataClassWithNestedParameterized
57
58
import org.bson.codecs.kotlin.samples.DataClassWithNestedParameterizedDataClass
59
+ import org.bson.codecs.kotlin.samples.DataClassWithNullableGeneric
58
60
import org.bson.codecs.kotlin.samples.DataClassWithNulls
59
61
import org.bson.codecs.kotlin.samples.DataClassWithObjectIdAndBsonDocument
60
62
import org.bson.codecs.kotlin.samples.DataClassWithPair
@@ -131,6 +133,25 @@ class DataClassCodecTest {
131
133
assertDecodesTo(withStoredNulls, dataClass)
132
134
}
133
135
136
+ @Test
137
+ fun testDataClassWithNullableGenericsNotNull () {
138
+ val expected =
139
+ """ {
140
+ | "box": {"boxed": "String"}
141
+ |}"""
142
+ .trimMargin()
143
+
144
+ val dataClass = DataClassWithNullableGeneric (Box (" String" ))
145
+ assertRoundTrips(expected, dataClass)
146
+ }
147
+
148
+ @Test
149
+ fun testDataClassWithNullableGenericsNull () {
150
+ val expected = """ {"box": {}}"""
151
+ val dataClass = DataClassWithNullableGeneric (Box (null ))
152
+ assertRoundTrips(expected, dataClass)
153
+ }
154
+
134
155
@Test
135
156
fun testDataClassSelfReferential () {
136
157
val expected =
0 commit comments