Skip to content

Commit 9f80820

Browse files
authored
(DOCSP-29899): Ready site for MVP publish (#67)
# Pull Request Info [PR Reviewing Guidelines](https://github.com/mongodb/docs-java/blob/master/REVIEWING.md) JIRA - https://jira.mongodb.org/browse/DOCSP-29899 Staging - https://docs-mongodbcom-staging.corp.mongodb.com/kotlin/docsworker-xlarge/DOCSP-29899/ ## Self-Review Checklist - [ ] Is this free of any warnings or errors in the RST? - [ ] Did you run a spell-check? - [ ] Did you run a grammar-check? - [ ] Are all the links working?
1 parent 62284b2 commit 9f80820

File tree

134 files changed

+309
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+309
-209
lines changed

examples/src/test/kotlin/AggregationTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class AggregationTest {
8282
Accumulators.sum("count", 1))
8383
)
8484
)
85+
8586
resultsFlow.collect { println(it) }
8687
// :snippet-end:
8788

@@ -110,6 +111,7 @@ class AggregationTest {
110111
)
111112
)
112113
)
114+
113115
resultsFlow.collect { println(it) }
114116
// :snippet-end:
115117
val results = resultsFlow.toList()
@@ -130,6 +132,7 @@ class AggregationTest {
130132
Aggregates.group("\$${Restaurant::stars.name}", Accumulators.sum("count", 1))
131133
)
132134
).explain(ExplainVerbosity.EXECUTION_STATS)
135+
133136
// Prettyprint the output
134137
println(explanation.toJson(JsonWriterSettings.builder().indent(true).build()))
135138
// :snippet-end:
@@ -143,7 +146,7 @@ class AggregationTest {
143146
// :snippet-start: build-documents-tip
144147
Document("\$arrayElemAt", listOf("\$categories", 0))
145148
// is equivalent to
146-
val method2 = // :remove
149+
val method2 = // :remove:
147150
Document.parse("{ \$arrayElemAt: ['\$categories', 0] }")
148151
// :snippet-end:
149152
// assert to test equivalency

examples/src/test/kotlin/BuildersTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal class BuildersTest {
3737

3838
@BeforeAll
3939
@JvmStatic
40-
private fun beforeAll() {
40+
fun beforeAll() {
4141
runBlocking {
4242
val users = listOf(
4343
User(BsonObjectId(), "female", 29, "[email protected]"),
@@ -50,7 +50,7 @@ internal class BuildersTest {
5050

5151
@AfterAll
5252
@JvmStatic
53-
private fun afterAll() {
53+
fun afterAll() {
5454
runBlocking {
5555
collection.drop()
5656
client.close()

examples/src/test/kotlin/BulkTest.kt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal class BulkTest {
3030

3131
@BeforeAll
3232
@JvmStatic
33-
private fun beforeAll() {
33+
fun beforeAll() {
3434
runBlocking {
3535
val sampleDocuments = listOf(
3636
SampleDoc(1),
@@ -42,7 +42,7 @@ internal class BulkTest {
4242

4343
@AfterAll
4444
@JvmStatic
45-
private fun afterAll() {
45+
fun afterAll() {
4646
runBlocking {
4747
collection.drop()
4848
client.close()
@@ -117,18 +117,16 @@ internal class BulkTest {
117117
@Test
118118
fun orderOfOperationsTest() = runBlocking {
119119
// :snippet-start: ordered
120-
val doc1: InsertOneModel<SampleDoc> = InsertOneModel(SampleDoc(3))
121-
val doc2: ReplaceOneModel<SampleDoc> = ReplaceOneModel(
120+
val doc1= InsertOneModel(SampleDoc(3))
121+
val doc2 = ReplaceOneModel(
122122
Filters.eq("_id", 1),
123123
SampleDoc(1, 2)
124124
)
125-
val doc3: UpdateOneModel<SampleDoc> =
126-
UpdateOneModel(
125+
val doc3 = UpdateOneModel<SampleDoc>(
127126
Filters.eq("_id", 3),
128127
Updates.set(SampleDoc::x.name, 2)
129128
)
130-
val doc4: DeleteManyModel<SampleDoc> =
131-
DeleteManyModel(Filters.eq(SampleDoc::x.name, 2))
129+
val doc4 = DeleteManyModel<SampleDoc>(Filters.eq(SampleDoc::x.name, 2))
132130

133131
val bulkOperations = listOf(
134132
doc1,
@@ -145,18 +143,16 @@ internal class BulkTest {
145143

146144
@Test
147145
fun unorderedExecutionTest() = runBlocking {
148-
val doc1: InsertOneModel<SampleDoc> = InsertOneModel(SampleDoc(3))
149-
val doc2: ReplaceOneModel<SampleDoc> = ReplaceOneModel(
146+
val doc1 = InsertOneModel(SampleDoc(3))
147+
val doc2 = ReplaceOneModel(
150148
Filters.eq("_id", 1),
151149
SampleDoc(1, 2)
152150
)
153-
val doc3: UpdateOneModel<SampleDoc> =
154-
UpdateOneModel(
151+
val doc3 = UpdateOneModel<SampleDoc>(
155152
Filters.eq("_id", 3),
156153
Updates.set(SampleDoc::x.name, 2)
157154
)
158-
val doc4: DeleteManyModel<SampleDoc> =
159-
DeleteManyModel(Filters.eq(SampleDoc::x.name, 2))
155+
val doc4 = DeleteManyModel<SampleDoc>(Filters.eq(SampleDoc::x.name, 2))
160156

161157
val bulkOperations = listOf(
162158
doc1,

examples/src/test/kotlin/ChangeTest.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal class ChangeTest {
3030

3131
@BeforeAll
3232
@JvmStatic
33-
private fun beforeAll() {
33+
fun beforeAll() {
3434
runBlocking {
3535
val paintOrders = listOf(
3636
PaintOrder(1, "red", 5),
@@ -45,7 +45,7 @@ internal class ChangeTest {
4545

4646
@AfterAll
4747
@JvmStatic
48-
private fun afterAll() {
48+
fun afterAll() {
4949
runBlocking {
5050
collection.drop()
5151
client.close()
@@ -58,6 +58,7 @@ internal class ChangeTest {
5858
val filter = Filters.eq(PaintOrder::color.name, "yellow")
5959
val update = Updates.inc(PaintOrder::qty.name, 1)
6060
val result = collection.updateOne(filter, update)
61+
6162
println("Matched document count: $result.matchedCount")
6263
println("Modified document count: $result.modifiedCount")
6364
// :snippet-end:
@@ -70,6 +71,7 @@ internal class ChangeTest {
7071
val filter = Filters.empty()
7172
val update = Updates.inc(PaintOrder::qty.name, 20)
7273
val result = collection.updateMany(filter, update)
74+
7375
println("Matched document count: $result.matchedCount")
7476
println("Modified document count: $result.modifiedCount")
7577
// :snippet-end:
@@ -83,6 +85,7 @@ internal class ChangeTest {
8385
val filter = Filters.eq(PaintOrder::color.name, "pink")
8486
val update = PaintOrder(5, "orange", 25)
8587
val result = collection.replaceOne(filter, update)
88+
8689
println("Matched document count: $result.matchedCount")
8790
println("Modified document count: $result.modifiedCount")
8891
// :snippet-end:

examples/src/test/kotlin/CompoundTest.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ internal class CompoundOperationsTest {
8181
or null if the document was inserted due to upsert
8282
being true */
8383
val result = collection.findOneAndUpdate(filter, update, options)
84+
8485
println(result)
8586
// :snippet-end:
8687
// Junit test for the above code
@@ -104,6 +105,7 @@ internal class CompoundOperationsTest {
104105
val options = FindOneAndReplaceOptions()
105106
.returnDocument(ReturnDocument.AFTER)
106107
val result = collection.withDocumentClass<Music>().findOneAndReplace(filter, replace, options)
108+
107109
println(result)
108110
// :snippet-end:
109111
assertEquals(replace, result)
@@ -121,7 +123,7 @@ internal class CompoundOperationsTest {
121123
val filter = Filters.empty()
122124
val options = FindOneAndDeleteOptions().sort(sort)
123125
val result = collection.findOneAndDelete(filter, options)
124-
// Returns the deleted document
126+
125127
println(result)
126128
// :snippet-end:
127129
// Junit test for the above code
@@ -140,6 +142,7 @@ internal class CompoundOperationsTest {
140142
}
141143

142144
val myRoomName = myRoom.room
145+
143146
println("You got the $myRoomName, $guestName")
144147

145148
val update = Updates.combine(Updates.set("reserved", true), Updates.set("guest", guestName))
@@ -164,6 +167,7 @@ internal class CompoundOperationsTest {
164167
println("Sorry, we are booked, $guestName")
165168
return
166169
}
170+
167171
val myRoomName = myRoom.room
168172
println("You got the $myRoomName, $guestName")
169173
}

examples/src/test/kotlin/ConnectTest.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import org.junit.jupiter.api.Assertions.*
1010
import org.junit.jupiter.api.TestInstance
1111
import java.util.*
1212
import kotlin.test.*
13-
13+
// :replace-start: {
14+
// "terms": {
15+
// "CONNECTION_URI_PLACEHOLDER": "\"<connection string>\""
16+
// }
17+
// }
1418

1519
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
1620
internal class ConnectionTest {
@@ -89,3 +93,4 @@ internal class ConnectionTest {
8993

9094

9195
}
96+
// :replace-end:

examples/src/test/kotlin/DatabaseCollectionsTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ internal class DatabaseCollectionsTest {
5555
database.createCollection("movies")
5656
// :snippet-start: get-collections
5757
val collectionList = database.listCollectionNames().toList()
58+
5859
println(collectionList)
5960
// :snippet-end:
6061
// :snippet-start: drop-collections

examples/src/test/kotlin/DeleteTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class DeleteTest {
3131

3232
@BeforeAll
3333
@JvmStatic
34-
private fun beforeAll() {
34+
fun beforeAll() {
3535
runBlocking {
3636
val paintOrders = listOf(
3737
PaintOrder(1, 5, "red"),
@@ -50,7 +50,7 @@ internal class DeleteTest {
5050

5151
@AfterAll
5252
@JvmStatic
53-
private fun afterAll() {
53+
fun afterAll() {
5454
runBlocking {
5555
collection.drop()
5656
client.close()
@@ -101,6 +101,7 @@ internal class DeleteTest {
101101
// :snippet-start: find-one-and-delete
102102
val filter = Filters.eq("color", "purple")
103103
val result = collection.findOneAndDelete(filter)
104+
104105
println("The following was deleted: $result")
105106
// :snippet-end:
106107
// Junit test for the above code

examples/src/test/kotlin/EjsonTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ internal class EjsonTest {
2727
""".trimIndent()
2828

2929
val doc = Document.parse(ejsonStr)
30+
3031
println(doc)
3132
// :snippet-end:
3233
assertEquals("507f1f77bcf86cd799439011", doc.getObjectId("_id").toString())
@@ -66,7 +67,7 @@ internal class EjsonTest {
6667
.append("myNumber", 11223344)
6768

6869
val settings = JsonWriterSettings.builder().outputMode(JsonMode.RELAXED).build()
69-
(myDoc.toJson(settings))
70+
myDoc.toJson(settings)
7071
// :snippet-end:
7172
assertEquals(11223344, myDoc.getInteger("myNumber"))
7273
}

examples/src/test/kotlin/EmbeddedArraysTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ internal class UpdateArraysTest {
6262
val options = FindOneAndUpdateOptions()
6363
.returnDocument(ReturnDocument.AFTER)
6464
val result = collection.findOneAndUpdate(filter, update, options)
65+
6566
print(result)
6667
// :snippet-end:
6768
// Junit test for the above code
@@ -79,6 +80,7 @@ internal class UpdateArraysTest {
7980
val options = FindOneAndUpdateOptions()
8081
.returnDocument(ReturnDocument.AFTER)
8182
val result = collection.findOneAndUpdate(filter, update, options)
83+
8284
print(result)
8385
// :snippet-end:
8486
// Junit test for the above code
@@ -97,6 +99,7 @@ internal class UpdateArraysTest {
9799
val options = FindOneAndUpdateOptions()
98100
.returnDocument(ReturnDocument.AFTER)
99101
val result = collection.findOneAndUpdate(filter, update, options)
102+
100103
println(result)
101104
// :snippet-end:
102105
// Junit test for the above code
@@ -116,6 +119,7 @@ internal class UpdateArraysTest {
116119
.arrayFilters(listOf(smallerFilter))
117120
val update = Updates.inc("${PaintOrder::qty.name}.$[smaller]", 5)
118121
val result = collection.findOneAndUpdate(filter, update, options)
122+
119123
println(result)
120124
// :snippet-end:
121125
// Junit test for the above code

0 commit comments

Comments
 (0)