Skip to content

Commit 2fac62a

Browse files
pull-vertmp911de
authored andcommitted
#212 - Provide Kotlin Coroutine extensions on UpdatedRowsFetchSpec.
Original pull request: #213.
1 parent f1dbaab commit 2fac62a

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2018-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.r2dbc.core
17+
18+
import kotlinx.coroutines.reactive.awaitSingle
19+
20+
/**
21+
* Coroutines variant of [UpdatedRowsFetchSpec.rowsUpdated].
22+
*
23+
* @author Fred Montariol
24+
*/
25+
suspend fun UpdatedRowsFetchSpec.awaitRowsUpdated(): Int =
26+
rowsUpdated().awaitSingle()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2018-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.r2dbc.core
17+
18+
import io.mockk.every
19+
import io.mockk.mockk
20+
import io.mockk.verify
21+
import kotlinx.coroutines.runBlocking
22+
import org.assertj.core.api.Assertions.assertThat
23+
import org.junit.Test
24+
import reactor.core.publisher.Mono
25+
26+
/**
27+
* Unit tests for [UpdatedRowsFetchSpec] extensions.
28+
*
29+
* @author Fred Montariol
30+
*/
31+
class UpdatedRowsFetchSpecExtensionsTests {
32+
33+
@Test // gh-212
34+
fun awaitRowsUpdatedWithValue() {
35+
36+
val spec = mockk<UpdatedRowsFetchSpec>()
37+
every { spec.rowsUpdated() } returns Mono.just(42)
38+
39+
runBlocking {
40+
assertThat(spec.awaitRowsUpdated()).isEqualTo(42)
41+
}
42+
43+
verify {
44+
spec.rowsUpdated()
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)