@@ -47,12 +47,14 @@ internal class ClientBulkTest {
4747 fun beforeAll () {
4848 runBlocking {
4949 personCollection.insertOne(Person (1 , " Sandy King" ))
50- personCollection.insertOne(Person (1 ," Freya Polk" ,34 ))
51- objectCollection.insertMany(listOf (
52- Object (1 , " artist easel" ),
53- Object (2 , " keyboard" , " electronic" ),
54- Object (3 , " blender" ," electronic" ),
55- ) )
50+ personCollection.insertOne(Person (1 , " Freya Polk" , 34 ))
51+ objectCollection.insertMany(
52+ listOf (
53+ Object (1 , " artist easel" ),
54+ Object (2 , " keyboard" , " electronic" ),
55+ Object (3 , " blender" , " electronic" ),
56+ )
57+ )
5658 }
5759 }
5860
@@ -74,18 +76,20 @@ internal class ClientBulkTest {
7476 // :snippet-start: insert-models
7577 val docsToInsert = mutableListOf<ClientNamespacedWriteModel >()
7678
77- docsToInsert.add(ClientNamespacedWriteModel
78- .insertOne(
79- MongoNamespace (" sample_db" , " people" ),
80- Person (2 , " Julia Smith" )
81- )
79+ docsToInsert.add(
80+ ClientNamespacedWriteModel
81+ .insertOne(
82+ MongoNamespace (" sample_db" , " people" ),
83+ Person (2 , " Julia Smith" )
84+ )
8285 )
8386
84- docsToInsert.add(ClientNamespacedWriteModel
85- .insertOne(
86- MongoNamespace (" sample_db" , " objects" ),
87- Object (2 , " washing machine" )
88- )
87+ docsToInsert.add(
88+ ClientNamespacedWriteModel
89+ .insertOne(
90+ MongoNamespace (" sample_db" , " objects" ),
91+ Object (2 , " washing machine" )
92+ )
8993 )
9094
9195 val clientBulkResult = client.bulkWrite(docsToInsert)
@@ -104,20 +108,22 @@ internal class ClientBulkTest {
104108 // :snippet-start: update-models
105109 val docsToInsert = mutableListOf<ClientNamespacedWriteModel >()
106110
107- docsToInsert.add(ClientNamespacedWriteModel
108- .updateOne(
109- MongoNamespace (" sample_db" , " people" ),
110- Filters .eq(Person ::name.name, " Freya Polk" ),
111- Updates .inc(Person ::age.name, 1 )
112- )
111+ docsToInsert.add(
112+ ClientNamespacedWriteModel
113+ .updateOne(
114+ MongoNamespace (" sample_db" , " people" ),
115+ Filters .eq(Person ::name.name, " Freya Polk" ),
116+ Updates .inc(Person ::age.name, 1 )
117+ )
113118 )
114119
115- docsToInsert.add(ClientNamespacedWriteModel
116- .updateMany(
117- MongoNamespace (" sample_db" , " objects" ),
118- Filters .eq(Object ::category.name, " electronic" ),
119- Updates .set(Object ::manufacturer.name, " Premium Technologies" )
120- )
120+ docsToInsert.add(
121+ ClientNamespacedWriteModel
122+ .updateMany(
123+ MongoNamespace (" sample_db" , " objects" ),
124+ Filters .eq(Object ::category.name, " electronic" ),
125+ Updates .set(Object ::manufacturer.name, " Premium Technologies" )
126+ )
121127 )
122128
123129 val clientBulkResult = client.bulkWrite(docsToInsert)
@@ -132,20 +138,22 @@ internal class ClientBulkTest {
132138 // :snippet-start: replace-models
133139 val docsReplacements = mutableListOf<ClientNamespacedWriteModel >()
134140
135- docsReplacements.add(ClientNamespacedWriteModel
136- .replaceOne(
137- MongoNamespace (" sample_db" , " people" ),
138- Filters .eq(Person ::id.name, 1 ),
139- Person (1 , " Frederic Hilbert" )
140- )
141+ docsReplacements.add(
142+ ClientNamespacedWriteModel
143+ .replaceOne(
144+ MongoNamespace (" sample_db" , " people" ),
145+ Filters .eq(Person ::id.name, 1 ),
146+ Person (1 , " Frederic Hilbert" )
147+ )
141148 )
142149
143- docsReplacements.add(ClientNamespacedWriteModel
144- .replaceOne(
145- MongoNamespace (" sample_db" , " objects" ),
146- Filters .eq(Object ::id.name, 1 ),
147- Object (1 , " ironing board" )
148- )
150+ docsReplacements.add(
151+ ClientNamespacedWriteModel
152+ .replaceOne(
153+ MongoNamespace (" sample_db" , " objects" ),
154+ Filters .eq(Object ::id.name, 1 ),
155+ Object (1 , " ironing board" )
156+ )
149157 )
150158
151159 val clientBulkResult = client.bulkWrite(docsReplacements)
0 commit comments