From 769b0f6af577087622e1d4af3de43a203d492e2d Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Mon, 13 Jan 2020 14:01:58 +0100 Subject: [PATCH] DATACMNS-1508 - Polishing. Add findAllById, deleteAll to CoroutineCrudRepository. Keep CoroutineCrudRepository somewhat in sync with ReactiveCrudRepository by adding based methods for those accecpting Publisher. Also add some test. Update License Headers of Kotlin files and fix some warnings. Switch to kotlin-test-junit5. Original pull request: #415. --- pom.xml | 3 +- .../data/util/KotlinReflectionUtils.java | 16 ++- .../repository/CrudRepositoryExtensions.kt | 2 +- .../kotlin/CoroutineCrudRepository.kt | 23 +++- .../kotlin/CoroutineSortingRepository.kt | 2 +- .../core/support/DummyRepositoryFactory.java | 2 +- ...ssGeneratingEntityInstantiatorUnitTests.kt | 2 +- ...ionEntityInstantiatorDataClassUnitTests.kt | 2 +- .../data/mapping/context/SimpleDataClass.kt | 5 +- .../context/TypeCreatingSyntheticClass.kt | 5 +- .../data/mapping/model/DataClasses.kt | 5 +- ...PreferredConstructorDiscovererUnitTests.kt | 5 +- .../model/TypeCreatingSyntheticClass.kt | 5 +- .../data/mapping/model/UnusedCustomCopy.kt | 4 +- .../data/mapping/model/ValueClassKt.kt | 5 +- .../data/mapping/model/With32Args.kt | 2 +- .../data/mapping/model/With33Args.kt | 2 +- .../CrudRepositoryExtensionsTests.kt | 2 +- .../core/support/KotlinUserRepository.kt | 2 +- ...RepositoryCustomImplementationUnitTests.kt | 6 +- .../CoroutineCrudRepositoryUnitTests.kt | 109 +++++++++++++++++- .../repository/query/ParameterUnitTests.kt | 3 +- .../data/util/DummyInterface.kt | 2 +- .../data/util/TypeCreatingSyntheticClass.kt | 5 +- 24 files changed, 171 insertions(+), 48 deletions(-) diff --git a/pom.xml b/pom.xml index df8759fd5..a36219397 100644 --- a/pom.xml +++ b/pom.xml @@ -287,7 +287,8 @@ org.jetbrains.kotlin - kotlin-test + kotlin-test-junit5 + ${kotlin} test diff --git a/src/main/java/org/springframework/data/util/KotlinReflectionUtils.java b/src/main/java/org/springframework/data/util/KotlinReflectionUtils.java index 8ec5ff3f1..16206b4cd 100644 --- a/src/main/java/org/springframework/data/util/KotlinReflectionUtils.java +++ b/src/main/java/org/springframework/data/util/KotlinReflectionUtils.java @@ -40,13 +40,12 @@ import org.springframework.lang.Nullable; * errors. * * @author Mark Paluch + * @author Christoph Strobl * @since 2.3 * @see org.springframework.core.KotlinDetector#isKotlinReflectPresent() */ public final class KotlinReflectionUtils { - private static final int KOTLIN_KIND_CLASS = 1; - private KotlinReflectionUtils() {} /** @@ -64,7 +63,7 @@ public final class KotlinReflectionUtils { return Arrays.stream(type.getDeclaredAnnotations()) // .filter(annotation -> annotation.annotationType().getName().equals("kotlin.Metadata")) // .map(annotation -> AnnotationUtils.getValue(annotation, "k")) // - .anyMatch(it -> Integer.valueOf(KOTLIN_KIND_CLASS).equals(it)); + .anyMatch(it -> Integer.valueOf(KotlinClassHeaderKind.CLASS.id).equals(it)); } /** @@ -202,4 +201,15 @@ public final class KotlinReflectionUtils { Method javaMethod = ReflectJvmMapping.getJavaMethod(function); return javaMethod != null && javaMethod.equals(method); } + + private enum KotlinClassHeaderKind { + + CLASS(1), FILE(2), SYNTHETIC_CLASS(3), MULTI_FILE_CLASS_FACADE(4), MULTI_FILE_CLASS_PART(5); + + int id; + + KotlinClassHeaderKind(int val) { + this.id = val; + } + } } diff --git a/src/main/kotlin/org/springframework/data/repository/CrudRepositoryExtensions.kt b/src/main/kotlin/org/springframework/data/repository/CrudRepositoryExtensions.kt index 2b3ce5127..25e0cca87 100644 --- a/src/main/kotlin/org/springframework/data/repository/CrudRepositoryExtensions.kt +++ b/src/main/kotlin/org/springframework/data/repository/CrudRepositoryExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepository.kt b/src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepository.kt index 69309fe96..d25d13164 100644 --- a/src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepository.kt +++ b/src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import reactor.core.publisher.Mono * Interface for generic CRUD operations using Kotlin Coroutines on a repository for a specific type. * * @author Mark Paluch + * @author Christoph Strobl * @since 2.3 * @see Flow */ @@ -96,6 +97,18 @@ interface CoroutineCrudRepository : Repository { */ fun findAllById(ids: Iterable): Flow + /** + * Returns all instances of the type `T` with the given IDs. + * If some or all ids are not found, no entities are returned for these IDs. + * Note that the order of elements in the result is not guaranteed. + * + * @param ids must not be null nor contain any null values. + * @return [Flow] emitting the found entities. The size can be equal or less than the number of given + * ids. + * @throws IllegalArgumentException in case the given [ids][Iterable] or one of its items is null. + */ + fun findAllById(ids: Flow): Flow + /** * Returns the number of entities available. * @@ -128,6 +141,14 @@ interface CoroutineCrudRepository : Repository { */ suspend fun deleteAll(entities: Iterable) + /** + * Deletes all given entities. + * + * @param entityStream must not be null. + * @throws IllegalArgumentException in case the given [entityStream][Flow] is null. + */ + fun deleteAll(entityStream: Flow) + /** * Deletes all entities managed by the repository. */ diff --git a/src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineSortingRepository.kt b/src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineSortingRepository.kt index 813bb7f2f..07b967e1b 100644 --- a/src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineSortingRepository.kt +++ b/src/main/kotlin/org/springframework/data/repository/kotlin/CoroutineSortingRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/springframework/data/repository/core/support/DummyRepositoryFactory.java b/src/test/java/org/springframework/data/repository/core/support/DummyRepositoryFactory.java index 36b64eeb0..9a7180d8a 100644 --- a/src/test/java/org/springframework/data/repository/core/support/DummyRepositoryFactory.java +++ b/src/test/java/org/springframework/data/repository/core/support/DummyRepositoryFactory.java @@ -112,7 +112,7 @@ public class DummyRepositoryFactory extends RepositoryFactorySupport { /** * @author Mark Paluch */ - public static interface MyRepositoryQuery extends RepositoryQuery { + public interface MyRepositoryQuery extends RepositoryQuery { } } diff --git a/src/test/kotlin/org/springframework/data/convert/KotlinClassGeneratingEntityInstantiatorUnitTests.kt b/src/test/kotlin/org/springframework/data/convert/KotlinClassGeneratingEntityInstantiatorUnitTests.kt index cb20edbb7..ee430e064 100644 --- a/src/test/kotlin/org/springframework/data/convert/KotlinClassGeneratingEntityInstantiatorUnitTests.kt +++ b/src/test/kotlin/org/springframework/data/convert/KotlinClassGeneratingEntityInstantiatorUnitTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/kotlin/org/springframework/data/convert/ReflectionEntityInstantiatorDataClassUnitTests.kt b/src/test/kotlin/org/springframework/data/convert/ReflectionEntityInstantiatorDataClassUnitTests.kt index 5dacbbf48..bf18b1d18 100644 --- a/src/test/kotlin/org/springframework/data/convert/ReflectionEntityInstantiatorDataClassUnitTests.kt +++ b/src/test/kotlin/org/springframework/data/convert/ReflectionEntityInstantiatorDataClassUnitTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/kotlin/org/springframework/data/mapping/context/SimpleDataClass.kt b/src/test/kotlin/org/springframework/data/mapping/context/SimpleDataClass.kt index 1f4f653dd..d9ce4a6a9 100644 --- a/src/test/kotlin/org/springframework/data/mapping/context/SimpleDataClass.kt +++ b/src/test/kotlin/org/springframework/data/mapping/context/SimpleDataClass.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,5 +18,4 @@ package org.springframework.data.mapping.context /** * @author Mark Paluch */ -data class SimpleDataClass(val firstname: String, val lastname: String) { -} +data class SimpleDataClass(val firstname: String, val lastname: String) diff --git a/src/test/kotlin/org/springframework/data/mapping/context/TypeCreatingSyntheticClass.kt b/src/test/kotlin/org/springframework/data/mapping/context/TypeCreatingSyntheticClass.kt index 60c98c803..0cf1f0622 100644 --- a/src/test/kotlin/org/springframework/data/mapping/context/TypeCreatingSyntheticClass.kt +++ b/src/test/kotlin/org/springframework/data/mapping/context/TypeCreatingSyntheticClass.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,7 @@ package org.springframework.data.mapping.context /** * @author Mark Paluch */ -class TypeCreatingSyntheticClass { -} +class TypeCreatingSyntheticClass fun foobar(args: Array) { } diff --git a/src/test/kotlin/org/springframework/data/mapping/model/DataClasses.kt b/src/test/kotlin/org/springframework/data/mapping/model/DataClasses.kt index 54b7336a1..a61371a50 100644 --- a/src/test/kotlin/org/springframework/data/mapping/model/DataClasses.kt +++ b/src/test/kotlin/org/springframework/data/mapping/model/DataClasses.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,7 @@ import java.util.* /** * @author Mark Paluch */ -data class DataClassKt(val id: String) { -} +data class DataClassKt(val id: String) data class ExtendedDataClassKt(val id: Long, val name: String) { fun copy(name: String, id: Long): ExtendedDataClassKt { diff --git a/src/test/kotlin/org/springframework/data/mapping/model/PreferredConstructorDiscovererUnitTests.kt b/src/test/kotlin/org/springframework/data/mapping/model/PreferredConstructorDiscovererUnitTests.kt index 769547241..1ca1bb7ee 100644 --- a/src/test/kotlin/org/springframework/data/mapping/model/PreferredConstructorDiscovererUnitTests.kt +++ b/src/test/kotlin/org/springframework/data/mapping/model/PreferredConstructorDiscovererUnitTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,8 +109,7 @@ class PreferredConstructorDiscovererUnitTests { constructor(firstname: String, lastname: String) : this(firstname) } - class DefaultConstructor(val firstname: String = "foo") { - } + class DefaultConstructor(val firstname: String = "foo") class TwoDefaultConstructorsAnnotated(val firstname: String = "foo", val lastname: String = "bar") { diff --git a/src/test/kotlin/org/springframework/data/mapping/model/TypeCreatingSyntheticClass.kt b/src/test/kotlin/org/springframework/data/mapping/model/TypeCreatingSyntheticClass.kt index 05fba90ae..bcfbddd82 100644 --- a/src/test/kotlin/org/springframework/data/mapping/model/TypeCreatingSyntheticClass.kt +++ b/src/test/kotlin/org/springframework/data/mapping/model/TypeCreatingSyntheticClass.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,7 @@ package org.springframework.data.mapping.model /** * @author Mark Paluch */ -class TypeCreatingSyntheticClass { -} +class TypeCreatingSyntheticClass fun foobar(args: Array) { } diff --git a/src/test/kotlin/org/springframework/data/mapping/model/UnusedCustomCopy.kt b/src/test/kotlin/org/springframework/data/mapping/model/UnusedCustomCopy.kt index 3b5895c62..c20ef979d 100644 --- a/src/test/kotlin/org/springframework/data/mapping/model/UnusedCustomCopy.kt +++ b/src/test/kotlin/org/springframework/data/mapping/model/UnusedCustomCopy.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.mapping.model; +package org.springframework.data.mapping.model import java.sql.Timestamp diff --git a/src/test/kotlin/org/springframework/data/mapping/model/ValueClassKt.kt b/src/test/kotlin/org/springframework/data/mapping/model/ValueClassKt.kt index d7e9c39f5..cc748eb58 100644 --- a/src/test/kotlin/org/springframework/data/mapping/model/ValueClassKt.kt +++ b/src/test/kotlin/org/springframework/data/mapping/model/ValueClassKt.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,5 +18,4 @@ package org.springframework.data.mapping.model /** * @author Mark Paluch */ -class ValueClassKt(val immutable: String) { -} +class ValueClassKt(val immutable: String) diff --git a/src/test/kotlin/org/springframework/data/mapping/model/With32Args.kt b/src/test/kotlin/org/springframework/data/mapping/model/With32Args.kt index 591a214f6..b438e21b4 100644 --- a/src/test/kotlin/org/springframework/data/mapping/model/With32Args.kt +++ b/src/test/kotlin/org/springframework/data/mapping/model/With32Args.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/kotlin/org/springframework/data/mapping/model/With33Args.kt b/src/test/kotlin/org/springframework/data/mapping/model/With33Args.kt index b30a25ea0..13e8dd1ea 100644 --- a/src/test/kotlin/org/springframework/data/mapping/model/With33Args.kt +++ b/src/test/kotlin/org/springframework/data/mapping/model/With33Args.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/kotlin/org/springframework/data/repository/CrudRepositoryExtensionsTests.kt b/src/test/kotlin/org/springframework/data/repository/CrudRepositoryExtensionsTests.kt index 767bf15a9..bcba5028f 100644 --- a/src/test/kotlin/org/springframework/data/repository/CrudRepositoryExtensionsTests.kt +++ b/src/test/kotlin/org/springframework/data/repository/CrudRepositoryExtensionsTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2008-2019 the original author or authors. + * Copyright 2008-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/kotlin/org/springframework/data/repository/core/support/KotlinUserRepository.kt b/src/test/kotlin/org/springframework/data/repository/core/support/KotlinUserRepository.kt index 1c960a94e..4b0793dc7 100644 --- a/src/test/kotlin/org/springframework/data/repository/core/support/KotlinUserRepository.kt +++ b/src/test/kotlin/org/springframework/data/repository/core/support/KotlinUserRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepositoryCustomImplementationUnitTests.kt b/src/test/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepositoryCustomImplementationUnitTests.kt index 7343df9f6..d5589617a 100644 --- a/src/test/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepositoryCustomImplementationUnitTests.kt +++ b/src/test/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepositoryCustomImplementationUnitTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,8 +35,8 @@ import org.springframework.data.repository.sample.User class CoroutineCrudRepositoryCustomImplementationUnitTests { val backingRepository = mockk>() - lateinit var factory: DummyReactiveRepositoryFactory; - lateinit var coRepository: MyCoRepository; + lateinit var factory: DummyReactiveRepositoryFactory + lateinit var coRepository: MyCoRepository @Before fun before() { diff --git a/src/test/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepositoryUnitTests.kt b/src/test/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepositoryUnitTests.kt index 519d07875..01ff1d982 100644 --- a/src/test/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepositoryUnitTests.kt +++ b/src/test/kotlin/org/springframework/data/repository/kotlin/CoroutineCrudRepositoryUnitTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,16 @@ package org.springframework.data.repository.kotlin import io.mockk.every import io.mockk.mockk +import io.mockk.verify import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.assertj.core.api.Assertions.assertThat import org.junit.Before import org.junit.Test import org.mockito.Mockito +import org.reactivestreams.Publisher import org.springframework.data.repository.core.support.DummyReactiveRepositoryFactory import org.springframework.data.repository.reactive.ReactiveCrudRepository import org.springframework.data.repository.sample.User @@ -40,8 +43,8 @@ import rx.Single class CoroutineCrudRepositoryUnitTests { val backingRepository = mockk>() - lateinit var factory: DummyReactiveRepositoryFactory; - lateinit var coRepository: MyCoRepository; + lateinit var factory: DummyReactiveRepositoryFactory + lateinit var coRepository: MyCoRepository @Before fun before() { @@ -54,7 +57,7 @@ class CoroutineCrudRepositoryUnitTests { val sample = User() - every { backingRepository.findAll() }.returns(Flux.just(sample)) + every { backingRepository.findAll() } returns Flux.just(sample) val result = runBlocking { coRepository.findAll().toList() @@ -63,12 +66,54 @@ class CoroutineCrudRepositoryUnitTests { assertThat(result).hasSize(1).containsOnly(sample) } + @Test // DATACMNS-1508 + fun shouldInvokeFindAllById() { + + every { backingRepository.findAllById(any>()) } returns Flux.fromArray(arrayOf(User(), User())) + + val result = runBlocking { + coRepository.findAllById(flowOf("user-1", "user-2")).toList() + } + + assertThat(result).hasSize(2) + } + + @Test // DATACMNS-1508 + fun shouldInvokeSaveAllWhenGivenIterable() { + + val sample = listOf(User(), User()) + + every { backingRepository.saveAll(any>()) } returns Flux.fromIterable(sample) + + val result = runBlocking { + coRepository.saveAll(sample).toList() + } + + assertThat(result).containsExactlyElementsOf(sample) + } + + @Test // DATACMNS-1508 + fun shouldInvokeSaveAllWhenGivenFlow() { + + val u1 = User() + val u2 = User() + val sample = flowOf(u1, u2) + + every { backingRepository.saveAll(any>()) } returns Flux.fromArray(arrayOf(u1, u2)) + + val result = runBlocking { + coRepository.saveAll(sample).toList() + } + + assertThat(result).containsExactly(u1, u2) + } + @Test // DATACMNS-1508 fun shouldInvokeFindById() { val sample = User() - every { backingRepository.findById("foo") }.returns(Mono.just(sample)) + every { backingRepository.findById("foo") } returns Mono.just(sample) val result = runBlocking { coRepository.findById("foo") @@ -77,6 +122,60 @@ class CoroutineCrudRepositoryUnitTests { assertThat(result).isNotNull().isEqualTo(sample) } + @Test // DATACMNS-1508 + fun shouldInvokeExistsById() { + + every { backingRepository.existsById("foo") } returns Mono.just(true) + + val result = runBlocking { + coRepository.existsById("foo") + } + + assertThat(result).isTrue() + } + + @Test // DATACMNS-1508 + fun shouldInvokeDeleteAll() { + + every { backingRepository.deleteAll() } returns Mono.empty() + + runBlocking { + coRepository.deleteAll() + } + + verify { backingRepository.deleteAll() } + } + + @Test // DATACMNS-1508 + fun shouldInvokeDeleteAllWhenGivenIterable() { + + val sample = listOf(User(), User()) + + every { backingRepository.deleteAll(any>()) } returns Mono.empty() + + runBlocking { + coRepository.deleteAll(sample) + } + + verify { backingRepository.deleteAll(sample) } + } + + @Test // DATACMNS-1508 + fun shouldInvokeDeleteAllWhenGivenFlow() { + + val u1 = User() + val u2 = User() + val sample = flowOf(u1, u2) + + every { backingRepository.deleteAll(any>()) } returns Mono.empty() + + runBlocking { + coRepository.deleteAll(sample) + } + + verify { backingRepository.deleteAll(any>()) } + } + @Test // DATACMNS-1508 fun shouldBridgeQueryMethod() { diff --git a/src/test/kotlin/org/springframework/data/repository/query/ParameterUnitTests.kt b/src/test/kotlin/org/springframework/data/repository/query/ParameterUnitTests.kt index 298053ee0..27ebeb95b 100644 --- a/src/test/kotlin/org/springframework/data/repository/query/ParameterUnitTests.kt +++ b/src/test/kotlin/org/springframework/data/repository/query/ParameterUnitTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.Test import org.springframework.core.DefaultParameterNameDiscoverer import org.springframework.core.MethodParameter -import org.springframework.core.ParameterNameDiscoverer import kotlin.reflect.jvm.javaMethod /** diff --git a/src/test/kotlin/org/springframework/data/util/DummyInterface.kt b/src/test/kotlin/org/springframework/data/util/DummyInterface.kt index 3c3dabff2..d6e11c522 100644 --- a/src/test/kotlin/org/springframework/data/util/DummyInterface.kt +++ b/src/test/kotlin/org/springframework/data/util/DummyInterface.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/kotlin/org/springframework/data/util/TypeCreatingSyntheticClass.kt b/src/test/kotlin/org/springframework/data/util/TypeCreatingSyntheticClass.kt index fbc5b26f9..9b2f3e346 100644 --- a/src/test/kotlin/org/springframework/data/util/TypeCreatingSyntheticClass.kt +++ b/src/test/kotlin/org/springframework/data/util/TypeCreatingSyntheticClass.kt @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,7 @@ package org.springframework.data.util /** * @author Mark Paluch */ -class TypeCreatingSyntheticClass { -} +class TypeCreatingSyntheticClass fun foobar(args: Array) { }