1
1
/*
2
- * Copyright 2017- 2025 the original author or authors.
2
+ * Copyright 2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -17,58 +17,63 @@ package org.springframework.data.mongodb.core
17
17
18
18
import io.mockk.mockk
19
19
import io.mockk.verify
20
- import org.junit.Test
20
+ import org.junit.jupiter.api. Test
21
21
import org.springframework.data.mongodb.core.query.Criteria
22
22
import org.springframework.data.mongodb.core.query.Query
23
23
import org.springframework.data.mongodb.core.query.Update
24
24
import org.springframework.data.mongodb.core.query.UpdateDefinition
25
25
import org.springframework.data.util.Pair.of
26
26
27
27
/* *
28
+ * Unit tests for BulkOperationExtensions.
28
29
* @author 2tsumo-hitori
29
30
*/
30
31
class BulkOperationExtensionsTests {
31
32
32
- private val bulkOperation = mockk<BulkOperations >(relaxed = true )
33
+ private val bulkOperation = mockk<BulkOperations >(relaxed = true )
33
34
34
- @Test // GH-4911
35
- fun `BulkOperation#updateMulti#updates() using kotlin#Pair should call its Java counterpart` () {
36
- val list : MutableList <Pair <Query , UpdateDefinition >> = mutableListOf ()
37
- list.add(where(" value" , " v2" ) to set(" value" , " v3" ))
35
+ @Test // GH-4911
36
+ fun `BulkOperation#updateMulti using kotlin#Pair should call its Java counterpart` () {
38
37
39
- bulkOperation.updateMulti(list)
38
+ val list: MutableList <Pair <Query , UpdateDefinition >> = mutableListOf ()
39
+ list.add(where(" value" , " v2" ) to set(" value" , " v3" ))
40
40
41
- val expected = list.map { (query, update) -> of(query, update) }
42
- verify { bulkOperation.updateMulti(expected) }
43
- }
41
+ bulkOperation.updateMulti(list)
44
42
45
- @Test // GH-4911
46
- fun `BulkOperation#upsert#updates() using kotlin#Pair should call its Java counterpart` () {
47
- val list : MutableList <Pair <Query , Update >> = mutableListOf ()
48
- list.add(where(" value" , " v2" ) to set(" value" , " v3" ))
43
+ val expected = list.map { (query, update) -> of(query, update) }
44
+ verify { bulkOperation.updateMulti(expected) }
45
+ }
49
46
50
- bulkOperation.upsert(list)
47
+ @Test // GH-4911
48
+ fun `BulkOperation#upsert using kotlin#Pair should call its Java counterpart` () {
51
49
52
- val expected = list.map { (query, update) -> of(query, update) }
53
- verify { bulkOperation.upsert(expected) }
54
- }
50
+ val list: MutableList <Pair <Query , Update >> = mutableListOf ()
51
+ list.add(where(" value" , " v2" ) to set(" value" , " v3" ))
55
52
56
- @Test // GH-4911
57
- fun `BulkOperation#updateOne#updates() using kotlin#Pair should call its Java counterpart` () {
58
- val list : MutableList <Pair <Query , UpdateDefinition >> = mutableListOf ()
59
- list.add(where(" value" , " v2" ) to set(" value" , " v3" ))
53
+ bulkOperation.upsert(list)
60
54
61
- bulkOperation.updateOne(list)
55
+ val expected = list.map { (query, update) -> of(query, update) }
56
+ verify { bulkOperation.upsert(expected) }
57
+ }
62
58
63
- val expected = list.map { (query, update) -> of(query, update) }
64
- verify { bulkOperation.updateOne(expected) }
65
- }
59
+ @Test // GH-4911
60
+ fun `BulkOperation#updateOne using kotlin#Pair should call its Java counterpart` () {
66
61
67
- private fun where (field : String , value : String ): Query {
68
- return Query ().addCriteria(Criteria .where(field).`is `(value))
69
- }
62
+ val list: MutableList <Pair <Query , UpdateDefinition >> = mutableListOf ()
63
+ list.add(where(" value" , " v2" ) to set(" value" , " v3" ))
70
64
71
- private fun set (field : String , value : String ): Update {
72
- return Update ().set(field, value)
73
- }
74
- }
65
+ bulkOperation.updateOne(list)
66
+
67
+ val expected = list.map { (query, update) -> of(query, update) }
68
+ verify { bulkOperation.updateOne(expected) }
69
+ }
70
+
71
+ private fun where (field : String , value : String ): Query {
72
+ return Query ().addCriteria(Criteria .where(field).`is `(value))
73
+ }
74
+
75
+ private fun set (field : String , value : String ): Update {
76
+ return Update ().set(field, value)
77
+ }
78
+
79
+ }
0 commit comments