Skip to content

Commit 18d4ea1

Browse files
DATAREDIS-1111 - Polishing.
Update author information, issue references and favour non nullable parameter with default value. Original Pull Request: spring-projects#514
1 parent 62042a5 commit 18d4ea1

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

src/main/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensions.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,17 @@ fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.rangeWithScoresAsFlow(key: K
102102
* @author Sebastien Deleuze
103103
* @since 2.2
104104
*/
105-
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.rangeByScoreAsFlow(key: K, range: Range<Double>, limit: Limit? = null): Flow<V> =
106-
(if (limit == null) rangeByScore(key, range) else rangeByScore(key, range, limit)).asFlow()
105+
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.rangeByScoreAsFlow(key: K, range: Range<Double>, limit: Limit = Limit.unlimited()): Flow<V> =
106+
rangeByScore(key, range, limit).asFlow()
107107

108108
/**
109109
* Coroutines variant of [ReactiveZSetOperations.rangeByScoreWithScores].
110110
*
111111
* @author Sebastien Deleuze
112112
* @since 2.2
113113
*/
114-
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.rangeByScoreWithScoresAsFlow(key: K, range: Range<Double>, limit: Limit? = null): Flow<TypedTuple<V>> =
115-
(if (limit == null) rangeByScoreWithScores(key, range) else rangeByScoreWithScores(key, range, limit)).asFlow()
114+
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.rangeByScoreWithScoresAsFlow(key: K, range: Range<Double>, limit: Limit = Limit.unlimited()): Flow<TypedTuple<V>> =
115+
rangeByScoreWithScores(key, range, limit).asFlow()
116116

117117
/**
118118
* Coroutines variant of [ReactiveZSetOperations.reverseRange].
@@ -138,17 +138,17 @@ fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.reverseRangeWithScoresAsFlow
138138
* @author Sebastien Deleuze
139139
* @since 2.2
140140
*/
141-
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.reverseRangeByScoreAsFlow(key: K, range: Range<Double>, limit: Limit? = null): Flow<V> =
142-
(if (limit == null) reverseRangeByScore(key, range) else reverseRangeByScore(key, range, limit)).asFlow()
141+
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.reverseRangeByScoreAsFlow(key: K, range: Range<Double>, limit: Limit = Limit.unlimited()): Flow<V> =
142+
reverseRangeByScore(key, range, limit).asFlow()
143143

144144
/**
145145
* Coroutines variant of [ReactiveZSetOperations.reverseRangeByScoreWithScores].
146146
*
147147
* @author Sebastien Deleuze
148148
* @since 2.2
149149
*/
150-
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.reverseRangeByScoreWithScoresAsFlow(key: K, range: Range<Double>, limit: Limit? = null): Flow<TypedTuple<V>> =
151-
(if (limit == null) reverseRangeByScoreWithScores(key, range) else reverseRangeByScoreWithScores(key, range, limit)).asFlow()
150+
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.reverseRangeByScoreWithScoresAsFlow(key: K, range: Range<Double>, limit: Limit = Limit.unlimited()): Flow<TypedTuple<V>> =
151+
reverseRangeByScoreWithScores(key, range, limit).asFlow()
152152

153153
/**
154154
* Coroutines variant of [ReactiveZSetOperations.count].
@@ -273,17 +273,17 @@ suspend fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.intersectAndStoreAnd
273273
* @author Wonwoo Lee
274274
* @since 2.3
275275
*/
276-
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.rangeByLexAndAwait(key: K, range: Range<String>, limit: Limit? = null): Flow<V> =
277-
(if (limit == null) rangeByLex(key, range) else rangeByLex(key, range, limit)).asFlow()
276+
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.rangeByLexAndAwait(key: K, range: Range<String>, limit: Limit = Limit.unlimited()): Flow<V> =
277+
rangeByLex(key, range, limit).asFlow()
278278

279279
/**
280280
* Coroutines variant of [ReactiveZSetOperations.reverseRangeByLex].
281281
*
282282
* @author Wonwoo Lee
283283
* @since 2.3
284284
*/
285-
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.reverseRangeByLexAndAwait(key: K, range: Range<String>, limit: Limit? = null): Flow<V> =
286-
(if (limit == null) reverseRangeByLex(key, range) else reverseRangeByLex(key, range, limit)).asFlow()
285+
fun <K : Any, V : Any> ReactiveZSetOperations<K, V>.reverseRangeByLexAndAwait(key: K, range: Range<String>, limit: Limit = Limit.unlimited()): Flow<V> =
286+
reverseRangeByLex(key, range, limit).asFlow()
287287

288288
/**
289289
* Coroutines variant of [ReactiveZSetOperations.delete].

src/test/kotlin/org/springframework/data/redis/core/ReactiveListOperationsExtensionsUnitTests.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import java.time.Duration
3131
*
3232
* @author Mark Paluch
3333
* @author Sebastien Deleuze
34+
* @author Wonwoo Lee
3435
*/
3536
class ReactiveListOperationsExtensionsUnitTests {
3637

@@ -334,7 +335,7 @@ class ReactiveListOperationsExtensionsUnitTests {
334335
}
335336
}
336337

337-
@Test
338+
@Test // DATAREDIS-1111
338339
fun rightPopAndLeftPush() {
339340

340341
val operations = mockk<ReactiveListOperations<String, String>>()
@@ -349,7 +350,7 @@ class ReactiveListOperationsExtensionsUnitTests {
349350
}
350351
}
351352

352-
@Test
353+
@Test // DATAREDIS-1111
353354
fun blockingRightPopAndLeftPush() {
354355

355356
val operations = mockk<ReactiveListOperations<String, String>>()

src/test/kotlin/org/springframework/data/redis/core/ReactiveZSetOperationsExtensionsUnitTests.kt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import kotlinx.coroutines.runBlocking
2323
import org.assertj.core.api.Assertions.assertThat
2424
import org.junit.Test
2525
import org.springframework.data.domain.Range
26+
import org.springframework.data.redis.connection.RedisZSetCommands
2627
import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate
2728
import org.springframework.data.redis.connection.RedisZSetCommands.Weights
2829
import org.springframework.data.redis.core.ZSetOperations.*
@@ -34,6 +35,7 @@ import reactor.core.publisher.Mono
3435
*
3536
* @author Mark Paluch
3637
* @author Christoph Strobl
38+
* @author Wonwoo Lee
3739
*/
3840
class ReactiveZSetOperationsExtensionsUnitTests {
3941

@@ -195,14 +197,14 @@ class ReactiveZSetOperationsExtensionsUnitTests {
195197

196198
val range = Range.unbounded<Double>()
197199
val operations = mockk<ReactiveZSetOperations<String, String>>()
198-
every { operations.rangeByScore(any(), any()) } returns Flux.just("bar")
200+
every { operations.rangeByScore(any(), any(), any()) } returns Flux.just("bar")
199201

200202
runBlocking {
201203
assertThat(operations.rangeByScoreAsFlow("foo", range).toList()).contains("bar")
202204
}
203205

204206
verify {
205-
operations.rangeByScore("foo", range)
207+
operations.rangeByScore("foo", range, RedisZSetCommands.Limit.unlimited())
206208
}
207209
}
208210

@@ -212,14 +214,14 @@ class ReactiveZSetOperationsExtensionsUnitTests {
212214
val tuple = mockk<TypedTuple<String>>(relaxed = true)
213215
val range = Range.unbounded<Double>()
214216
val operations = mockk<ReactiveZSetOperations<String, String>>()
215-
every { operations.rangeByScoreWithScores(any(), any()) } returns Flux.just(tuple)
217+
every { operations.rangeByScoreWithScores(any(), any(), any()) } returns Flux.just(tuple)
216218

217219
runBlocking {
218220
assertThat(operations.rangeByScoreWithScoresAsFlow("foo", range).toList()).contains(tuple)
219221
}
220222

221223
verify {
222-
operations.rangeByScoreWithScores("foo", range)
224+
operations.rangeByScoreWithScores("foo", range, RedisZSetCommands.Limit.unlimited())
223225
}
224226
}
225227

@@ -261,14 +263,14 @@ class ReactiveZSetOperationsExtensionsUnitTests {
261263

262264
val range = Range.unbounded<Double>()
263265
val operations = mockk<ReactiveZSetOperations<String, String>>()
264-
every { operations.reverseRangeByScore(any(), any()) } returns Flux.just("bar")
266+
every { operations.reverseRangeByScore(any(), any(), any()) } returns Flux.just("bar")
265267

266268
runBlocking {
267269
assertThat(operations.reverseRangeByScoreAsFlow("foo", range).toList()).contains("bar")
268270
}
269271

270272
verify {
271-
operations.reverseRangeByScore("foo", range)
273+
operations.reverseRangeByScore("foo", range, RedisZSetCommands.Limit.unlimited())
272274
}
273275
}
274276

@@ -278,14 +280,14 @@ class ReactiveZSetOperationsExtensionsUnitTests {
278280
val tuple = mockk<TypedTuple<String>>(relaxed = true)
279281
val range = Range.unbounded<Double>()
280282
val operations = mockk<ReactiveZSetOperations<String, String>>()
281-
every { operations.reverseRangeByScoreWithScores(any(), any()) } returns Flux.just(tuple)
283+
every { operations.reverseRangeByScoreWithScores(any(), any(), any()) } returns Flux.just(tuple)
282284

283285
runBlocking {
284286
assertThat(operations.reverseRangeByScoreWithScoresAsFlow("foo", range).toList()).contains(tuple)
285287
}
286288

287289
verify {
288-
operations.reverseRangeByScoreWithScores("foo", range)
290+
operations.reverseRangeByScoreWithScores("foo", range, RedisZSetCommands.Limit.unlimited())
289291
}
290292
}
291293

@@ -304,7 +306,7 @@ class ReactiveZSetOperationsExtensionsUnitTests {
304306
}
305307
}
306308

307-
@Test
309+
@Test // DATAREDIS-1111
308310
fun size() {
309311

310312
val operations = mockk<ReactiveZSetOperations<String, String>>()
@@ -499,37 +501,37 @@ class ReactiveZSetOperationsExtensionsUnitTests {
499501
}
500502
}
501503

502-
@Test
504+
@Test // DATAREDIS-1111
503505
fun rangeByLex() {
504506

505507
val operations = mockk<ReactiveZSetOperations<String, String>>()
506-
every { operations.rangeByLex(any(), any()) } returns Flux.just("bar")
508+
every { operations.rangeByLex(any(), any(), any()) } returns Flux.just("bar")
507509

508510
runBlocking {
509511
assertThat(operations.rangeByLexAndAwait("foo", Range.just("bar")).toList()).contains("bar")
510512
}
511513

512514
verify {
513-
operations.rangeByLex("foo", Range.just("bar"))
515+
operations.rangeByLex("foo", Range.just("bar"), RedisZSetCommands.Limit.unlimited())
514516
}
515517
}
516518

517-
@Test
519+
@Test // DATAREDIS-1111
518520
fun reverseRangeByLexAndAwait() {
519521

520522
val operations = mockk<ReactiveZSetOperations<String, String>>()
521-
every { operations.reverseRangeByLex(any(), any()) } returns Flux.just("bar")
523+
every { operations.reverseRangeByLex(any(), any(), any()) } returns Flux.just("bar")
522524

523525
runBlocking {
524526
assertThat(operations.reverseRangeByLexAndAwait("foo", Range.just("bar")).toList()).contains("bar")
525527
}
526528

527529
verify {
528-
operations.reverseRangeByLex("foo", Range.just("bar"))
530+
operations.reverseRangeByLex("foo", Range.just("bar"), RedisZSetCommands.Limit.unlimited())
529531
}
530532
}
531533

532-
@Test
534+
@Test // DATAREDIS-1111
533535
fun delete() {
534536

535537
val operations = mockk<ReactiveZSetOperations<String, String>>()

0 commit comments

Comments
 (0)