11/*
2- * Copyright 2017- 2025 the original author or authors.
2+ * Copyright 2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -17,58 +17,63 @@ package org.springframework.data.mongodb.core
1717
1818import io.mockk.mockk
1919import io.mockk.verify
20- import org.junit.Test
20+ import org.junit.jupiter.api. Test
2121import org.springframework.data.mongodb.core.query.Criteria
2222import org.springframework.data.mongodb.core.query.Query
2323import org.springframework.data.mongodb.core.query.Update
2424import org.springframework.data.mongodb.core.query.UpdateDefinition
2525import org.springframework.data.util.Pair.of
2626
2727/* *
28+ * Unit tests for BulkOperationExtensions.
2829 * @author 2tsumo-hitori
2930 */
3031class BulkOperationExtensionsTests {
3132
32- private val bulkOperation = mockk<BulkOperations >(relaxed = true )
33+ private val bulkOperation = mockk<BulkOperations >(relaxed = true )
3334
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` () {
3837
39- bulkOperation.updateMulti(list)
38+ val list: MutableList <Pair <Query , UpdateDefinition >> = mutableListOf ()
39+ list.add(where(" value" , " v2" ) to set(" value" , " v3" ))
4040
41- val expected = list.map { (query, update) -> of(query, update) }
42- verify { bulkOperation.updateMulti(expected) }
43- }
41+ bulkOperation.updateMulti(list)
4442
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+ }
4946
50- bulkOperation.upsert(list)
47+ @Test // GH-4911
48+ fun `BulkOperation#upsert using kotlin#Pair should call its Java counterpart` () {
5149
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" ))
5552
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)
6054
61- bulkOperation.updateOne(list)
55+ val expected = list.map { (query, update) -> of(query, update) }
56+ verify { bulkOperation.upsert(expected) }
57+ }
6258
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` () {
6661
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" ))
7064
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