1818import static org .assertj .core .api .Assertions .*;
1919import static org .springframework .data .domain .ExampleMatcher .*;
2020
21- import org .junit .jupiter .api .RepeatedTest ;
22- import org .springframework .data .mongodb .ReactiveMongoTransactionManager ;
23- import org .springframework .transaction .TransactionDefinition ;
24- import org .springframework .transaction .reactive .TransactionalOperator ;
2521import reactor .core .publisher .Flux ;
2622import reactor .core .publisher .Mono ;
2723import reactor .test .StepVerifier ;
2824
2925import java .util .Arrays ;
3026import java .util .Objects ;
27+ import java .util .stream .Stream ;
3128
3229import org .junit .jupiter .api .BeforeEach ;
30+ import org .junit .jupiter .api .RepeatedTest ;
3331import org .junit .jupiter .api .Test ;
3432import org .junit .jupiter .api .extension .ExtendWith ;
3533import org .springframework .beans .BeansException ;
4442import org .springframework .data .domain .Sort ;
4543import org .springframework .data .domain .Sort .Direction ;
4644import org .springframework .data .domain .Sort .Order ;
45+ import org .springframework .data .mongodb .ReactiveMongoTransactionManager ;
4746import org .springframework .data .mongodb .core .ReactiveMongoTemplate ;
4847import org .springframework .data .mongodb .repository .support .ReactiveMongoRepositoryFactory ;
4948import org .springframework .data .mongodb .repository .support .SimpleReactiveMongoRepository ;
5251import org .springframework .lang .Nullable ;
5352import org .springframework .test .context .ContextConfiguration ;
5453import org .springframework .test .context .junit .jupiter .SpringExtension ;
54+ import org .springframework .transaction .TransactionDefinition ;
55+ import org .springframework .transaction .reactive .TransactionalOperator ;
5556import org .springframework .util .ClassUtils ;
5657
5758/**
@@ -337,16 +338,26 @@ void savePublisherOfEntitiesShouldInsertEntity() {
337338 assertThat (boyd .getId ()).isNotNull ();
338339 }
339340
340- @ RepeatedTest (10 )
341+ @ RepeatedTest (10 ) // GH-4838
341342 void transactionalSaveAllForStuffThatIsConsideredAnUpdateOfExistingData () {
342343
343344 ReactiveMongoTransactionManager txmgr = new ReactiveMongoTransactionManager (template .getMongoDatabaseFactory ());
344345 TransactionalOperator .create (txmgr , TransactionDefinition .withDefaults ()).execute (callback -> {
345346 return repository .saveAll (Arrays .asList (oliver , dave , carter , boyd , stefan , leroi , alicia ));
346- })
347- .as (StepVerifier ::create ) //
348- .expectNext (oliver , dave , carter , boyd , stefan , leroi , alicia )
349- .verifyComplete ();
347+ }).as (StepVerifier ::create ) //
348+ .expectNext (oliver , dave , carter , boyd , stefan , leroi , alicia ).verifyComplete ();
349+ }
350+
351+ @ RepeatedTest (10 ) // GH-4838
352+ void transactionalSaveAllWithPublisherForStuffThatIsConsideredAnUpdateOfExistingData () {
353+
354+ ReactiveMongoTransactionManager txmgr = new ReactiveMongoTransactionManager (template .getMongoDatabaseFactory ());
355+ Flux <ReactivePerson > personFlux = Flux .fromStream (Stream .of (oliver , dave , carter , boyd , stefan , leroi , alicia ));
356+
357+ TransactionalOperator .create (txmgr , TransactionDefinition .withDefaults ()).execute (callback -> {
358+ return repository .saveAll (personFlux );
359+ }).as (StepVerifier ::create ) //
360+ .expectNextCount (7 ).verifyComplete ();
350361 }
351362
352363 @ Test // GH-3609
@@ -358,7 +369,7 @@ void savePublisherOfImmutableEntitiesShouldInsertEntity() {
358369 .consumeNextWith (actual -> {
359370 assertThat (actual .id ).isNotNull ();
360371 }) //
361- .verifyComplete ();
372+ .verifyComplete ();
362373 }
363374
364375 @ Test // DATAMONGO-1444
0 commit comments