37
37
import org .mockito .junit .jupiter .MockitoExtension ;
38
38
import org .mockito .junit .jupiter .MockitoSettings ;
39
39
import org .mockito .quality .Strictness ;
40
-
41
40
import org .springframework .aop .framework .ProxyFactory ;
42
41
import org .springframework .context .ApplicationEventPublisher ;
43
42
import org .springframework .data .domain .AfterDomainEventPublication ;
@@ -68,19 +67,14 @@ void rejectsNullAggregateTypes() {
68
67
assertThatIllegalArgumentException ().isThrownBy (() -> EventPublishingMethod .of (null ));
69
68
}
70
69
71
- @ Test // DATACMNS-928
72
- void publishingEventsForNullIsNoOp () {
73
- EventPublishingMethod .of (OneEvent .class ).publishEventsFrom (null , publisher );
74
- }
75
-
76
70
@ Test // DATACMNS-928
77
71
void exposesEventsExposedByEntityToPublisher () {
78
72
79
73
SomeEvent first = new SomeEvent ();
80
74
SomeEvent second = new SomeEvent ();
81
75
MultipleEvents entity = MultipleEvents .of (Arrays .asList (first , second ));
82
76
83
- EventPublishingMethod .of (MultipleEvents .class ).publishEventsFrom (entity , publisher );
77
+ EventPublishingMethod .of (MultipleEvents .class ).publishEventsFrom (Arrays . asList ( entity ) , publisher );
84
78
85
79
verify (publisher ).publishEvent (eq (first ));
86
80
verify (publisher ).publishEvent (eq (second ));
@@ -92,7 +86,7 @@ void exposesSingleEventByEntityToPublisher() {
92
86
SomeEvent event = new SomeEvent ();
93
87
OneEvent entity = OneEvent .of (event );
94
88
95
- EventPublishingMethod .of (OneEvent .class ).publishEventsFrom (entity , publisher );
89
+ EventPublishingMethod .of (OneEvent .class ).publishEventsFrom (Arrays . asList ( entity ) , publisher );
96
90
97
91
verify (publisher , times (1 )).publishEvent (event );
98
92
}
@@ -102,7 +96,7 @@ void doesNotExposeNullEvent() {
102
96
103
97
OneEvent entity = OneEvent .of (null );
104
98
105
- EventPublishingMethod .of (OneEvent .class ).publishEventsFrom (entity , publisher );
99
+ EventPublishingMethod .of (OneEvent .class ).publishEventsFrom (Arrays . asList ( entity ) , publisher );
106
100
107
101
verify (publisher , times (0 )).publishEvent (any ());
108
102
}
@@ -194,7 +188,7 @@ void publishesEventsForCallToSaveWithIterable() throws Throwable {
194
188
195
189
SomeEvent event = new SomeEvent ();
196
190
MultipleEvents sample = MultipleEvents .of (Collections .singletonList (event ));
197
- mockInvocation (invocation , SampleRepository .class .getMethod ("saveAll" , Iterable .class ), sample );
191
+ mockInvocation (invocation , SampleRepository .class .getMethod ("saveAll" , Iterable .class ), Arrays . asList ( sample ) );
198
192
199
193
EventPublishingMethodInterceptor //
200
194
.of (EventPublishingMethod .of (MultipleEvents .class ), publisher )//
@@ -208,7 +202,7 @@ void publishesEventsForCallToDeleteWithIterable() throws Throwable {
208
202
209
203
SomeEvent event = new SomeEvent ();
210
204
MultipleEvents sample = MultipleEvents .of (Collections .singletonList (event ));
211
- mockInvocation (invocation , SampleRepository .class .getMethod ("deleteAll" , Iterable .class ), sample );
205
+ mockInvocation (invocation , SampleRepository .class .getMethod ("deleteAll" , Iterable .class ), Arrays . asList ( sample ) );
212
206
213
207
EventPublishingMethodInterceptor //
214
208
.of (EventPublishingMethod .of (MultipleEvents .class ), publisher )//
@@ -222,7 +216,8 @@ void publishesEventsForCallToDeleteInBatchWithIterable() throws Throwable {
222
216
223
217
SomeEvent event = new SomeEvent ();
224
218
MultipleEvents sample = MultipleEvents .of (Collections .singletonList (event ));
225
- mockInvocation (invocation , SampleRepository .class .getMethod ("deleteInBatch" , Iterable .class ), sample );
219
+ mockInvocation (invocation , SampleRepository .class .getMethod ("deleteInBatch" , Iterable .class ),
220
+ Arrays .asList (sample ));
226
221
227
222
EventPublishingMethodInterceptor //
228
223
.of (EventPublishingMethod .of (MultipleEvents .class ), publisher )//
@@ -236,7 +231,8 @@ void publishesEventsForCallToDeleteAllInBatchWithIterable() throws Throwable {
236
231
237
232
SomeEvent event = new SomeEvent ();
238
233
MultipleEvents sample = MultipleEvents .of (Collections .singletonList (event ));
239
- mockInvocation (invocation , SampleRepository .class .getMethod ("deleteAllInBatch" , Iterable .class ), sample );
234
+ mockInvocation (invocation , SampleRepository .class .getMethod ("deleteAllInBatch" , Iterable .class ),
235
+ Arrays .asList (sample ));
240
236
241
237
EventPublishingMethodInterceptor //
242
238
.of (EventPublishingMethod .of (MultipleEvents .class ), publisher )//
@@ -278,7 +274,7 @@ void clearsEventsEvenIfNoneWereExposedToPublish() {
278
274
279
275
EventsWithClearing entity = spy (EventsWithClearing .of (Collections .emptyList ()));
280
276
281
- EventPublishingMethod .of (EventsWithClearing .class ).publishEventsFrom (entity , publisher );
277
+ EventPublishingMethod .of (EventsWithClearing .class ).publishEventsFrom (Arrays . asList ( entity ) , publisher );
282
278
283
279
verify (entity , times (1 )).clearDomainEvents ();
284
280
}
@@ -288,7 +284,7 @@ void clearsEventsIfThereWereSomeToBePublished() {
288
284
289
285
EventsWithClearing entity = spy (EventsWithClearing .of (Collections .singletonList (new SomeEvent ())));
290
286
291
- EventPublishingMethod .of (EventsWithClearing .class ).publishEventsFrom (entity , publisher );
287
+ EventPublishingMethod .of (EventsWithClearing .class ).publishEventsFrom (Arrays . asList ( entity ) , publisher );
292
288
293
289
verify (entity , times (1 )).clearDomainEvents ();
294
290
}
0 commit comments