committed by
Jens Schauder
parent
20a1220cd1
commit
d4036ec0a9
@@ -17,7 +17,7 @@ package org.springframework.data.repository.core.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -30,7 +30,7 @@ import org.reactivestreams.Publisher;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
|
||||
import org.springframework.data.repository.reactive.RxJava2CrudRepository;
|
||||
import org.springframework.data.repository.reactive.RxJava3CrudRepository;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ReactiveRepositoryInformation}.
|
||||
@@ -45,18 +45,18 @@ class ReactiveRepositoryInformationUnitTests {
|
||||
static final Class<ReactiveJavaInterfaceWithGenerics> BASE_CLASS = ReactiveJavaInterfaceWithGenerics.class;
|
||||
|
||||
@Test // DATACMNS-988
|
||||
void discoversRxJava2MethodWithoutComparingReturnType() throws Exception {
|
||||
void discoversRxJava3MethodWithoutComparingReturnType() throws Exception {
|
||||
|
||||
Method reference = extractTargetMethodFromRepository(RxJava2InterfaceWithGenerics.class, "deleteAll");
|
||||
Method reference = extractTargetMethodFromRepository(RxJava3InterfaceWithGenerics.class, "deleteAll");
|
||||
|
||||
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
|
||||
assertThat(reference.getName()).isEqualTo("deleteAll");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-988
|
||||
void discoversRxJava2MethodWithConvertibleArguments() throws Exception {
|
||||
void discoversRxJava3MethodWithConvertibleArguments() throws Exception {
|
||||
|
||||
Method reference = extractTargetMethodFromRepository(RxJava2InterfaceWithGenerics.class, "saveAll", Flowable.class);
|
||||
Method reference = extractTargetMethodFromRepository(RxJava3InterfaceWithGenerics.class, "saveAll", Flowable.class);
|
||||
|
||||
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
|
||||
assertThat(reference.getName()).isEqualTo("saveAll");
|
||||
@@ -113,7 +113,7 @@ class ReactiveRepositoryInformationUnitTests {
|
||||
return composition.findMethod(repositoryType.getMethod(methodName, args)).get();
|
||||
}
|
||||
|
||||
interface RxJava2InterfaceWithGenerics extends RxJava2CrudRepository<User, String> {}
|
||||
interface RxJava3InterfaceWithGenerics extends RxJava3CrudRepository<User, String> {}
|
||||
|
||||
interface ReactiveJavaInterfaceWithGenerics extends ReactiveCrudRepository<User, String> {}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ package org.springframework.data.repository.core.support;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Maybe;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -72,7 +72,7 @@ class ReactiveWrapperRepositoryFactorySupportUnitTests {
|
||||
Long id = 1L;
|
||||
when(backingRepo.findById(id)).thenReturn(Mono.just(true));
|
||||
|
||||
RxJava2ConvertingRepository repository = factory.getRepository(RxJava2ConvertingRepository.class);
|
||||
RxJava3ConvertingRepository repository = factory.getRepository(RxJava3ConvertingRepository.class);
|
||||
repository.findById(id);
|
||||
|
||||
verify(backingRepo, times(1)).findById(id);
|
||||
@@ -84,14 +84,14 @@ class ReactiveWrapperRepositoryFactorySupportUnitTests {
|
||||
Serializable id = 1L;
|
||||
when(backingRepo.deleteById(id)).thenReturn(Mono.empty());
|
||||
|
||||
RxJava2ConvertingRepository repository = factory.getRepository(RxJava2ConvertingRepository.class);
|
||||
RxJava3ConvertingRepository repository = factory.getRepository(RxJava3ConvertingRepository.class);
|
||||
repository.deleteById(id);
|
||||
|
||||
verify(backingRepo, times(1)).deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
interface RxJava2ConvertingRepository extends Repository<Object, Long> {
|
||||
interface RxJava3ConvertingRepository extends Repository<Object, Long> {
|
||||
|
||||
Maybe<Boolean> findById(Serializable id);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.repository.query;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -102,11 +102,6 @@ class QueryExecutionConvertersUnitTests {
|
||||
assertThat(QueryExecutionConverters.supportsUnwrapping(Single.class)).isFalse();
|
||||
assertThat(QueryExecutionConverters.supportsUnwrapping(Completable.class)).isFalse();
|
||||
assertThat(QueryExecutionConverters.supportsUnwrapping(Observable.class)).isFalse();
|
||||
assertThat(QueryExecutionConverters.supportsUnwrapping(io.reactivex.Single.class)).isFalse();
|
||||
assertThat(QueryExecutionConverters.supportsUnwrapping(io.reactivex.Maybe.class)).isFalse();
|
||||
assertThat(QueryExecutionConverters.supportsUnwrapping(io.reactivex.Completable.class)).isFalse();
|
||||
assertThat(QueryExecutionConverters.supportsUnwrapping(io.reactivex.Flowable.class)).isFalse();
|
||||
assertThat(QueryExecutionConverters.supportsUnwrapping(io.reactivex.Observable.class)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-714
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.repository.util;
|
||||
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.*;
|
||||
|
||||
import io.reactivex.Maybe;
|
||||
import io.smallrye.mutiny.Multi;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
@@ -47,16 +46,6 @@ class ReactiveWrapperConvertersUnitTests {
|
||||
assertThat(ReactiveWrapperConverters.supports(Object.class)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void shouldSupportRxJava2Types() {
|
||||
|
||||
assertThat(ReactiveWrapperConverters.supports(io.reactivex.Single.class)).isTrue();
|
||||
assertThat(ReactiveWrapperConverters.supports(io.reactivex.Maybe.class)).isTrue();
|
||||
assertThat(ReactiveWrapperConverters.supports(io.reactivex.Observable.class)).isTrue();
|
||||
assertThat(ReactiveWrapperConverters.supports(io.reactivex.Flowable.class)).isTrue();
|
||||
assertThat(ReactiveWrapperConverters.supports(io.reactivex.Completable.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1653
|
||||
void shouldSupportRxJava3Types() {
|
||||
|
||||
@@ -88,122 +77,6 @@ class ReactiveWrapperConvertersUnitTests {
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Mono.class)).isSameAs(foo);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertMonoToRxJava2Single() {
|
||||
|
||||
Mono<String> foo = Mono.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, io.reactivex.Single.class))
|
||||
.isInstanceOf(io.reactivex.Single.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2SingleToMono() {
|
||||
|
||||
io.reactivex.Single<String> foo = io.reactivex.Single.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Mono.class)).isInstanceOf(Mono.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2SingleToPublisher() {
|
||||
|
||||
io.reactivex.Single<String> foo = io.reactivex.Single.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Publisher.class)).isInstanceOf(Publisher.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2MaybeToMono() {
|
||||
|
||||
io.reactivex.Maybe<String> foo = io.reactivex.Maybe.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Mono.class)).isInstanceOf(Mono.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2MaybeToFlux() {
|
||||
|
||||
io.reactivex.Maybe<String> foo = io.reactivex.Maybe.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Flux.class)).isInstanceOf(Flux.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2MaybeToPublisher() {
|
||||
|
||||
io.reactivex.Maybe<String> foo = io.reactivex.Maybe.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Publisher.class)).isInstanceOf(Publisher.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2FlowableToMono() {
|
||||
|
||||
io.reactivex.Flowable<String> foo = io.reactivex.Flowable.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Mono.class)).isInstanceOf(Mono.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2FlowableToFlux() {
|
||||
|
||||
io.reactivex.Flowable<String> foo = io.reactivex.Flowable.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Flux.class)).isInstanceOf(Flux.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldCastRxJava2FlowableToPublisher() {
|
||||
|
||||
io.reactivex.Flowable<String> foo = io.reactivex.Flowable.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Publisher.class)).isSameAs(foo);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2ObservableToMono() {
|
||||
|
||||
io.reactivex.Observable<String> foo = io.reactivex.Observable.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Mono.class)).isInstanceOf(Mono.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2ObservableToFlux() {
|
||||
|
||||
io.reactivex.Observable<String> foo = io.reactivex.Observable.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Flux.class)).isInstanceOf(Flux.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2ObservableToSingle() {
|
||||
|
||||
io.reactivex.Observable<String> foo = io.reactivex.Observable.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, io.reactivex.Single.class))
|
||||
.isInstanceOf(io.reactivex.Single.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2ObservableToMaybe() {
|
||||
|
||||
io.reactivex.Observable<String> foo = io.reactivex.Observable.empty();
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Maybe.class)).isInstanceOf(Maybe.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertRxJava2ObservableToPublisher() {
|
||||
|
||||
io.reactivex.Observable<String> foo = io.reactivex.Observable.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, Publisher.class)).isInstanceOf(Publisher.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-988
|
||||
void toWrapperShouldConvertPublisherToRxJava2Observable() {
|
||||
|
||||
Flux<String> foo = Flux.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, io.reactivex.Observable.class))
|
||||
.isInstanceOf(io.reactivex.Observable.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-988
|
||||
void toWrapperShouldConvertPublisherToRxJava2Flowable() {
|
||||
|
||||
Flux<String> foo = Flux.just("foo");
|
||||
assertThat(ReactiveWrapperConverters.toWrapper(foo, io.reactivex.Flowable.class))
|
||||
.isInstanceOf(io.reactivex.Flowable.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void toWrapperShouldConvertMonoToFlux() {
|
||||
|
||||
@@ -227,38 +100,6 @@ class ReactiveWrapperConvertersUnitTests {
|
||||
assertThat(map.next().block()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void shouldMapRxJava2Single() {
|
||||
|
||||
io.reactivex.Single<String> foo = io.reactivex.Single.just("foo");
|
||||
io.reactivex.Single<Long> map = ReactiveWrapperConverters.map(foo, source -> 1L);
|
||||
assertThat(map.blockingGet()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void shouldMapRxJava2Maybe() {
|
||||
|
||||
io.reactivex.Maybe<String> foo = io.reactivex.Maybe.just("foo");
|
||||
io.reactivex.Maybe<Long> map = ReactiveWrapperConverters.map(foo, source -> 1L);
|
||||
assertThat(map.toSingle().blockingGet()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void shouldMapRxJava2Observable() {
|
||||
|
||||
io.reactivex.Observable<String> foo = io.reactivex.Observable.just("foo");
|
||||
io.reactivex.Observable<Long> map = ReactiveWrapperConverters.map(foo, source -> 1L);
|
||||
assertThat(map.blockingFirst()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
void shouldMapRxJava2Flowable() {
|
||||
|
||||
io.reactivex.Flowable<String> foo = io.reactivex.Flowable.just("foo");
|
||||
io.reactivex.Flowable<Long> map = ReactiveWrapperConverters.map(foo, source -> 1L);
|
||||
assertThat(map.blockingFirst()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1653
|
||||
void shouldMapRxJava3Single() {
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.repository.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.Flowable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -41,13 +39,8 @@ class ReactiveWrappersUnitTests {
|
||||
|
||||
assertThat(ReactiveWrappers.isNoValueType(Mono.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(Flux.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(Completable.class)).isTrue();
|
||||
assertThat(ReactiveWrappers.isNoValueType(CompletableFuture.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(Publisher.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(io.reactivex.Single.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(io.reactivex.Maybe.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(Flowable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(io.reactivex.Observable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(io.reactivex.rxjava3.core.Single.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(io.reactivex.rxjava3.core.Maybe.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isNoValueType(io.reactivex.rxjava3.core.Flowable.class)).isFalse();
|
||||
@@ -61,14 +54,8 @@ class ReactiveWrappersUnitTests {
|
||||
|
||||
assertThat(ReactiveWrappers.isSingleValueType(Mono.class)).isTrue();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(Flux.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(Completable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(CompletableFuture.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(Publisher.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(io.reactivex.Single.class)).isTrue();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(io.reactivex.Completable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(io.reactivex.Maybe.class)).isTrue();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(Flowable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(io.reactivex.Observable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(io.reactivex.rxjava3.core.Single.class)).isTrue();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(io.reactivex.rxjava3.core.Completable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(io.reactivex.rxjava3.core.Maybe.class)).isTrue();
|
||||
@@ -83,13 +70,8 @@ class ReactiveWrappersUnitTests {
|
||||
|
||||
assertThat(ReactiveWrappers.isMultiValueType(Mono.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isMultiValueType(Flux.class)).isTrue();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(Completable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(CompletableFuture.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isMultiValueType(Publisher.class)).isTrue();
|
||||
assertThat(ReactiveWrappers.isMultiValueType(io.reactivex.Single.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(io.reactivex.Completable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isMultiValueType(Flowable.class)).isTrue();
|
||||
assertThat(ReactiveWrappers.isMultiValueType(io.reactivex.Observable.class)).isTrue();
|
||||
assertThat(ReactiveWrappers.isMultiValueType(io.reactivex.rxjava3.core.Single.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isSingleValueType(io.reactivex.rxjava3.core.Completable.class)).isFalse();
|
||||
assertThat(ReactiveWrappers.isMultiValueType(io.reactivex.rxjava3.core.Flowable.class)).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user