DATAMONGO-1907 - Polishing.
Rename test method to reflect test subject. Switch from flatMap(…) to map(…) to avoid overhead of Mono creation. Original pull request: #541.
This commit is contained in:
@@ -92,12 +92,12 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement
|
|||||||
q.limit(2);
|
q.limit(2);
|
||||||
|
|
||||||
return mongoOperations.find(q, example.getProbeType(), entityInformation.getCollectionName()).buffer(2)
|
return mongoOperations.find(q, example.getProbeType(), entityInformation.getCollectionName()).buffer(2)
|
||||||
.flatMap(vals -> {
|
.map(vals -> {
|
||||||
|
|
||||||
if (vals.size() > 1) {
|
if (vals.size() > 1) {
|
||||||
return Mono.error(new IncorrectResultSizeDataAccessException(1));
|
throw new IncorrectResultSizeDataAccessException(1);
|
||||||
}
|
}
|
||||||
return Mono.just(vals.iterator().next());
|
return vals.iterator().next();
|
||||||
}).next();
|
}).next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,10 +315,9 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement
|
|||||||
|
|
||||||
Assert.notNull(entityStream, "The given Publisher of entities must not be null!");
|
Assert.notNull(entityStream, "The given Publisher of entities must not be null!");
|
||||||
|
|
||||||
return Flux.from(entityStream)
|
return Flux.from(entityStream).flatMap(entity -> entityInformation.isNew(entity) ? //
|
||||||
.flatMap(entity -> entityInformation.isNew(entity) ? //
|
mongoOperations.insert(entity, entityInformation.getCollectionName()).then(Mono.just(entity)) : //
|
||||||
mongoOperations.insert(entity, entityInformation.getCollectionName()).then(Mono.just(entity)) : //
|
mongoOperations.save(entity, entityInformation.getCollectionName()).then(Mono.just(entity)));
|
||||||
mongoOperations.save(entity, entityInformation.getCollectionName()).then(Mono.just(entity)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ public class SimpleReactiveMongoRepositoryTests implements BeanClassLoaderAware,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAMONGO-1907
|
@Test // DATAMONGO-1907
|
||||||
public void existsByExampleShouldReturnNonExistingWithoutThrowException() {
|
public void findOneByExampleWithoutResultShouldCompleteEmpty() {
|
||||||
|
|
||||||
Example<ReactivePerson> example = Example.of(new ReactivePerson("foo", "bar", -1));
|
Example<ReactivePerson> example = Example.of(new ReactivePerson("foo", "bar", -1));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user