15
15
*/
16
16
package org .springframework .data .mongodb .repository ;
17
17
18
+ import static java .util .Arrays .*;
18
19
import static org .assertj .core .api .Assertions .*;
19
20
import static org .springframework .data .domain .Sort .Direction .*;
20
21
import static org .springframework .data .mongodb .core .query .Criteria .*;
66
67
import org .springframework .data .mongodb .test .util .MongoTestUtils ;
67
68
import org .springframework .data .querydsl .ReactiveQuerydslPredicateExecutor ;
68
69
import org .springframework .data .repository .Repository ;
69
- import org .springframework .data .repository .query .QueryMethodEvaluationContextProvider ;
70
70
import org .springframework .data .repository .query .ReactiveQueryMethodEvaluationContextProvider ;
71
71
import org .springframework .test .context .junit .jupiter .SpringExtension ;
72
72
77
77
*
78
78
* @author Mark Paluch
79
79
* @author Christoph Strobl
80
+ * @author Jens Schauder
80
81
*/
81
82
@ ExtendWith ({ MongoClientExtension .class , SpringExtension .class })
82
83
public class ReactiveMongoRepositoryTests {
83
84
85
+ public static final int PERSON_COUNT = 7 ;
84
86
static @ Client MongoClient mongoClient ;
85
87
86
88
@ Autowired ReactiveMongoTemplate template ;
@@ -154,17 +156,17 @@ public void setUp() throws Exception {
154
156
dave = new Person ("Dave" , "Matthews" , 42 );
155
157
oliver = new Person ("Oliver August" , "Matthews" , 4 );
156
158
carter = new Person ("Carter" , "Beauford" , 49 );
157
- carter .setSkills (Arrays . asList ("Drums" , "percussion" , "vocals" ));
159
+ carter .setSkills (asList ("Drums" , "percussion" , "vocals" ));
158
160
Thread .sleep (10 );
159
161
boyd = new Person ("Boyd" , "Tinsley" , 45 );
160
- boyd .setSkills (Arrays . asList ("Violin" , "Electric Violin" , "Viola" , "Mandolin" , "Vocals" , "Guitar" ));
162
+ boyd .setSkills (asList ("Violin" , "Electric Violin" , "Viola" , "Mandolin" , "Vocals" , "Guitar" ));
161
163
stefan = new Person ("Stefan" , "Lessard" , 34 );
162
164
leroi = new Person ("Leroi" , "Moore" , 41 );
163
165
164
166
alicia = new Person ("Alicia" , "Keys" , 30 , Sex .FEMALE );
165
167
166
- repository .saveAll (Arrays . asList (oliver , carter , boyd , stefan , leroi , alicia , dave )).as (StepVerifier ::create ) //
167
- .expectNextCount (7 ) //
168
+ repository .saveAll (asList (oliver , carter , boyd , stefan , leroi , alicia , dave )).as (StepVerifier ::create ) //
169
+ .expectNextCount (PERSON_COUNT ) //
168
170
.verifyComplete ();
169
171
}
170
172
@@ -411,7 +413,7 @@ public void considersRepositoryCollectionName() {
411
413
412
414
leroi .id = null ;
413
415
boyd .id = null ;
414
- contactRepository .saveAll (Arrays . asList (leroi , boyd )) //
416
+ contactRepository .saveAll (asList (leroi , boyd )) //
415
417
.as (StepVerifier ::create ) //
416
418
.expectNextCount (2 ) //
417
419
.verifyComplete ();
@@ -430,7 +432,7 @@ public void considersRepositoryCollectionName() {
430
432
@ Test // DATAMONGO-2182
431
433
public void shouldFindPersonsWhenUsingQueryDslPerdicatedOnIdProperty () {
432
434
433
- repository .findAll (person .id .in (Arrays . asList (dave .id , carter .id ))) //
435
+ repository .findAll (person .id .in (asList (dave .id , carter .id ))) //
434
436
.collectList () //
435
437
.as (StepVerifier ::create ) //
436
438
.assertNext (actual -> {
@@ -468,7 +470,7 @@ public void annotatedAggregationWithPlaceholderValue() {
468
470
.contains (new PersonAggregate ("Tinsley" , "Boyd" )) //
469
471
.contains (new PersonAggregate ("Beauford" , "Carter" )) //
470
472
.contains (new PersonAggregate ("Moore" , "Leroi" )) //
471
- .contains (new PersonAggregate ("Matthews" , Arrays . asList ("Dave" , "Oliver August" )));
473
+ .contains (new PersonAggregate ("Matthews" , asList ("Dave" , "Oliver August" )));
472
474
}).verifyComplete ();
473
475
}
474
476
@@ -484,7 +486,7 @@ public void annotatedAggregationWithSort() {
484
486
new PersonAggregate ("Beauford" , "Carter" ), //
485
487
new PersonAggregate ("Keys" , "Alicia" ), //
486
488
new PersonAggregate ("Lessard" , "Stefan" ), //
487
- new PersonAggregate ("Matthews" , Arrays . asList ("Dave" , "Oliver August" )), //
489
+ new PersonAggregate ("Matthews" , asList ("Dave" , "Oliver August" )), //
488
490
new PersonAggregate ("Moore" , "Leroi" ), //
489
491
new PersonAggregate ("Tinsley" , "Boyd" ));
490
492
}) //
@@ -501,7 +503,7 @@ public void annotatedAggregationWithPageable() {
501
503
assertThat (actual ) //
502
504
.containsExactly ( //
503
505
new PersonAggregate ("Lessard" , "Stefan" ), //
504
- new PersonAggregate ("Matthews" , Arrays . asList ("Dave" , "Oliver August" )));
506
+ new PersonAggregate ("Matthews" , asList ("Dave" , "Oliver August" )));
505
507
}) //
506
508
.verifyComplete ();
507
509
}
@@ -576,7 +578,7 @@ public void annotatedAggregationSkipsEmptyDocumentsWhenExtractingSimpleValue() {
576
578
Person p3 = new Person (firstname , null );
577
579
578
580
579
- repository .saveAll (Arrays . asList (p1 , p2 , p3 )).then ().as (StepVerifier ::create ).verifyComplete ();
581
+ repository .saveAll (asList (p1 , p2 , p3 )).then ().as (StepVerifier ::create ).verifyComplete ();
580
582
581
583
repository .projectToLastnameAndRemoveId (firstname ) //
582
584
.as (StepVerifier ::create ) //
@@ -617,6 +619,18 @@ public void deleteByShouldAllowSingleDocumentRemovalCorrectly() {
617
619
.verifyComplete ();
618
620
}
619
621
622
+ @ Test // DATAMONGO-2652
623
+ public void deleteAllById () {
624
+
625
+ repository .deleteAllById (asList (carter .id , dave .id )) //
626
+ .as (StepVerifier ::create ) //
627
+ .verifyComplete ();
628
+
629
+ repository .count ().as (StepVerifier ::create ) //
630
+ .expectNext (PERSON_COUNT - 2L ) //
631
+ .verifyComplete ();
632
+ }
633
+
620
634
interface ReactivePersonRepository
621
635
extends ReactiveMongoRepository <Person , String >, ReactiveQuerydslPredicateExecutor <Person > {
622
636
0 commit comments