DATACASS-462 - Adopt to ReactiveCrudRepository.findById(Publisher) and existsById(Publisher).
Related ticket: DATACMNS-1063. Related Pull Request: #106
This commit is contained in:
committed by
Christoph Strobl
parent
d7623f979b
commit
3f5d2589fb
@@ -162,14 +162,14 @@ public class SimpleReactiveCassandraRepository<T, ID> implements ReactiveCassand
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(reactor.core.publisher.Mono)
|
||||
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(org.reactivestreams.Publisher)
|
||||
*/
|
||||
@Override
|
||||
public Mono<T> findById(Mono<ID> mono) {
|
||||
public Mono<T> findById(Publisher<ID> publisher) {
|
||||
|
||||
Assert.notNull(mono, "The given id must not be null");
|
||||
Assert.notNull(publisher, "The given id must not be null");
|
||||
|
||||
return mono.flatMap(id -> operations.selectOneById(id, entityInformation.getJavaType()));
|
||||
return Mono.from(publisher).flatMap(id -> operations.selectOneById(id, entityInformation.getJavaType()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -184,14 +184,14 @@ public class SimpleReactiveCassandraRepository<T, ID> implements ReactiveCassand
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#existsById(reactor.core.publisher.Mono)
|
||||
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#existsById(org.reactivestreams.Publisher)
|
||||
*/
|
||||
@Override
|
||||
public Mono<Boolean> existsById(Mono<ID> mono) {
|
||||
public Mono<Boolean> existsById(Publisher<ID> publisher) {
|
||||
|
||||
Assert.notNull(mono, "The given id must not be null");
|
||||
Assert.notNull(publisher, "The given id must not be null");
|
||||
|
||||
return mono.flatMap(id -> operations.exists(id, entityInformation.getJavaType()));
|
||||
return Mono.from(publisher).flatMap(id -> operations.exists(id, entityInformation.getJavaType()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -127,6 +127,15 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
StepVerifier.create(repository.existsById(Mono.just(dave.getId()))).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void existsByFluxOfIdShouldReturnTrueForExistingObject() {
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.existsById(Flux.just(dave.getId(), oliver.getId()))).expectNext(true)
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void existsByEmptyMonoOfIdShouldReturnEmptyMono() {
|
||||
StepVerifier.create(repository.existsById(Mono.empty())).verifyComplete();
|
||||
@@ -153,6 +162,14 @@ public class SimpleReactiveCassandraRepositoryIntegrationTests extends AbstractK
|
||||
StepVerifier.create(repository.findById(Mono.just(dave.getId()))).expectNext(dave).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-462
|
||||
public void findByIdByFluxOfIdShouldReturnTrueForExistingObject() {
|
||||
|
||||
insertTestData();
|
||||
|
||||
StepVerifier.create(repository.findById(Flux.just(dave.getId(), oliver.getId()))).expectNext(dave).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-335
|
||||
public void findByIdByEmptyMonoOfIdShouldReturnEmptyMono() {
|
||||
StepVerifier.create(repository.findById(Mono.empty())).verifyComplete();
|
||||
|
||||
Reference in New Issue
Block a user