Skip to content

Commit 9c26859

Browse files
committed
DATAMONGO-2255 - Polishing.
Add ticket references. Rename allAsFlow() to flow() to simplify naming. Original pull request: #736.
1 parent 02931ec commit 9c26859

10 files changed

+30
-32
lines changed

spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/ExecutableFindOperationExtensions.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inline fun <reified T : Any> ExecutableFindOperation.query(): ExecutableFindOper
3939
query(T::class.java)
4040

4141
/**
42-
* Extension for [ExecutableFindOperation.FindWithProjection. as] providing a [KClass] based variant.
42+
* Extension for [ExecutableFindOperation.FindWithProjection.as] providing a [KClass] based variant.
4343
*
4444
* @author Sebastien Deleuze
4545
* @author Mark Paluch
@@ -50,7 +50,7 @@ fun <T : Any> ExecutableFindOperation.FindWithProjection<*>.asType(resultType: K
5050
`as`(resultType.java)
5151

5252
/**
53-
* Extension for [ExecutableFindOperation.FindWithProjection. as] leveraging reified type parameters.
53+
* Extension for [ExecutableFindOperation.FindWithProjection.as] leveraging reified type parameters.
5454
*
5555
* @author Sebastien Deleuze
5656
* @author Mark Paluch
@@ -60,7 +60,7 @@ inline fun <reified T : Any> ExecutableFindOperation.FindWithProjection<*>.asTyp
6060
`as`(T::class.java)
6161

6262
/**
63-
* Extension for [ExecutableFindOperation.DistinctWithProjection. as] providing a [KClass] based variant.
63+
* Extension for [ExecutableFindOperation.DistinctWithProjection.as] providing a [KClass] based variant.
6464
*
6565
* @author Christoph Strobl
6666
* @since 2.1
@@ -70,7 +70,7 @@ fun <T : Any> ExecutableFindOperation.DistinctWithProjection.asType(resultType:
7070
`as`(resultType.java);
7171

7272
/**
73-
* Extension for [ExecutableFindOperation.DistinctWithProjection. as] leveraging reified type parameters.
73+
* Extension for [ExecutableFindOperation.DistinctWithProjection.as] leveraging reified type parameters.
7474
*
7575
* @author Christoph Strobl
7676
* @since 2.1

spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/ReactiveAggregationOperationExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ inline fun <reified T : Any> ReactiveAggregationOperation.aggregateAndReturn():
4949
* @since 2.2
5050
*/
5151
@FlowPreview
52-
fun <T : Any> ReactiveAggregationOperation.TerminatingAggregationOperation<T>.allAsFlow(batchSize: Int = 1): Flow<T> =
52+
fun <T : Any> ReactiveAggregationOperation.TerminatingAggregationOperation<T>.flow(batchSize: Int = 1): Flow<T> =
5353
all().asFlow(batchSize)

spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/ReactiveFindOperationExtensions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ suspend fun <T : Any> ReactiveFindOperation.TerminatingFind<T>.awaitExists(): Bo
143143
* @author Sebastien Deleuze
144144
*/
145145
@FlowPreview
146-
fun <T : Any> ReactiveFindOperation.TerminatingFind<T>.allAsFlow(batchSize: Int = 1): Flow<T> =
146+
fun <T : Any> ReactiveFindOperation.TerminatingFind<T>.flow(batchSize: Int = 1): Flow<T> =
147147
all().asFlow(batchSize)
148148

149149
/**
@@ -167,7 +167,7 @@ fun <T : Any> ReactiveFindOperation.TerminatingFind<T>.tailAsFlow(batchSize: Int
167167
* @author Sebastien Deleuze
168168
*/
169169
@FlowPreview
170-
fun <T : Any> ReactiveFindOperation.TerminatingFindNear<T>.allAsFlow(batchSize: Int = 1): Flow<GeoResult<T>> =
170+
fun <T : Any> ReactiveFindOperation.TerminatingFindNear<T>.flow(batchSize: Int = 1): Flow<GeoResult<T>> =
171171
all().asFlow(batchSize)
172172

173173
/**
@@ -180,5 +180,5 @@ fun <T : Any> ReactiveFindOperation.TerminatingFindNear<T>.allAsFlow(batchSize:
180180
* @since 2.2
181181
*/
182182
@FlowPreview
183-
fun <T : Any> ReactiveFindOperation.TerminatingDistinct<T>.allAsFlow(batchSize: Int = 1): Flow<T> =
183+
fun <T : Any> ReactiveFindOperation.TerminatingDistinct<T>.flow(batchSize: Int = 1): Flow<T> =
184184
all().asFlow(batchSize)

spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/ReactiveInsertOperationExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ suspend inline fun <reified T: Any> ReactiveInsertOperation.TerminatingInsert<T>
6060
* @since 2.2
6161
*/
6262
@FlowPreview
63-
fun <T : Any> ReactiveInsertOperation.TerminatingInsert<T>.allAsFlow(objects: Collection<T>, batchSize: Int = 1): Flow<T> =
63+
fun <T : Any> ReactiveInsertOperation.TerminatingInsert<T>.flow(objects: Collection<T>, batchSize: Int = 1): Flow<T> =
6464
all(objects).asFlow(batchSize)

spring-data-mongodb/src/main/kotlin/org/springframework/data/mongodb/core/ReactiveMapReduceOperationExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ inline fun <reified T : Any> ReactiveMapReduceOperation.MapReduceWithProjection<
6969
* @since 2.2
7070
*/
7171
@FlowPreview
72-
fun <T : Any> ReactiveMapReduceOperation.TerminatingMapReduce<T>.allAsFlow(batchSize: Int = 1): Flow<T> =
72+
fun <T : Any> ReactiveMapReduceOperation.TerminatingMapReduce<T>.flow(batchSize: Int = 1): Flow<T> =
7373
all().asFlow(batchSize)

spring-data-mongodb/src/test/kotlin/org/springframework/data/mongodb/core/ReactiveAggregationOperationExtensionsTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import io.mockk.verify
2222
import kotlinx.coroutines.FlowPreview
2323
import kotlinx.coroutines.flow.toList
2424
import kotlinx.coroutines.runBlocking
25-
import org.assertj.core.api.Assertions
25+
import org.assertj.core.api.Assertions.assertThat
2626
import org.junit.Test
2727
import reactor.core.publisher.Flux
2828

@@ -48,15 +48,15 @@ class ReactiveAggregationOperationExtensionsTests {
4848
verify { operation.aggregateAndReturn(First::class.java) }
4949
}
5050

