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