|
35 | 35 | import org.springframework.beans.factory.BeanFactory;
|
36 | 36 | import org.springframework.beans.factory.BeanFactoryAware;
|
37 | 37 | import org.springframework.beans.factory.annotation.Autowired;
|
| 38 | +import org.springframework.dao.IncorrectResultSizeDataAccessException; |
38 | 39 | import org.springframework.data.annotation.Id;
|
39 | 40 | import org.springframework.data.domain.Example;
|
40 | 41 | import org.springframework.data.domain.Sort;
|
|
49 | 50 | import org.springframework.util.ClassUtils;
|
50 | 51 |
|
51 | 52 | /**
|
52 |
| - * Test for {@link ReactiveMongoRepository}. |
| 53 | + * Tests for {@link ReactiveMongoRepository}. |
53 | 54 | *
|
54 | 55 | * @author Mark Paluch
|
| 56 | + * @author Christoph Strobl |
55 | 57 | */
|
56 | 58 | @RunWith(SpringJUnit4ClassRunner.class)
|
57 | 59 | @ContextConfiguration("classpath:reactive-infrastructure.xml")
|
@@ -403,6 +405,15 @@ public void existsByExampleShouldReturnNonExisting() {
|
403 | 405 | StepVerifier.create(repository.exists(example)).expectNext(false).verifyComplete();
|
404 | 406 | }
|
405 | 407 |
|
| 408 | + @Test // DATAMONGO-1619 |
| 409 | + public void findOneShouldEmitIncorrectResultSizeDataAccessExceptionWhenMoreThanOneElementFound() { |
| 410 | + |
| 411 | + Example<ReactivePerson> example = Example.of(new ReactivePerson(null, "Matthews", -1), |
| 412 | + matching().withIgnorePaths("age")); |
| 413 | + |
| 414 | + StepVerifier.create(repository.findOne(example)).expectError(IncorrectResultSizeDataAccessException.class); |
| 415 | + } |
| 416 | + |
406 | 417 | interface ReactivePersonRepostitory extends ReactiveMongoRepository<ReactivePerson, String> {
|
407 | 418 |
|
408 | 419 | Flux<ReactivePerson> findByLastname(String lastname);
|
|
0 commit comments