Browse Source

DATAMONGO-2652 - Polishing.

Reorder implementation methods. Reduce visibility of test methods according to JUnit 5 requirements.

Original pull request: #892.
pull/895/head
Mark Paluch 5 years ago
parent
commit
ab4fe5cb0b
No known key found for this signature in database
GPG Key ID: 4406B84C1661DCD1
  1. 12
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ReactiveMongoRepository.java
  2. 128
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java
  3. 363
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleReactiveMongoRepository.java
  4. 120
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/ReactiveMongoRepositoryTests.java
  5. 70
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepositoryTests.java

12
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ReactiveMongoRepository.java

@ -64,16 +64,4 @@ public interface ReactiveMongoRepository<T, ID> extends ReactiveSortingRepositor
*/ */
<S extends T> Flux<S> insert(Publisher<S> entities); <S extends T> Flux<S> insert(Publisher<S> entities);
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.QueryByExampleExecutor#findAll(org.springframework.data.domain.Example)
*/
<S extends T> Flux<S> findAll(Example<S> example);
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.QueryByExampleExecutor#findAll(org.springframework.data.domain.Example, org.springframework.data.domain.Sort)
*/
<S extends T> Flux<S> findAll(Example<S> example, Sort sort);
} }

128
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java

@ -73,6 +73,10 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
this.mongoOperations = mongoOperations; this.mongoOperations = mongoOperations;
} }
// -------------------------------------------------------------------------
// Methods from CrudRepository
// -------------------------------------------------------------------------
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#save(java.lang.Object) * @see org.springframework.data.repository.CrudRepository#save(java.lang.Object)
@ -136,6 +140,27 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
entityInformation.getCollectionName()); entityInformation.getCollectionName());
} }
/*
* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#findAll()
*/
@Override
public List<T> findAll() {
return findAll(new Query());
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#findAllById(java.lang.Iterable)
*/
@Override
public Iterable<T> findAllById(Iterable<ID> ids) {
Assert.notNull(ids, "The given Ids of entities not be null!");
return findAll(getIdQuery(ids));
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#count() * @see org.springframework.data.repository.CrudRepository#count()
@ -178,55 +203,42 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#delete(java.lang.Iterable) * @see org.springframework.data.repository.CrudRepository#deleteAllById(java.lang.Iterable)
*/ */
@Override
public void deleteAll(Iterable<? extends T> entities) {
Assert.notNull(entities, "The given Iterable of entities must not be null!");
entities.forEach(this::delete);
}
@Override @Override
public void deleteAllById(Iterable<? extends ID> ids) { public void deleteAllById(Iterable<? extends ID> ids) {
Assert.notNull(ids, "The given Iterable of ids must not be null!"); Assert.notNull(ids, "The given Iterable of ids must not be null!");
ids.forEach(this::deleteById); mongoOperations.remove(getIdQuery(ids), entityInformation.getJavaType(),
entityInformation.getCollectionName());
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#deleteAll() * @see org.springframework.data.repository.CrudRepository#delete(java.lang.Iterable)
*/ */
@Override @Override
public void deleteAll() { public void deleteAll(Iterable<? extends T> entities) {
mongoOperations.remove(new Query(), entityInformation.getCollectionName());
}
/* Assert.notNull(entities, "The given Iterable of entities must not be null!");
* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#findAll() entities.forEach(this::delete);
*/
@Override
public List<T> findAll() {
return findAll(new Query());
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#findAllById(java.lang.Iterable) * @see org.springframework.data.repository.CrudRepository#deleteAll()
*/ */
@Override @Override
public Iterable<T> findAllById(Iterable<ID> ids) { public void deleteAll() {
mongoOperations.remove(new Query(), entityInformation.getCollectionName());
Assert.notNull(ids, "The given Ids of entities not be null!");
return findAll(new Query(new Criteria(entityInformation.getIdAttribute())
.in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList()))));
} }
// -------------------------------------------------------------------------
// Methods from PagingAndSortingRepository
// -------------------------------------------------------------------------
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.PagingAndSortingRepository#findAll(org.springframework.data.domain.Pageable) * @see org.springframework.data.repository.PagingAndSortingRepository#findAll(org.springframework.data.domain.Pageable)
@ -254,6 +266,10 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
return findAll(new Query().with(sort)); return findAll(new Query().with(sort));
} }
// -------------------------------------------------------------------------
// Methods from MongoRepository
// -------------------------------------------------------------------------
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.mongodb.repository.MongoRepository#insert(java.lang.Object) * @see org.springframework.data.mongodb.repository.MongoRepository#insert(java.lang.Object)
@ -284,23 +300,33 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
return new ArrayList<>(mongoOperations.insertAll(list)); return new ArrayList<>(mongoOperations.insertAll(list));
} }
// -------------------------------------------------------------------------
// Methods from QueryByExampleExecutor
// -------------------------------------------------------------------------
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.mongodb.repository.MongoRepository#findAllByExample(org.springframework.data.domain.Example, org.springframework.data.domain.Pageable) * @see org.springframework.data.repository.query.QueryByExampleExecutor#findOne(org.springframework.data.domain.Example)
*/ */
@Override @Override
public <S extends T> Page<S> findAll(final Example<S> example, Pageable pageable) { public <S extends T> Optional<S> findOne(Example<S> example) {
Assert.notNull(example, "Sample must not be null!"); Assert.notNull(example, "Sample must not be null!");
Assert.notNull(pageable, "Pageable must not be null!");
Query query = new Query(new Criteria().alike(example)) // Query query = new Query(new Criteria().alike(example)) //
.collation(entityInformation.getCollation()).with(pageable); // .collation(entityInformation.getCollation());
List<S> list = mongoOperations.find(query, example.getProbeType(), entityInformation.getCollectionName()); return Optional
.ofNullable(mongoOperations.findOne(query, example.getProbeType(), entityInformation.getCollectionName()));
}
return PageableExecutionUtils.getPage(list, pageable, /*
() -> mongoOperations.count(Query.of(query).limit(-1).skip(-1), example.getProbeType(), entityInformation.getCollectionName())); * (non-Javadoc)
* @see org.springframework.data.mongodb.repository.MongoRepository#findAllByExample(org.springframework.data.domain.Example)
*/
@Override
public <S extends T> List<S> findAll(Example<S> example) {
return findAll(example, Sort.unsorted());
} }
/* /*
@ -322,27 +348,21 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.mongodb.repository.MongoRepository#findAllByExample(org.springframework.data.domain.Example) * @see org.springframework.data.mongodb.repository.MongoRepository#findAllByExample(org.springframework.data.domain.Example, org.springframework.data.domain.Pageable)
*/
@Override
public <S extends T> List<S> findAll(Example<S> example) {
return findAll(example, Sort.unsorted());
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.QueryByExampleExecutor#findOne(org.springframework.data.domain.Example)
*/ */
@Override @Override
public <S extends T> Optional<S> findOne(Example<S> example) { public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable) {
Assert.notNull(example, "Sample must not be null!"); Assert.notNull(example, "Sample must not be null!");
Assert.notNull(pageable, "Pageable must not be null!");
Query query = new Query(new Criteria().alike(example)) // Query query = new Query(new Criteria().alike(example)) //
.collation(entityInformation.getCollation()); .collation(entityInformation.getCollation()).with(pageable); //
return Optional List<S> list = mongoOperations.find(query, example.getProbeType(), entityInformation.getCollectionName());
.ofNullable(mongoOperations.findOne(query, example.getProbeType(), entityInformation.getCollectionName()));
return PageableExecutionUtils.getPage(list, pageable,
() -> mongoOperations.count(Query.of(query).limit(-1).skip(-1), example.getProbeType(), entityInformation.getCollectionName()));
} }
/* /*
@ -375,6 +395,10 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
return mongoOperations.exists(query, example.getProbeType(), entityInformation.getCollectionName()); return mongoOperations.exists(query, example.getProbeType(), entityInformation.getCollectionName());
} }
// -------------------------------------------------------------------------
// Utility methods
// -------------------------------------------------------------------------
private Query getIdQuery(Object id) { private Query getIdQuery(Object id) {
return new Query(getIdCriteria(id)); return new Query(getIdCriteria(id));
} }
@ -383,6 +407,11 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
return where(entityInformation.getIdAttribute()).is(id); return where(entityInformation.getIdAttribute()).is(id);
} }
private Query getIdQuery(Iterable<? extends ID> ids) {
return new Query(new Criteria(entityInformation.getIdAttribute())
.in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())));
}
private List<T> findAll(@Nullable Query query) { private List<T> findAll(@Nullable Query query) {
if (query == null) { if (query == null) {
@ -391,4 +420,5 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
return mongoOperations.find(query, entityInformation.getJavaType(), entityInformation.getCollectionName()); return mongoOperations.find(query, entityInformation.getJavaType(), entityInformation.getCollectionName());
} }
} }

363
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleReactiveMongoRepository.java

@ -17,12 +17,16 @@ package org.springframework.data.mongodb.repository.support;
import static org.springframework.data.mongodb.core.query.Criteria.*; import static org.springframework.data.mongodb.core.query.Criteria.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
import org.springframework.dao.IncorrectResultSizeDataAccessException; import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.data.domain.Example; import org.springframework.data.domain.Example;
@ -38,9 +42,6 @@ import org.springframework.util.Assert;
import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.DeleteResult;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/** /**
* Reactive repository base implementation for Mongo. * Reactive repository base implementation for Mongo.
* *
@ -66,52 +67,79 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement
this.mongoOperations = mongoOperations; this.mongoOperations = mongoOperations;
} }
// -------------------------------------------------------------------------
// Methods from ReactiveCrudRepository
// -------------------------------------------------------------------------
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(java.lang.Object) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#save(java.lang.Object)
*/ */
@Override @Override
public Mono<T> findById(ID id) { public <S extends T> Mono<S> save(S entity) {
Assert.notNull(id, "The given id must not be null!"); Assert.notNull(entity, "Entity must not be null!");
return mongoOperations.findById(id, entityInformation.getJavaType(), entityInformation.getCollectionName()); if (entityInformation.isNew(entity)) {
return mongoOperations.insert(entity, entityInformation.getCollectionName());
}
return mongoOperations.save(entity, entityInformation.getCollectionName());
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(org.reactivestreams.Publisher) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#saveAll(java.lang.Iterable)
*/ */
@Override @Override
public Mono<T> findById(Publisher<ID> publisher) { public <S extends T> Flux<S> saveAll(Iterable<S> entities) {
Assert.notNull(publisher, "The given id must not be null!"); Assert.notNull(entities, "The given Iterable of entities must not be null!");
return Mono.from(publisher).flatMap( Streamable<S> source = Streamable.of(entities);
id -> mongoOperations.findById(id, entityInformation.getJavaType(), entityInformation.getCollectionName()));
return source.stream().allMatch(entityInformation::isNew) ? //
mongoOperations.insert(source.stream().collect(Collectors.toList()), entityInformation.getCollectionName()) : //
Flux.fromIterable(entities).flatMap(this::save);
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#findOne(org.springframework.data.domain.Example) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#saveAll(org.reactivestreams.Publisher)
*/ */
@Override @Override
public <S extends T> Mono<S> findOne(Example<S> example) { public <S extends T> Flux<S> saveAll(Publisher<S> entityStream) {
Assert.notNull(example, "Sample must not be null!"); Assert.notNull(entityStream, "The given Publisher of entities must not be null!");
Query query = new Query(new Criteria().alike(example)) // return Flux.from(entityStream).flatMap(entity -> entityInformation.isNew(entity) ? //
.collation(entityInformation.getCollation()) // mongoOperations.insert(entity, entityInformation.getCollectionName()).then(Mono.just(entity)) : //
.limit(2); mongoOperations.save(entity, entityInformation.getCollectionName()).then(Mono.just(entity)));
}
return mongoOperations.find(query, example.getProbeType(), entityInformation.getCollectionName()).buffer(2) /*
.map(vals -> { * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(java.lang.Object)
*/
@Override
public Mono<T> findById(ID id) {
if (vals.size() > 1) { Assert.notNull(id, "The given id must not be null!");
throw new IncorrectResultSizeDataAccessException(1);
} return mongoOperations.findById(id, entityInformation.getJavaType(), entityInformation.getCollectionName());
return vals.iterator().next(); }
}).next();
/*
* (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findById(org.reactivestreams.Publisher)
*/
@Override
public Mono<T> findById(Publisher<ID> publisher) {
Assert.notNull(publisher, "The given id must not be null!");
return Mono.from(publisher).flatMap(
id -> mongoOperations.findById(id, entityInformation.getJavaType(), entityInformation.getCollectionName()));
} }
/* /*
@ -138,22 +166,6 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement
return Mono.from(publisher).flatMap(id -> mongoOperations.exists(getIdQuery(id), entityInformation.getJavaType(), return Mono.from(publisher).flatMap(id -> mongoOperations.exists(getIdQuery(id), entityInformation.getJavaType(),
entityInformation.getCollectionName())); entityInformation.getCollectionName()));
}
/*
* (non-Javadoc)
* @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#exists(org.springframework.data.domain.Example)
*/
@Override
public <S extends T> Mono<Boolean> exists(Example<S> example) {
Assert.notNull(example, "Sample must not be null!");
Query query = new Query(new Criteria().alike(example)) //
.collation(entityInformation.getCollation());
return mongoOperations.exists(query, example.getProbeType(), entityInformation.getCollectionName());
} }
/* /*
@ -174,8 +186,7 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement
Assert.notNull(ids, "The given Iterable of Id's must not be null!"); Assert.notNull(ids, "The given Iterable of Id's must not be null!");
return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) return findAll(getIdQuery(ids));
.in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList()))));
} }
/* /*
@ -192,265 +203,270 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveSortingRepository#findAll(org.springframework.data.domain.Sort) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#count()
*/ */
@Override @Override
public Flux<T> findAll(Sort sort) { public Mono<Long> count() {
return mongoOperations.count(new Query(), entityInformation.getCollectionName());
Assert.notNull(sort, "Sort must not be null!");
return findAll(new Query().with(sort));
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#findAll(org.springframework.data.domain.Example, org.springframework.data.domain.Sort) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteById(java.lang.Object)
*/ */
@Override @Override
public <S extends T> Flux<S> findAll(Example<S> example, Sort sort) { public Mono<Void> deleteById(ID id) {
Assert.notNull(example, "Sample must not be null!");
Assert.notNull(sort, "Sort must not be null!");
Query query = new Query(new Criteria().alike(example)) // Assert.notNull(id, "The given id must not be null!");
.collation(entityInformation.getCollation()) //
.with(sort);
return mongoOperations.find(query, example.getProbeType(), entityInformation.getCollectionName()); return mongoOperations
.remove(getIdQuery(id), entityInformation.getJavaType(), entityInformation.getCollectionName()).then();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#findAll(org.springframework.data.domain.Example) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteById(org.reactivestreams.Publisher)
*/ */
@Override @Override
public <S extends T> Flux<S> findAll(Example<S> example) { public Mono<Void> deleteById(Publisher<ID> publisher) {
Assert.notNull(example, "Example must not be null!"); Assert.notNull(publisher, "Id must not be null!");
return findAll(example, Sort.unsorted()); return Mono.from(publisher).flatMap(id -> mongoOperations.remove(getIdQuery(id), entityInformation.getJavaType(),
entityInformation.getCollectionName())).then();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#count() * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#delete(java.lang.Object)
*/ */
@Override @Override
public Mono<Long> count() { public Mono<Void> delete(T entity) {
return mongoOperations.count(new Query(), entityInformation.getCollectionName());
}
/* Assert.notNull(entity, "The given entity must not be null!");
* (non-Javadoc)
* @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#count(org.springframework.data.domain.Example)
*/
@Override
public <S extends T> Mono<Long> count(Example<S> example) {
Assert.notNull(example, "Sample must not be null!"); Mono<DeleteResult> remove = mongoOperations.remove(entity, entityInformation.getCollectionName());
Query query = new Query(new Criteria().alike(example)) // if (entityInformation.isVersioned()) {
.collation(entityInformation.getCollation());
return mongoOperations.count(query, example.getProbeType(), entityInformation.getCollectionName()); remove = remove.handle((deleteResult, sink) -> {
if (deleteResult.wasAcknowledged() && deleteResult.getDeletedCount() == 0) {
sink.error(new OptimisticLockingFailureException(String.format(
"The entity with id %s with version %s in %s cannot be deleted! Was it modified or deleted in the meantime?",
entityInformation.getId(entity), entityInformation.getVersion(entity),
entityInformation.getCollectionName())));
} else {
sink.next(deleteResult);
}
});
}
return remove.then();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(java.lang.Object) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAllById(java.lang.Iterable)
*/ */
@Override @Override
public <S extends T> Mono<S> insert(S entity) { public Mono<Void> deleteAllById(Iterable<? extends ID> ids) {
Assert.notNull(entity, "Entity must not be null!"); Assert.notNull(ids, "The given Iterable of Id's must not be null!");
return mongoOperations.insert(entity, entityInformation.getCollectionName()); return mongoOperations
.remove(getIdQuery(ids), entityInformation.getJavaType(), entityInformation.getCollectionName()).then();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(java.lang.Iterable) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll(java.lang.Iterable)
*/ */
@Override @Override
public <S extends T> Flux<S> insert(Iterable<S> entities) { public Mono<Void> deleteAll(Iterable<? extends T> entities) {
Assert.notNull(entities, "The given Iterable of entities must not be null!"); Assert.notNull(entities, "The given Iterable of entities must not be null!");
List<S> source = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); Collection<?> idCollection = StreamUtils.createStreamFromIterator(entities.iterator()).map(entityInformation::getId)
.collect(Collectors.toList());
return source.isEmpty() ? Flux.empty() : Flux.from(mongoOperations.insertAll(source)); Criteria idsInCriteria = where(entityInformation.getIdAttribute()).in(idCollection);
return mongoOperations
.remove(new Query(idsInCriteria), entityInformation.getJavaType(), entityInformation.getCollectionName())
.then();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(org.reactivestreams.Publisher) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll(org.reactivestreams.Publisher)
*/ */
@Override @Override
public <S extends T> Flux<S> insert(Publisher<S> entities) { public Mono<Void> deleteAll(Publisher<? extends T> entityStream) {
Assert.notNull(entities, "The given Publisher of entities must not be null!"); Assert.notNull(entityStream, "The given Publisher of entities must not be null!");
return Flux.from(entities).flatMap(entity -> mongoOperations.insert(entity, entityInformation.getCollectionName())); return Flux.from(entityStream)//
.map(entityInformation::getRequiredId)//
.flatMap(this::deleteById)//
.then();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#save(java.lang.Object) * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll()
*/ */
@Override @Override
public <S extends T> Mono<S> save(S entity) { public Mono<Void> deleteAll() {
return mongoOperations.remove(new Query(), entityInformation.getCollectionName()).then(Mono.empty());
Assert.notNull(entity, "Entity must not be null!");
if (entityInformation.isNew(entity)) {
return mongoOperations.insert(entity, entityInformation.getCollectionName());
}
return mongoOperations.save(entity, entityInformation.getCollectionName());
} }
// -------------------------------------------------------------------------
// Methods from ReactiveSortingRepository
// -------------------------------------------------------------------------
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#saveAll(java.lang.Iterable) * @see org.springframework.data.repository.reactive.ReactiveSortingRepository#findAll(org.springframework.data.domain.Sort)
*/ */
@Override @Override
public <S extends T> Flux<S> saveAll(Iterable<S> entities) { public Flux<T> findAll(Sort sort) {
Assert.notNull(entities, "The given Iterable of entities must not be null!");
Streamable<S> source = Streamable.of(entities); Assert.notNull(sort, "Sort must not be null!");
return source.stream().allMatch(entityInformation::isNew) ? // return findAll(new Query().with(sort));
mongoOperations.insert(source.stream().collect(Collectors.toList()), entityInformation.getCollectionName()) : //
Flux.fromIterable(entities).flatMap(this::save);
} }
// -------------------------------------------------------------------------
// Methods from ReactiveMongoRepository
// -------------------------------------------------------------------------
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#saveAll(org.reactivestreams.Publisher) * @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(java.lang.Object)
*/ */
@Override @Override
public <S extends T> Flux<S> saveAll(Publisher<S> entityStream) { public <S extends T> Mono<S> insert(S entity) {
Assert.notNull(entityStream, "The given Publisher of entities must not be null!"); Assert.notNull(entity, "Entity must not be null!");
return Flux.from(entityStream).flatMap(entity -> entityInformation.isNew(entity) ? // return mongoOperations.insert(entity, entityInformation.getCollectionName());
mongoOperations.insert(entity, entityInformation.getCollectionName()).then(Mono.just(entity)) : //
mongoOperations.save(entity, entityInformation.getCollectionName()).then(Mono.just(entity)));
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteById(java.lang.Object) * @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(java.lang.Iterable)
*/ */
@Override @Override
public Mono<Void> deleteById(ID id) { public <S extends T> Flux<S> insert(Iterable<S> entities) {
Assert.notNull(id, "The given id must not be null!"); Assert.notNull(entities, "The given Iterable of entities must not be null!");
return mongoOperations List<S> source = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList());
.remove(getIdQuery(id), entityInformation.getJavaType(), entityInformation.getCollectionName()).then();
return source.isEmpty() ? Flux.empty() : Flux.from(mongoOperations.insertAll(source));
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteById(org.reactivestreams.Publisher) * @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#insert(org.reactivestreams.Publisher)
*/ */
@Override @Override
public Mono<Void> deleteById(Publisher<ID> publisher) { public <S extends T> Flux<S> insert(Publisher<S> entities) {
Assert.notNull(publisher, "Id must not be null!"); Assert.notNull(entities, "The given Publisher of entities must not be null!");
return Mono.from(publisher).flatMap(id -> mongoOperations.remove(getIdQuery(id), entityInformation.getJavaType(), return Flux.from(entities).flatMap(entity -> mongoOperations.insert(entity, entityInformation.getCollectionName()));
entityInformation.getCollectionName())).then();
} }
// -------------------------------------------------------------------------
// Methods from ReactiveMongoRepository
// -------------------------------------------------------------------------
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#delete(java.lang.Object) * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#findOne(org.springframework.data.domain.Example)
*/ */
@Override @Override
public Mono<Void> delete(T entity) { public <S extends T> Mono<S> findOne(Example<S> example) {
Assert.notNull(entity, "The given entity must not be null!");
Mono<DeleteResult> remove = mongoOperations.remove(entity, entityInformation.getCollectionName());
if (entityInformation.isVersioned()) { Assert.notNull(example, "Sample must not be null!");
remove = remove.handle((deleteResult, sink) -> { Query query = new Query(new Criteria().alike(example)) //
.collation(entityInformation.getCollation()) //
.limit(2);
if (deleteResult.wasAcknowledged() && deleteResult.getDeletedCount() == 0) { return mongoOperations.find(query, example.getProbeType(), entityInformation.getCollectionName()).buffer(2)
sink.error(new OptimisticLockingFailureException(String.format( .map(vals -> {
"The entity with id %s with version %s in %s cannot be deleted! Was it modified or deleted in the meantime?",
entityInformation.getId(entity), entityInformation.getVersion(entity),
entityInformation.getCollectionName())));
} else {
sink.next(deleteResult);
}
});
}
return remove.then(); if (vals.size() > 1) {
throw new IncorrectResultSizeDataAccessException(1);
}
return vals.iterator().next();
}).next();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll(java.lang.Iterable) * @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#findAll(org.springframework.data.domain.Example)
*/ */
@Override @Override
public Mono<Void> deleteAll(Iterable<? extends T> entities) { public <S extends T> Flux<S> findAll(Example<S> example) {
Assert.notNull(entities, "The given Iterable of entities must not be null!");
Collection<?> idCollection = StreamUtils.createStreamFromIterator(entities.iterator())
.map(entityInformation::getId)
.collect(Collectors.toList());
Criteria idsInCriteria = where(entityInformation.getIdAttribute()).in(idCollection); Assert.notNull(example, "Example must not be null!");
return mongoOperations return findAll(example, Sort.unsorted());
.remove(new Query(idsInCriteria), entityInformation.getJavaType(), entityInformation.getCollectionName())
.then();
} }
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.repository.ReactiveMongoRepository#findAll(org.springframework.data.domain.Example, org.springframework.data.domain.Sort)
*/
@Override @Override
public Mono<Void> deleteAllById(Iterable<? extends ID> ids) { public <S extends T> Flux<S> findAll(Example<S> example, Sort sort) {
Assert.notNull(ids, "The given Iterable of ids must not be null!"); Assert.notNull(example, "Sample must not be null!");
Assert.notNull(sort, "Sort must not be null!");
Collection<?> idCollection = StreamUtils.createStreamFromIterator(ids.iterator()).collect(Collectors.toList()); Query query = new Query(new Criteria().alike(example)) //
Criteria idsInCriteria = where(entityInformation.getIdAttribute()).in(idCollection); .collation(entityInformation.getCollation()) //
.with(sort);
return mongoOperations return mongoOperations.find(query, example.getProbeType(), entityInformation.getCollectionName());
.remove(new Query(idsInCriteria), entityInformation.getJavaType(), entityInformation.getCollectionName())
.then();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll(org.reactivestreams.Publisher) * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#count(org.springframework.data.domain.Example)
*/ */
@Override @Override
public Mono<Void> deleteAll(Publisher<? extends T> entityStream) { public <S extends T> Mono<Long> count(Example<S> example) {
Assert.notNull(entityStream, "The given Publisher of entities must not be null!"); Assert.notNull(example, "Sample must not be null!");
return Flux.from(entityStream)// Query query = new Query(new Criteria().alike(example)) //
.map(entityInformation::getRequiredId)// .collation(entityInformation.getCollation());
.flatMap(this::deleteById)//
.then(); return mongoOperations.count(query, example.getProbeType(), entityInformation.getCollectionName());
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll() * @see org.springframework.data.repository.query.ReactiveQueryByExampleExecutor#exists(org.springframework.data.domain.Example)
*/ */
@Override @Override
public Mono<Void> deleteAll() { public <S extends T> Mono<Boolean> exists(Example<S> example) {
return mongoOperations.remove(new Query(), entityInformation.getCollectionName()).then(Mono.empty());
Assert.notNull(example, "Sample must not be null!");
Query query = new Query(new Criteria().alike(example)) //
.collation(entityInformation.getCollation());
return mongoOperations.exists(query, example.getProbeType(), entityInformation.getCollectionName());
} }
private Query getIdQuery(Object id) { private Query getIdQuery(Object id) {
return new Query(getIdCriteria(id)); return new Query(getIdCriteria(id));
} }
@ -459,6 +475,13 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement
return where(entityInformation.getIdAttribute()).is(id); return where(entityInformation.getIdAttribute()).is(id);
} }
private Query getIdQuery(Iterable<? extends ID> ids) {
Collection<?> idCollection = StreamUtils.createStreamFromIterator(ids.iterator()).collect(Collectors.toList());
Criteria idsInCriteria = where(entityInformation.getIdAttribute()).in(idCollection);
return new Query(idsInCriteria);
}
private Flux<T> findAll(Query query) { private Flux<T> findAll(Query query) {
return mongoOperations.find(query, entityInformation.getJavaType(), entityInformation.getCollectionName()); return mongoOperations.find(query, entityInformation.getJavaType(), entityInformation.getCollectionName());

120
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/ReactiveMongoRepositoryTests.java

@ -15,7 +15,6 @@
*/ */
package org.springframework.data.mongodb.repository; package org.springframework.data.mongodb.repository;
import static java.util.Arrays.*;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.domain.Sort.Direction.*; import static org.springframework.data.domain.Sort.Direction.*;
import static org.springframework.data.mongodb.core.query.Criteria.*; import static org.springframework.data.mongodb.core.query.Criteria.*;
@ -80,10 +79,10 @@ import com.mongodb.reactivestreams.client.MongoClient;
* @author Jens Schauder * @author Jens Schauder
*/ */
@ExtendWith({ MongoClientExtension.class, SpringExtension.class }) @ExtendWith({ MongoClientExtension.class, SpringExtension.class })
public class ReactiveMongoRepositoryTests { class ReactiveMongoRepositoryTests {
public static final int PERSON_COUNT = 7; private static final int PERSON_COUNT = 7;
static @Client MongoClient mongoClient; private static @Client MongoClient mongoClient;
@Autowired ReactiveMongoTemplate template; @Autowired ReactiveMongoTemplate template;
@ -91,8 +90,8 @@ public class ReactiveMongoRepositoryTests {
@Autowired ReactiveContactRepository contactRepository; @Autowired ReactiveContactRepository contactRepository;
@Autowired ReactiveCappedCollectionRepository cappedRepository; @Autowired ReactiveCappedCollectionRepository cappedRepository;
Person dave, oliver, carter, boyd, stefan, leroi, alicia; private Person dave, oliver, carter, boyd, stefan, leroi, alicia;
QPerson person = QPerson.person; private QPerson person = QPerson.person;
@Configuration @Configuration
static class Config extends AbstractReactiveMongoConfiguration { static class Config extends AbstractReactiveMongoConfiguration {
@ -142,59 +141,59 @@ public class ReactiveMongoRepositoryTests {
} }
@BeforeAll @BeforeAll
public static void cleanDb() { static void cleanDb() {
MongoTestUtils.createOrReplaceCollectionNow("reactive", "person", mongoClient); MongoTestUtils.createOrReplaceCollectionNow("reactive", "person", mongoClient);
MongoTestUtils.createOrReplaceCollectionNow("reactive", "capped", mongoClient); MongoTestUtils.createOrReplaceCollectionNow("reactive", "capped", mongoClient);
} }
@BeforeEach @BeforeEach
public void setUp() throws Exception { void setUp() throws Exception {
repository.deleteAll().as(StepVerifier::create).verifyComplete(); repository.deleteAll().as(StepVerifier::create).verifyComplete();
dave = new Person("Dave", "Matthews", 42); dave = new Person("Dave", "Matthews", 42);
oliver = new Person("Oliver August", "Matthews", 4); oliver = new Person("Oliver August", "Matthews", 4);
carter = new Person("Carter", "Beauford", 49); carter = new Person("Carter", "Beauford", 49);
carter.setSkills(asList("Drums", "percussion", "vocals")); carter.setSkills(Arrays.asList("Drums", "percussion", "vocals"));
Thread.sleep(10); Thread.sleep(10);
boyd = new Person("Boyd", "Tinsley", 45); boyd = new Person("Boyd", "Tinsley", 45);
boyd.setSkills(asList("Violin", "Electric Violin", "Viola", "Mandolin", "Vocals", "Guitar")); boyd.setSkills(Arrays.asList("Violin", "Electric Violin", "Viola", "Mandolin", "Vocals", "Guitar"));
stefan = new Person("Stefan", "Lessard", 34); stefan = new Person("Stefan", "Lessard", 34);
leroi = new Person("Leroi", "Moore", 41); leroi = new Person("Leroi", "Moore", 41);
alicia = new Person("Alicia", "Keys", 30, Sex.FEMALE); alicia = new Person("Alicia", "Keys", 30, Sex.FEMALE);
repository.saveAll(asList(oliver, carter, boyd, stefan, leroi, alicia, dave)).as(StepVerifier::create) // repository.saveAll(Arrays.asList(oliver, carter, boyd, stefan, leroi, alicia, dave)).as(StepVerifier::create) //
.expectNextCount(PERSON_COUNT) // .expectNextCount(PERSON_COUNT) //
.verifyComplete(); .verifyComplete();
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void shouldFindByLastName() { void shouldFindByLastName() {
repository.findByLastname(dave.getLastname()).as(StepVerifier::create).expectNextCount(2).verifyComplete(); repository.findByLastname(dave.getLastname()).as(StepVerifier::create).expectNextCount(2).verifyComplete();
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void shouldFindOneByLastName() { void shouldFindOneByLastName() {
repository.findOneByLastname(carter.getLastname()).as(StepVerifier::create).expectNext(carter).verifyComplete(); repository.findOneByLastname(carter.getLastname()).as(StepVerifier::create).expectNext(carter).verifyComplete();
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void shouldFindOneByPublisherOfLastName() { void shouldFindOneByPublisherOfLastName() {
repository.findByLastname(Mono.just(carter.getLastname())).as(StepVerifier::create).expectNext(carter) repository.findByLastname(Mono.just(carter.getLastname())).as(StepVerifier::create).expectNext(carter)
.verifyComplete(); .verifyComplete();
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void shouldFindByPublisherOfLastNameIn() { void shouldFindByPublisherOfLastNameIn() {
repository.findByLastnameIn(Flux.just(carter.getLastname(), dave.getLastname())).as(StepVerifier::create) // repository.findByLastnameIn(Flux.just(carter.getLastname(), dave.getLastname())).as(StepVerifier::create) //
.expectNextCount(3) // .expectNextCount(3) //
.verifyComplete(); .verifyComplete();
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void shouldFindByPublisherOfLastNameInAndAgeGreater() { void shouldFindByPublisherOfLastNameInAndAgeGreater() {
repository.findByLastnameInAndAgeGreaterThan(Flux.just(carter.getLastname(), dave.getLastname()), 41) repository.findByLastnameInAndAgeGreaterThan(Flux.just(carter.getLastname(), dave.getLastname()), 41)
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -203,7 +202,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void shouldFindUsingPublishersInStringQuery() { void shouldFindUsingPublishersInStringQuery() {
repository.findStringQuery(Flux.just("Beauford", "Matthews"), Mono.just(41)).as(StepVerifier::create) // repository.findStringQuery(Flux.just("Beauford", "Matthews"), Mono.just(41)).as(StepVerifier::create) //
.expectNextCount(2) // .expectNextCount(2) //
@ -211,7 +210,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void shouldFindByLastNameAndSort() { void shouldFindByLastNameAndSort() {
repository.findByLastname("Matthews", Sort.by(ASC, "age")).as(StepVerifier::create) // repository.findByLastname("Matthews", Sort.by(ASC, "age")).as(StepVerifier::create) //
.expectNext(oliver, dave) // .expectNext(oliver, dave) //
@ -223,7 +222,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void shouldUseTailableCursor() throws Exception { void shouldUseTailableCursor() throws Exception {
template.dropCollection(Capped.class) // template.dropCollection(Capped.class) //
.then(template.createCollection(Capped.class, // .then(template.createCollection(Capped.class, //
@ -248,7 +247,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void shouldUseTailableCursorWithProjection() throws Exception { void shouldUseTailableCursorWithProjection() throws Exception {
template.dropCollection(Capped.class) // template.dropCollection(Capped.class) //
.then(template.createCollection(Capped.class, // .then(template.createCollection(Capped.class, //
@ -279,7 +278,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2080 @Test // DATAMONGO-2080
public void shouldUseTailableCursorWithDtoProjection() { void shouldUseTailableCursorWithDtoProjection() {
template.dropCollection(Capped.class) // template.dropCollection(Capped.class) //
.then(template.createCollection(Capped.class, // .then(template.createCollection(Capped.class, //
@ -292,7 +291,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void findsPeopleByLocationWithinCircle() { void findsPeopleByLocationWithinCircle() {
Point point = new Point(-73.99171, 40.738868); Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point); dave.setLocation(point);
@ -304,7 +303,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void findsPeopleByPageableLocationWithinCircle() { void findsPeopleByPageableLocationWithinCircle() {
Point point = new Point(-73.99171, 40.738868); Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point); dave.setLocation(point);
@ -317,7 +316,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void findsPeopleGeoresultByLocationWithinBox() { void findsPeopleGeoresultByLocationWithinBox() {
Point point = new Point(-73.99171, 40.738868); Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point); dave.setLocation(point);
@ -332,7 +331,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void findsPeoplePageableGeoresultByLocationWithinBox() throws InterruptedException { void findsPeoplePageableGeoresultByLocationWithinBox() throws InterruptedException {
Point point = new Point(-73.99171, 40.738868); Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point); dave.setLocation(point);
@ -352,7 +351,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1444 @Test // DATAMONGO-1444
public void findsPeopleByLocationWithinBox() throws InterruptedException { void findsPeopleByLocationWithinBox() throws InterruptedException {
Point point = new Point(-73.99171, 40.738868); Point point = new Point(-73.99171, 40.738868);
dave.setLocation(point); dave.setLocation(point);
@ -368,23 +367,23 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1865 @Test // DATAMONGO-1865
public void shouldErrorOnFindOneWithNonUniqueResult() { void shouldErrorOnFindOneWithNonUniqueResult() {
repository.findOneByLastname(dave.getLastname()).as(StepVerifier::create) repository.findOneByLastname(dave.getLastname()).as(StepVerifier::create)
.expectError(IncorrectResultSizeDataAccessException.class).verify(); .expectError(IncorrectResultSizeDataAccessException.class).verify();
} }
@Test // DATAMONGO-1865 @Test // DATAMONGO-1865
public void shouldReturnFirstFindFirstWithMoreResults() { void shouldReturnFirstFindFirstWithMoreResults() {
repository.findFirstByLastname(dave.getLastname()).as(StepVerifier::create).expectNextCount(1).verifyComplete(); repository.findFirstByLastname(dave.getLastname()).as(StepVerifier::create).expectNextCount(1).verifyComplete();
} }
@Test // DATAMONGO-2030 @Test // DATAMONGO-2030
public void shouldReturnExistsBy() { void shouldReturnExistsBy() {
repository.existsByLastname(dave.getLastname()).as(StepVerifier::create).expectNext(true).verifyComplete(); repository.existsByLastname(dave.getLastname()).as(StepVerifier::create).expectNext(true).verifyComplete();
} }
@Test // DATAMONGO-1979 @Test // DATAMONGO-1979
public void findAppliesAnnotatedSort() { void findAppliesAnnotatedSort() {
repository.findByAgeGreaterThan(40).collectList().as(StepVerifier::create).consumeNextWith(result -> { repository.findByAgeGreaterThan(40).collectList().as(StepVerifier::create).consumeNextWith(result -> {
assertThat(result).containsSequence(carter, boyd, dave, leroi); assertThat(result).containsSequence(carter, boyd, dave, leroi);
@ -392,7 +391,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1979 @Test // DATAMONGO-1979
public void findWithSortOverwritesAnnotatedSort() { void findWithSortOverwritesAnnotatedSort() {
repository.findByAgeGreaterThan(40, Sort.by(Direction.ASC, "age")).collectList().as(StepVerifier::create) repository.findByAgeGreaterThan(40, Sort.by(Direction.ASC, "age")).collectList().as(StepVerifier::create)
.consumeNextWith(result -> { .consumeNextWith(result -> {
@ -401,7 +400,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2181 @Test // DATAMONGO-2181
public void considersRepositoryCollectionName() { void considersRepositoryCollectionName() {
repository.deleteAll() // repository.deleteAll() //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -413,7 +412,7 @@ public class ReactiveMongoRepositoryTests {
leroi.id = null; leroi.id = null;
boyd.id = null; boyd.id = null;
contactRepository.saveAll(asList(leroi, boyd)) // contactRepository.saveAll(Arrays.asList(leroi, boyd)) //
.as(StepVerifier::create) // .as(StepVerifier::create) //
.expectNextCount(2) // .expectNextCount(2) //
.verifyComplete(); .verifyComplete();
@ -430,9 +429,9 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2182 @Test // DATAMONGO-2182
public void shouldFindPersonsWhenUsingQueryDslPerdicatedOnIdProperty() { void shouldFindPersonsWhenUsingQueryDslPerdicatedOnIdProperty() {
repository.findAll(person.id.in(asList(dave.id, carter.id))) // repository.findAll(person.id.in(Arrays.asList(dave.id, carter.id))) //
.collectList() // .collectList() //
.as(StepVerifier::create) // .as(StepVerifier::create) //
.assertNext(actual -> { .assertNext(actual -> {
@ -441,24 +440,19 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2153 @Test // DATAMONGO-2153
public void findListOfSingleValue() { void findListOfSingleValue() {
repository.findAllLastnames() // repository.findAllLastnames() //
.collectList() // .collectList() //
.as(StepVerifier::create) // .as(StepVerifier::create) //
.assertNext(actual -> { .assertNext(actual -> {
assertThat(actual) // assertThat(actual)
.contains("Lessard") // .contains("Lessard", "Keys", "Tinsley", "Beauford", "Moore", "Matthews");
.contains("Keys") //
.contains("Tinsley") //
.contains("Beauford") //
.contains("Moore") //
.contains("Matthews");
}).verifyComplete(); }).verifyComplete();
} }
@Test // DATAMONGO-2153 @Test // DATAMONGO-2153
public void annotatedAggregationWithPlaceholderValue() { void annotatedAggregationWithPlaceholderValue() {
repository.groupByLastnameAnd("firstname") // repository.groupByLastnameAnd("firstname") //
.collectList() // .collectList() //
@ -470,12 +464,12 @@ public class ReactiveMongoRepositoryTests {
.contains(new PersonAggregate("Tinsley", "Boyd")) // .contains(new PersonAggregate("Tinsley", "Boyd")) //
.contains(new PersonAggregate("Beauford", "Carter")) // .contains(new PersonAggregate("Beauford", "Carter")) //
.contains(new PersonAggregate("Moore", "Leroi")) // .contains(new PersonAggregate("Moore", "Leroi")) //
.contains(new PersonAggregate("Matthews", asList("Dave", "Oliver August"))); .contains(new PersonAggregate("Matthews", Arrays.asList("Dave", "Oliver August")));
}).verifyComplete(); }).verifyComplete();
} }
@Test // DATAMONGO-2153 @Test // DATAMONGO-2153
public void annotatedAggregationWithSort() { void annotatedAggregationWithSort() {
repository.groupByLastnameAnd("firstname", Sort.by("lastname")) // repository.groupByLastnameAnd("firstname", Sort.by("lastname")) //
.collectList() // .collectList() //
@ -486,7 +480,7 @@ public class ReactiveMongoRepositoryTests {
new PersonAggregate("Beauford", "Carter"), // new PersonAggregate("Beauford", "Carter"), //
new PersonAggregate("Keys", "Alicia"), // new PersonAggregate("Keys", "Alicia"), //
new PersonAggregate("Lessard", "Stefan"), // new PersonAggregate("Lessard", "Stefan"), //
new PersonAggregate("Matthews", asList("Dave", "Oliver August")), // new PersonAggregate("Matthews", Arrays.asList("Dave", "Oliver August")), //
new PersonAggregate("Moore", "Leroi"), // new PersonAggregate("Moore", "Leroi"), //
new PersonAggregate("Tinsley", "Boyd")); new PersonAggregate("Tinsley", "Boyd"));
}) // }) //
@ -494,7 +488,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2153 @Test // DATAMONGO-2153
public void annotatedAggregationWithPageable() { void annotatedAggregationWithPageable() {
repository.groupByLastnameAnd("firstname", PageRequest.of(1, 2, Sort.by("lastname"))) // repository.groupByLastnameAnd("firstname", PageRequest.of(1, 2, Sort.by("lastname"))) //
.collectList() // .collectList() //
@ -503,13 +497,13 @@ public class ReactiveMongoRepositoryTests {
assertThat(actual) // assertThat(actual) //
.containsExactly( // .containsExactly( //
new PersonAggregate("Lessard", "Stefan"), // new PersonAggregate("Lessard", "Stefan"), //
new PersonAggregate("Matthews", asList("Dave", "Oliver August"))); new PersonAggregate("Matthews", Arrays.asList("Dave", "Oliver August")));
}) // }) //
.verifyComplete(); .verifyComplete();
} }
@Test // DATAMONGO-2153 @Test // DATAMONGO-2153
public void annotatedAggregationWithSingleSimpleResult() { void annotatedAggregationWithSingleSimpleResult() {
repository.sumAge() // repository.sumAge() //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -518,7 +512,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2153 @Test // DATAMONGO-2153
public void annotatedAggregationWithAggregationResultAsReturnType() { void annotatedAggregationWithAggregationResultAsReturnType() {
repository.sumAgeAndReturnRawResult() // repository.sumAgeAndReturnRawResult() //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -527,7 +521,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2153 @Test // DATAMONGO-2153
public void annotatedAggregationWithAggregationResultAsReturnTypeAndProjection() { void annotatedAggregationWithAggregationResultAsReturnTypeAndProjection() {
repository.sumAgeAndReturnSumWrapper() // repository.sumAgeAndReturnSumWrapper() //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -536,7 +530,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2374 @Test // DATAMONGO-2374
public void findsWithNativeProjection() { void findsWithNativeProjection() {
repository.findDocumentById(dave.getId()) // repository.findDocumentById(dave.getId()) //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -546,7 +540,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2153 @Test // DATAMONGO-2153
public void annotatedAggregationWithAggregationResultAsMap() { void annotatedAggregationWithAggregationResultAsMap() {
repository.sumAgeAndReturnSumAsMap() // repository.sumAgeAndReturnSumAsMap() //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -556,7 +550,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2403 @Test // DATAMONGO-2403
public void annotatedAggregationExtractingSimpleValueIsEmptyForEmptyDocument() { void annotatedAggregationExtractingSimpleValueIsEmptyForEmptyDocument() {
Person p = new Person("project-on-lastanme", null); Person p = new Person("project-on-lastanme", null);
repository.save(p).then().as(StepVerifier::create).verifyComplete(); repository.save(p).then().as(StepVerifier::create).verifyComplete();
@ -567,7 +561,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2403 @Test // DATAMONGO-2403
public void annotatedAggregationSkipsEmptyDocumentsWhenExtractingSimpleValue() { void annotatedAggregationSkipsEmptyDocumentsWhenExtractingSimpleValue() {
String firstname = "project-on-lastanme"; String firstname = "project-on-lastanme";
@ -578,7 +572,7 @@ public class ReactiveMongoRepositoryTests {
Person p3 = new Person(firstname, null); Person p3 = new Person(firstname, null);
p3.setEmail("p3@example.com"); p3.setEmail("p3@example.com");
repository.saveAll(asList(p1, p2, p3)).then().as(StepVerifier::create).verifyComplete(); repository.saveAll(Arrays.asList(p1, p2, p3)).then().as(StepVerifier::create).verifyComplete();
repository.projectToLastnameAndRemoveId(firstname) // repository.projectToLastnameAndRemoveId(firstname) //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -586,7 +580,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2406 @Test // DATAMONGO-2406
public void deleteByShouldHandleVoidResultTypeCorrectly() { void deleteByShouldHandleVoidResultTypeCorrectly() {
repository.deleteByLastname(dave.getLastname()) // repository.deleteByLastname(dave.getLastname()) //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -598,7 +592,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1997 @Test // DATAMONGO-1997
public void deleteByShouldAllowDeletedCountAsResult() { void deleteByShouldAllowDeletedCountAsResult() {
repository.deleteCountByLastname(dave.getLastname()) // repository.deleteCountByLastname(dave.getLastname()) //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -607,7 +601,7 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-1997 @Test // DATAMONGO-1997
public void deleteByShouldAllowSingleDocumentRemovalCorrectly() { void deleteByShouldAllowSingleDocumentRemovalCorrectly() {
repository.deleteSinglePersonByLastname(carter.getLastname()) // repository.deleteSinglePersonByLastname(carter.getLastname()) //
.as(StepVerifier::create) // .as(StepVerifier::create) //
@ -620,9 +614,9 @@ public class ReactiveMongoRepositoryTests {
} }
@Test // DATAMONGO-2652 @Test // DATAMONGO-2652
public void deleteAllById() { void deleteAllById() {
repository.deleteAllById(asList(carter.id, dave.id)) // repository.deleteAllById(Arrays.asList(carter.id, dave.id)) //
.as(StepVerifier::create) // .as(StepVerifier::create) //
.verifyComplete(); .verifyComplete();
@ -731,7 +725,7 @@ public class ReactiveMongoRepositoryTests {
String key; String key;
double random; double random;
public Capped(String key, double random) { Capped(String key, double random) {
this.key = key; this.key = key;
this.random = random; this.random = random;
} }

70
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepositoryTests.java

@ -61,10 +61,10 @@ import org.springframework.transaction.support.TransactionTemplate;
* @author Jens Schauder * @author Jens Schauder
*/ */
@ExtendWith({ MongoTemplateExtension.class, MongoServerCondition.class }) @ExtendWith({ MongoTemplateExtension.class, MongoServerCondition.class })
public class SimpleMongoRepositoryTests { class SimpleMongoRepositoryTests {
@Template(initialEntitySet = Person.class) // @Template(initialEntitySet = Person.class) //
static MongoTestTemplate template; private static MongoTestTemplate template;
private Person oliver, dave, carter, boyd, stefan, leroi, alicia; private Person oliver, dave, carter, boyd, stefan, leroi, alicia;
private List<Person> all; private List<Person> all;
@ -74,7 +74,7 @@ public class SimpleMongoRepositoryTests {
template); template);
@BeforeEach @BeforeEach
public void setUp() { void setUp() {
repository.deleteAll(); repository.deleteAll();
@ -90,17 +90,17 @@ public class SimpleMongoRepositoryTests {
} }
@Test @Test
public void findAllFromCustomCollectionName() { void findAllFromCustomCollectionName() {
assertThat(repository.findAll()).hasSize(all.size()); assertThat(repository.findAll()).hasSameSizeAs(all);
} }
@Test @Test
public void findOneFromCustomCollectionName() { void findOneFromCustomCollectionName() {
assertThat(repository.findById(dave.getId()).get()).isEqualTo(dave); assertThat(repository.findById(dave.getId())).contains(dave);
} }
@Test @Test
public void deleteFromCustomCollectionName() { void deleteFromCustomCollectionName() {
repository.delete(dave); repository.delete(dave);
@ -108,7 +108,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test @Test
public void deleteByIdFromCustomCollectionName() { void deleteByIdFromCustomCollectionName() {
repository.deleteById(dave.getId()); repository.deleteById(dave.getId());
@ -116,7 +116,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1054 @Test // DATAMONGO-1054
public void shouldInsertSingle() { void shouldInsertSingle() {
String randomId = UUID.randomUUID().toString(); String randomId = UUID.randomUUID().toString();
@ -127,7 +127,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1054 @Test // DATAMONGO-1054
public void shouldInsertMultipleFromList() { void shouldInsertMultipleFromList() {
String randomId = UUID.randomUUID().toString(); String randomId = UUID.randomUUID().toString();
Map<String, Person> idToPerson = new HashMap<String, Person>(); Map<String, Person> idToPerson = new HashMap<String, Person>();
@ -141,12 +141,12 @@ public class SimpleMongoRepositoryTests {
List<Person> saved = repository.insert(persons); List<Person> saved = repository.insert(persons);
assertThat(saved).hasSize(persons.size()); assertThat(saved).hasSameSizeAs(persons);
assertThatAllReferencePersonsWereStoredCorrectly(idToPerson, saved); assertThatAllReferencePersonsWereStoredCorrectly(idToPerson, saved);
} }
@Test // DATAMONGO-1054 @Test // DATAMONGO-1054
public void shouldInsertMutlipleFromSet() { void shouldInsertMutlipleFromSet() {
String randomId = UUID.randomUUID().toString(); String randomId = UUID.randomUUID().toString();
Map<String, Person> idToPerson = new HashMap<String, Person>(); Map<String, Person> idToPerson = new HashMap<String, Person>();
@ -160,12 +160,12 @@ public class SimpleMongoRepositoryTests {
List<Person> saved = repository.insert(persons); List<Person> saved = repository.insert(persons);
assertThat(saved).hasSize(persons.size()); assertThat(saved).hasSameSizeAs(persons);
assertThatAllReferencePersonsWereStoredCorrectly(idToPerson, saved); assertThatAllReferencePersonsWereStoredCorrectly(idToPerson, saved);
} }
@Test // DATAMONGO-1245, DATAMONGO-1464 @Test // DATAMONGO-1245, DATAMONGO-1464
public void findByExampleShouldLookUpEntriesCorrectly() { void findByExampleShouldLookUpEntriesCorrectly() {
Person sample = new Person(); Person sample = new Person();
sample.setLastname("Matthews"); sample.setLastname("Matthews");
@ -178,7 +178,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1464 @Test // DATAMONGO-1464
public void findByExampleMultiplePagesShouldLookUpEntriesCorrectly() { void findByExampleMultiplePagesShouldLookUpEntriesCorrectly() {
Person sample = new Person(); Person sample = new Person();
sample.setLastname("Matthews"); sample.setLastname("Matthews");
@ -191,7 +191,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldLookUpEntriesCorrectly() { void findAllByExampleShouldLookUpEntriesCorrectly() {
Person sample = new Person(); Person sample = new Person();
sample.setLastname("Matthews"); sample.setLastname("Matthews");
@ -201,7 +201,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldLookUpEntriesCorrectlyWhenUsingNestedObject() { void findAllByExampleShouldLookUpEntriesCorrectlyWhenUsingNestedObject() {
dave.setAddress(new Address("1600 Pennsylvania Ave NW", "20500", "Washington")); dave.setAddress(new Address("1600 Pennsylvania Ave NW", "20500", "Washington"));
repository.save(dave); repository.save(dave);
@ -217,7 +217,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldLookUpEntriesCorrectlyWhenUsingPartialNestedObject() { void findAllByExampleShouldLookUpEntriesCorrectlyWhenUsingPartialNestedObject() {
dave.setAddress(new Address("1600 Pennsylvania Ave NW", "20500", "Washington")); dave.setAddress(new Address("1600 Pennsylvania Ave NW", "20500", "Washington"));
repository.save(dave); repository.save(dave);
@ -233,7 +233,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldNotFindEntriesWhenUsingPartialNestedObjectInStrictMode() { void findAllByExampleShouldNotFindEntriesWhenUsingPartialNestedObjectInStrictMode() {
dave.setAddress(new Address("1600 Pennsylvania Ave NW", "20500", "Washington")); dave.setAddress(new Address("1600 Pennsylvania Ave NW", "20500", "Washington"));
repository.save(dave); repository.save(dave);
@ -248,7 +248,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldLookUpEntriesCorrectlyWhenUsingNestedObjectInStrictMode() { void findAllByExampleShouldLookUpEntriesCorrectlyWhenUsingNestedObjectInStrictMode() {
dave.setAddress(new Address("1600 Pennsylvania Ave NW", "20500", "Washington")); dave.setAddress(new Address("1600 Pennsylvania Ave NW", "20500", "Washington"));
repository.save(dave); repository.save(dave);
@ -263,7 +263,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldRespectStringMatchMode() { void findAllByExampleShouldRespectStringMatchMode() {
Person sample = new Person(); Person sample = new Person();
sample.setLastname("Mat"); sample.setLastname("Mat");
@ -275,7 +275,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldResolveDbRefCorrectly() { void findAllByExampleShouldResolveDbRefCorrectly() {
User user = new User(); User user = new User();
user.setId("c0nf1ux"); user.setId("c0nf1ux");
@ -295,7 +295,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldResolveLegacyCoordinatesCorrectly() { void findAllByExampleShouldResolveLegacyCoordinatesCorrectly() {
Person megan = new Person("megan", "tarash"); Person megan = new Person("megan", "tarash");
megan.setLocation(new Point(41.85003D, -87.65005D)); megan.setLocation(new Point(41.85003D, -87.65005D));
@ -310,7 +310,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldResolveGeoJsonCoordinatesCorrectly() { void findAllByExampleShouldResolveGeoJsonCoordinatesCorrectly() {
Person megan = new Person("megan", "tarash"); Person megan = new Person("megan", "tarash");
megan.setLocation(new GeoJsonPoint(41.85003D, -87.65005D)); megan.setLocation(new GeoJsonPoint(41.85003D, -87.65005D));
@ -325,7 +325,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findAllByExampleShouldProcessInheritanceCorrectly() { void findAllByExampleShouldProcessInheritanceCorrectly() {
PersonExtended reference = new PersonExtended(); PersonExtended reference = new PersonExtended();
reference.setLastname("Matthews"); reference.setLastname("Matthews");
@ -341,7 +341,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void findOneByExampleShouldLookUpEntriesCorrectly() { void findOneByExampleShouldLookUpEntriesCorrectly() {
Person sample = new Person(); Person sample = new Person();
sample.setFirstname("Dave"); sample.setFirstname("Dave");
@ -352,7 +352,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void existsByExampleShouldLookUpEntriesCorrectly() { void existsByExampleShouldLookUpEntriesCorrectly() {
Person sample = new Person(); Person sample = new Person();
sample.setFirstname("Dave"); sample.setFirstname("Dave");
@ -363,7 +363,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1245 @Test // DATAMONGO-1245
public void countByExampleShouldLookUpEntriesCorrectly() { void countByExampleShouldLookUpEntriesCorrectly() {
Person sample = new Person(); Person sample = new Person();
sample.setLastname("Matthews"); sample.setLastname("Matthews");
@ -373,7 +373,7 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-1896 @Test // DATAMONGO-1896
public void saveAllUsesEntityCollection() { void saveAllUsesEntityCollection() {
Person first = new PersonExtended(); Person first = new PersonExtended();
first.setEmail("foo@bar.com"); first.setEmail("foo@bar.com");
@ -393,7 +393,7 @@ public class SimpleMongoRepositoryTests {
@Test // DATAMONGO-2130 @Test // DATAMONGO-2130
@EnableIfReplicaSetAvailable @EnableIfReplicaSetAvailable
@EnableIfMongoServerVersion(isGreaterThanEqual = "4.0") @EnableIfMongoServerVersion(isGreaterThanEqual = "4.0")
public void countShouldBePossibleInTransaction() { void countShouldBePossibleInTransaction() {
MongoTransactionManager txmgr = new MongoTransactionManager(template.getMongoDbFactory()); MongoTransactionManager txmgr = new MongoTransactionManager(template.getMongoDbFactory());
TransactionTemplate tt = new TransactionTemplate(txmgr); TransactionTemplate tt = new TransactionTemplate(txmgr);
@ -417,7 +417,7 @@ public class SimpleMongoRepositoryTests {
@Test // DATAMONGO-2130 @Test // DATAMONGO-2130
@EnableIfReplicaSetAvailable @EnableIfReplicaSetAvailable
@EnableIfMongoServerVersion(isGreaterThanEqual = "4.0") @EnableIfMongoServerVersion(isGreaterThanEqual = "4.0")
public void existsShouldBePossibleInTransaction() { void existsShouldBePossibleInTransaction() {
MongoTransactionManager txmgr = new MongoTransactionManager(template.getMongoDbFactory()); MongoTransactionManager txmgr = new MongoTransactionManager(template.getMongoDbFactory());
TransactionTemplate tt = new TransactionTemplate(txmgr); TransactionTemplate tt = new TransactionTemplate(txmgr);
@ -437,14 +437,12 @@ public class SimpleMongoRepositoryTests {
} }
@Test // DATAMONGO-2652 @Test // DATAMONGO-2652
public void deleteAllByIds() { void deleteAllByIds() {
repository.deleteAllById(asList(dave.getId(), carter.getId())); repository.deleteAllById(asList(dave.getId(), carter.getId()));
assertThat(repository.findAll()) // assertThat(repository.findAll()) //
.hasSize(all.size() - 2) // .hasSize(all.size() - 2).doesNotContain(dave, carter);
.doesNotContain(dave) //
.doesNotContain(carter);
} }
private void assertThatAllReferencePersonsWereStoredCorrectly(Map<String, Person> references, List<Person> saved) { private void assertThatAllReferencePersonsWereStoredCorrectly(Map<String, Person> references, List<Person> saved) {

Loading…
Cancel
Save