Properly emit domain events from calls to saveAll(…).
We now treat CrudRepository.saveAll(…) properly by unwrapping the given *Iterable*. This previously already worked for collections handed into the method but not for types only implementing Iterable directly (like Page or Window). Fixes #3153. Related tickets #2931, #2927.
This commit is contained in:
@@ -69,11 +69,6 @@ class EventPublishingRepositoryProxyPostProcessorUnitTests {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> EventPublishingMethod.of(null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-928
|
||||
void publishingEventsForNullIsNoOp() {
|
||||
EventPublishingMethod.of(OneEvent.class).publishEventsFrom(null, publisher);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-928
|
||||
void exposesEventsExposedByEntityToPublisher() {
|
||||
|
||||
@@ -81,7 +76,7 @@ class EventPublishingRepositoryProxyPostProcessorUnitTests {
|
||||
var second = new SomeEvent();
|
||||
var entity = MultipleEvents.of(Arrays.asList(first, second));
|
||||
|
||||
EventPublishingMethod.of(MultipleEvents.class).publishEventsFrom(entity, publisher);
|
||||
EventPublishingMethod.of(MultipleEvents.class).publishEventsFrom(List.of(entity), publisher);
|
||||
|
||||
verify(publisher).publishEvent(eq(first));
|
||||
verify(publisher).publishEvent(eq(second));
|
||||
@@ -93,7 +88,7 @@ class EventPublishingRepositoryProxyPostProcessorUnitTests {
|
||||
var event = new SomeEvent();
|
||||
var entity = OneEvent.of(event);
|
||||
|
||||
EventPublishingMethod.of(OneEvent.class).publishEventsFrom(entity, publisher);
|
||||
EventPublishingMethod.of(OneEvent.class).publishEventsFrom(List.of(entity), publisher);
|
||||
|
||||
verify(publisher, times(1)).publishEvent(event);
|
||||
}
|
||||
@@ -103,7 +98,7 @@ class EventPublishingRepositoryProxyPostProcessorUnitTests {
|
||||
|
||||
var entity = OneEvent.of(null);
|
||||
|
||||
EventPublishingMethod.of(OneEvent.class).publishEventsFrom(entity, publisher);
|
||||
EventPublishingMethod.of(OneEvent.class).publishEventsFrom(List.of(entity), publisher);
|
||||
|
||||
verify(publisher, times(0)).publishEvent(any());
|
||||
}
|
||||
@@ -279,7 +274,7 @@ class EventPublishingRepositoryProxyPostProcessorUnitTests {
|
||||
|
||||
var entity = spy(EventsWithClearing.of(Collections.emptyList()));
|
||||
|
||||
EventPublishingMethod.of(EventsWithClearing.class).publishEventsFrom(entity, publisher);
|
||||
EventPublishingMethod.of(EventsWithClearing.class).publishEventsFrom(List.of(entity), publisher);
|
||||
|
||||
verify(entity, times(1)).clearDomainEvents();
|
||||
}
|
||||
@@ -289,7 +284,7 @@ class EventPublishingRepositoryProxyPostProcessorUnitTests {
|
||||
|
||||
var entity = spy(EventsWithClearing.of(Collections.singletonList(new SomeEvent())));
|
||||
|
||||
EventPublishingMethod.of(EventsWithClearing.class).publishEventsFrom(entity, publisher);
|
||||
EventPublishingMethod.of(EventsWithClearing.class).publishEventsFrom(List.of(entity), publisher);
|
||||
|
||||
verify(entity, times(1)).clearDomainEvents();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user