|
38 | 38 | import org.springframework.context.ApplicationEventPublisher;
|
39 | 39 | import org.springframework.data.domain.AfterDomainEventPublication;
|
40 | 40 | import org.springframework.data.domain.DomainEvents;
|
| 41 | +import org.springframework.data.domain.ScrollPosition; |
| 42 | +import org.springframework.data.domain.Window; |
41 | 43 | import org.springframework.data.repository.CrudRepository;
|
42 | 44 | import org.springframework.data.repository.core.RepositoryInformation;
|
43 | 45 | import org.springframework.data.repository.core.support.EventPublishingRepositoryProxyPostProcessor.EventPublishingMethod;
|
|
50 | 52 | * @author Mark Paluch
|
51 | 53 | * @author Yuki Yoshida
|
52 | 54 | * @author Réda Housni Alaoui
|
| 55 | + * @author Yanming Zhou |
53 | 56 | * @soundtrack Henrik Freischlader Trio - Nobody Else To Blame (Openness)
|
54 | 57 | */
|
55 | 58 | @ExtendWith(MockitoExtension.class)
|
@@ -199,6 +202,21 @@ void publishesEventsForCallToSaveWithIterable() throws Throwable {
|
199 | 202 | verify(publisher).publishEvent(any(SomeEvent.class));
|
200 | 203 | }
|
201 | 204 |
|
| 205 | + @Test |
| 206 | + void publishesEventsForCallToSaveWithIterableAndWindowAsParameter() throws Throwable { |
| 207 | + |
| 208 | + var event = new SomeEvent(); |
| 209 | + var sample = MultipleEvents.of(Collections.singletonList(event)); |
| 210 | + Window<MultipleEvents> window = Window.from(List.of(sample), ScrollPosition::offset); |
| 211 | + mockInvocation(invocation, SampleRepository.class.getMethod("saveAll", Iterable.class), window); |
| 212 | + |
| 213 | + EventPublishingMethodInterceptor// |
| 214 | + .of(EventPublishingMethod.of(MultipleEvents.class), publisher)// |
| 215 | + .invoke(invocation); |
| 216 | + |
| 217 | + verify(publisher).publishEvent(any(SomeEvent.class)); |
| 218 | + } |
| 219 | + |
202 | 220 | @Test // DATACMNS-1663
|
203 | 221 | void publishesEventsForCallToDeleteWithIterable() throws Throwable {
|
204 | 222 |
|
|
0 commit comments