DATAMONGO-2209 - Polishing.
Convert spaces to tabs. Add ticket references to tests. Reformat code. Original pull request: #649.
This commit is contained in:
@@ -83,14 +83,14 @@
|
||||
|
||||
<!-- reactive -->
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-reactivestreams</artifactId>
|
||||
<version>${mongo.reactivestreams}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-async</artifactId>
|
||||
<version>${mongo}</version>
|
||||
<optional>true</optional>
|
||||
@@ -107,7 +107,7 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
@@ -119,14 +119,14 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.reactivex</groupId>
|
||||
<groupId>io.reactivex</groupId>
|
||||
<artifactId>rxjava</artifactId>
|
||||
<version>${rxjava}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.reactivex</groupId>
|
||||
<groupId>io.reactivex</groupId>
|
||||
<artifactId>rxjava-reactive-streams</artifactId>
|
||||
<version>${rxjava-reactive-streams}</version>
|
||||
<optional>true</optional>
|
||||
@@ -266,11 +266,13 @@
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-reflect</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-coroutines-core</artifactId>
|
||||
|
||||
@@ -56,7 +56,7 @@ inline fun <reified T : Any> ReactiveFindOperation.FindWithProjection<*>.asType(
|
||||
`as`(T::class.java)
|
||||
|
||||
/**
|
||||
* Extension for [ExecutableFindOperation.DistinctWithProjection. as] providing a [KClass] based variant.
|
||||
* Extension for [ExecutableFindOperation.DistinctWithProjection.as] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 2.1
|
||||
@@ -65,7 +65,7 @@ fun <T : Any> ReactiveFindOperation.DistinctWithProjection.asType(resultType: KC
|
||||
`as`(resultType.java);
|
||||
|
||||
/**
|
||||
* Extension for [ReactiveFindOperation.DistinctWithProjection. as] leveraging reified type parameters.
|
||||
* Extension for [ReactiveFindOperation.DistinctWithProjection.as] leveraging reified type parameters.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 2.1
|
||||
@@ -79,7 +79,7 @@ inline fun <reified T : Any> ReactiveFindOperation.DistinctWithProjection.asType
|
||||
* @author Sebastien Deleuze
|
||||
* @since 2.2
|
||||
*/
|
||||
suspend inline fun <reified T: Any> ReactiveFindOperation.TerminatingFind<T>.awaitOne(): T? =
|
||||
suspend inline fun <reified T : Any> ReactiveFindOperation.TerminatingFind<T>.awaitOne(): T? =
|
||||
one().awaitFirstOrNull()
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ suspend inline fun <reified T: Any> ReactiveFindOperation.TerminatingFind<T>.awa
|
||||
* @author Sebastien Deleuze
|
||||
* @since 2.2
|
||||
*/
|
||||
suspend inline fun <reified T: Any> ReactiveFindOperation.TerminatingFind<T>.awaitFirst(): T? =
|
||||
suspend inline fun <reified T : Any> ReactiveFindOperation.TerminatingFind<T>.awaitFirst(): T? =
|
||||
first().awaitFirstOrNull()
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,5 +89,5 @@ suspend fun <T : Any> ReactiveUpdateOperation.TerminatingUpdate<T>.upsertAndAwai
|
||||
* @author Sebastien Deleuze
|
||||
* @since 2.2
|
||||
*/
|
||||
inline fun <reified T : Any> ReactiveUpdateOperation.FindAndReplaceWithProjection<T>.asType(): ReactiveUpdateOperation.FindAndReplaceWithOptions<T> =
|
||||
inline fun <reified T : Any> ReactiveUpdateOperation.FindAndReplaceWithProjection<*>.asType(): ReactiveUpdateOperation.FindAndReplaceWithOptions<T> =
|
||||
`as`(T::class.java)
|
||||
|
||||
@@ -20,6 +20,7 @@ import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import reactor.core.publisher.Mono
|
||||
@@ -78,49 +79,61 @@ class ReactiveFindOperationExtensionsTests {
|
||||
verify { distinctWithProjection.`as`(User::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun terminatingFindAwaitOne() {
|
||||
|
||||
val find = mockk<ReactiveFindOperation.TerminatingFind<String>>()
|
||||
every { find.one() } returns Mono.just("foo")
|
||||
|
||||
runBlocking {
|
||||
assertEquals("foo", find.awaitOne())
|
||||
assertThat(find.awaitOne()).isEqualTo("foo")
|
||||
}
|
||||
|
||||
verify {
|
||||
find.one()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun terminatingFindAwaitFirst() {
|
||||
|
||||
val find = mockk<ReactiveFindOperation.TerminatingFind<String>>()
|
||||
every { find.first() } returns Mono.just("foo")
|
||||
|
||||
runBlocking {
|
||||
assertEquals("foo", find.awaitFirst())
|
||||
assertThat(find.awaitFirst()).isEqualTo("foo")
|
||||
}
|
||||
|
||||
verify {
|
||||
find.first()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun terminatingFindAwaitCount() {
|
||||
|
||||
val find = mockk<ReactiveFindOperation.TerminatingFind<String>>()
|
||||
every { find.count() } returns Mono.just(1)
|
||||
|
||||
runBlocking {
|
||||
assertEquals(1, find.awaitCount())
|
||||
assertThat(find.awaitCount()).isEqualTo(1)
|
||||
}
|
||||
|
||||
verify {
|
||||
find.count()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun terminatingFindAwaitExists() {
|
||||
|
||||
val find = mockk<ReactiveFindOperation.TerminatingFind<String>>()
|
||||
every { find.exists() } returns Mono.just(true)
|
||||
|
||||
runBlocking {
|
||||
assertEquals(true, find.awaitExists())
|
||||
assertThat(find.awaitExists()).isTrue()
|
||||
}
|
||||
|
||||
verify {
|
||||
find.exists()
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Test
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -46,13 +46,16 @@ class ReactiveInsertOperationExtensionsTests {
|
||||
verify { operation.insert(First::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun terminatingFindAwaitOne() {
|
||||
|
||||
val find = mockk<ReactiveInsertOperation.TerminatingInsert<String>>()
|
||||
every { find.one("foo") } returns Mono.just("foo")
|
||||
|
||||
runBlocking {
|
||||
assertEquals("foo", find.oneAndAwait("foo"))
|
||||
assertThat(find.oneAndAwait("foo")).isEqualTo("foo")
|
||||
}
|
||||
|
||||
verify {
|
||||
find.one("foo")
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Test
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -47,14 +47,17 @@ class ReactiveRemoveOperationExtensionsTests {
|
||||
verify { operation.remove(First::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun allAndAwait() {
|
||||
|
||||
val remove = mockk<ReactiveRemoveOperation.TerminatingRemove<String>>()
|
||||
val result = mockk<DeleteResult>()
|
||||
every { remove.all() } returns Mono.just(result)
|
||||
|
||||
runBlocking {
|
||||
assertEquals(result, remove.allAndAwait())
|
||||
assertThat(remove.allAndAwait()).isEqualTo(result)
|
||||
}
|
||||
|
||||
verify {
|
||||
remove.all()
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Test
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -49,75 +49,93 @@ class ReactiveUpdateOperationExtensionsTests {
|
||||
verify { operation.update(First::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun findModifyAndAwait() {
|
||||
|
||||
val find = mockk<ReactiveUpdateOperation.TerminatingFindAndModify<String>>()
|
||||
every { find.findAndModify() } returns Mono.just("foo")
|
||||
|
||||
runBlocking {
|
||||
assertEquals("foo", find.findModifyAndAwait())
|
||||
assertThat(find.findModifyAndAwait()).isEqualTo("foo")
|
||||
}
|
||||
|
||||
verify {
|
||||
find.findAndModify()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun findReplaceAndAwait() {
|
||||
|
||||
val find = mockk<ReactiveUpdateOperation.TerminatingFindAndReplace<String>>()
|
||||
every { find.findAndReplace() } returns Mono.just("foo")
|
||||
|
||||
runBlocking {
|
||||
assertEquals("foo", find.findReplaceAndAwait())
|
||||
assertThat(find.findReplaceAndAwait()).isEqualTo("foo")
|
||||
}
|
||||
|
||||
verify {
|
||||
find.findAndReplace()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun allAndAwait() {
|
||||
|
||||
val update = mockk<ReactiveUpdateOperation.TerminatingUpdate<String>>()
|
||||
val result = mockk<UpdateResult>()
|
||||
every { update.all() } returns Mono.just(result)
|
||||
|
||||
runBlocking {
|
||||
assertEquals(result, update.allAndAwait())
|
||||
assertThat(update.allAndAwait()).isEqualTo(result)
|
||||
}
|
||||
|
||||
verify {
|
||||
update.all()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun firstAndAwait() {
|
||||
|
||||
val update = mockk<ReactiveUpdateOperation.TerminatingUpdate<String>>()
|
||||
val result = mockk<UpdateResult>()
|
||||
every { update.first() } returns Mono.just(result)
|
||||
|
||||
runBlocking {
|
||||
assertEquals(result, update.firstAndAwait())
|
||||
assertThat(update.firstAndAwait()).isEqualTo(result)
|
||||
}
|
||||
|
||||
verify {
|
||||
update.first()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun upsertAndAwait() {
|
||||
|
||||
val update = mockk<ReactiveUpdateOperation.TerminatingUpdate<String>>()
|
||||
val result = mockk<UpdateResult>()
|
||||
every { update.upsert() } returns Mono.just(result)
|
||||
|
||||
runBlocking {
|
||||
assertEquals(result, update.upsertAndAwait())
|
||||
assertThat(update.upsertAndAwait()).isEqualTo(result)
|
||||
}
|
||||
|
||||
verify {
|
||||
update.upsert()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAMONGO-2209
|
||||
fun findAndReplaceWithProjectionAsType() {
|
||||
|
||||
val update = mockk<ReactiveUpdateOperation.FindAndReplaceWithProjection<String>>()
|
||||
val result = mockk<ReactiveUpdateOperation.FindAndReplaceWithOptions<String>>()
|
||||
every { update.`as`(String::class.java) } returns result
|
||||
assertEquals(result, update.asType<String>())
|
||||
|
||||
assertThat(update.asType<String>()).isEqualTo(result)
|
||||
|
||||
verify {
|
||||
update.`as`(String::class.java)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user