51-
@Test
51+
@Test // DATAMONGO-2255
5252
@FlowPreview
5353
fun terminatingAggregationOperationAllAsFlow() {
5454

5555
val spec = mockk<ReactiveAggregationOperation.TerminatingAggregationOperation<String>>()
5656
every { spec.all() } returns Flux.just("foo", "bar", "baz")
5757

5858
runBlocking {
59-
Assertions.assertThat(spec.allAsFlow().toList()).contains("foo", "bar", "baz")
59+
assertThat(spec.flow().toList()).contains("foo", "bar", "baz")
6060
}
6161

6262
verify {

spring-data-mongodb/src/test/kotlin/org/springframework/data/mongodb/core/ReactiveFindOperationExtensionsTests.kt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import io.mockk.every
2020
import io.mockk.mockk
2121
import io.mockk.verify
2222
import kotlinx.coroutines.FlowPreview
23+
import kotlinx.coroutines.flow.take
2324
import kotlinx.coroutines.flow.toList
2425
import kotlinx.coroutines.runBlocking
2526
import org.assertj.core.api.Assertions.assertThat
@@ -34,6 +35,7 @@ import reactor.core.publisher.Mono
3435
* @author Mark Paluch
3536
* @author Sebastien Deleuze
3637
*/
38+
@FlowPreview
3739
class ReactiveFindOperationExtensionsTests {
3840

3941
val operation = mockk<ReactiveFindOperation>(relaxed = true)
@@ -234,40 +236,37 @@ class ReactiveFindOperationExtensionsTests {
234236
}
235237
}
236238

237-
@Test
238-
@FlowPreview
239+
@Test // DATAMONGO-2255
239240
fun terminatingFindAllAsFlow() {
240241

241242
val spec = mockk<ReactiveFindOperation.TerminatingFind<String>>()
242243
every { spec.all() } returns Flux.just("foo", "bar", "baz")
243244

244245
runBlocking {
245-
assertThat(spec.allAsFlow().toList()).contains("foo", "bar", "baz")
246+
assertThat(spec.flow().toList()).contains("foo", "bar", "baz")
246247
}
247248

248249
verify {
249250
spec.all()
250251
}
251252
}
252253

253-
@Test
254-
@FlowPreview
254+
@Test // DATAMONGO-2255
255255
fun terminatingFindTailAsFlow() {
256256

257257
val spec = mockk<ReactiveFindOperation.TerminatingFind<String>>()
258-
every { spec.tail() } returns Flux.just("foo", "bar", "baz")
258+
every { spec.tail() } returns Flux.just("foo", "bar", "baz").concatWith(Flux.never())
259259

260260
runBlocking {
261-
assertThat(spec.tailAsFlow().toList()).contains("foo", "bar", "baz")
261+
assertThat(spec.tailAsFlow().take(3).toList()).contains("foo", "bar", "baz")
262262
}
263263

264264
verify {
265265
spec.tail()
266266
}
267267
}
268268

269-
@Test
270-
@FlowPreview
269+
@Test // DATAMONGO-2255
271270
fun terminatingFindNearAllAsFlow() {
272271

273272
val spec = mockk<ReactiveFindOperation.TerminatingFindNear<String>>()
@@ -277,23 +276,22 @@ class ReactiveFindOperationExtensionsTests {
277276
every { spec.all() } returns Flux.just(foo, bar, baz)
278277

279278
runBlocking {
280-
assertThat(spec.allAsFlow().toList()).contains(foo, bar, baz)
279+
assertThat(spec.flow().toList()).contains(foo, bar, baz)
281280
}
282281

283282
verify {
284283
spec.all()
285284
}
286285
}
287286

288-
@Test
289-
@FlowPreview
287+
@Test // DATAMONGO-2255
290288
fun terminatingDistinctAllAsFlow() {
291289

292290
val spec = mockk<ReactiveFindOperation.TerminatingDistinct<String>>()
293291
every { spec.all() } returns Flux.just("foo", "bar", "baz")
294292

295293
runBlocking {
296-
assertThat(spec.allAsFlow().toList()).contains("foo", "bar", "baz")
294+
assertThat(spec.flow().toList()).contains("foo", "bar", "baz")
297295
}
298296

299297
verify {

spring-data-mongodb/src/test/kotlin/org/springframework/data/mongodb/core/ReactiveInsertOperationExtensionsTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class ReactiveInsertOperationExtensionsTests {
6464
}
6565
}
6666

67-
@Test
67+
@Test // DATAMONGO-2255
6868
@FlowPreview
6969
fun terminatingInsertAllAsFlow() {
7070

@@ -73,7 +73,7 @@ class ReactiveInsertOperationExtensionsTests {
7373
every { insert.all(any()) } returns Flux.fromIterable(list)
7474

7575
runBlocking {
76-
assertThat(insert.allAsFlow(list).toList()).containsAll(list)
76+
assertThat(insert.flow(list).toList()).containsAll(list)
7777
}
7878

7979
verify {

spring-data-mongodb/src/test/kotlin/org/springframework/data/mongodb/core/ReactiveMapReduceOperationExtensionsTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import io.mockk.verify
2222
import kotlinx.coroutines.FlowPreview
2323
import kotlinx.coroutines.flow.toList
2424
import kotlinx.coroutines.runBlocking
25-
import org.assertj.core.api.Assertions
25+
import org.assertj.core.api.Assertions.assertThat
2626
import org.junit.Test
2727
import reactor.core.publisher.Flux
2828

@@ -64,15 +64,15 @@ class ReactiveMapReduceOperationExtensionsTests {
6464
verify { operationWithProjection.`as`(User::class.java) }
6565
}
6666

67-
@Test
67+
@Test // DATAMONGO-2255
6868
@FlowPreview
6969
fun terminatingMapReduceAllAsFlow() {
7070

7171
val spec = mockk<ReactiveMapReduceOperation.TerminatingMapReduce<String>>()
7272
every { spec.all() } returns Flux.just("foo", "bar", "baz")
7373

7474
runBlocking {
75-
Assertions.assertThat(spec.allAsFlow().toList()).contains("foo", "bar", "baz")
75+
assertThat(spec.flow().toList()).contains("foo", "bar", "baz")
7676
}
7777

7878
verify {

spring-data-mongodb/src/test/kotlin/org/springframework/data/mongodb/core/ReactiveRemoveOperationExtensionsTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ReactiveRemoveOperationExtensionsTests {
6666
}
6767
}
6868

69-
@Test
69+
@Test // DATAMONGO-2255
7070
@FlowPreview
7171
fun terminatingRemoveFindAndRemoveAsFlow() {
7272

0 commit comments

Comments
 (0)