@@ -127,7 +127,7 @@ void interceptsSaveMethod() throws Throwable {
127127 }
128128
129129 @ Test // DATACMNS-1663
130- public void interceptsDeleteMethod () throws Throwable {
130+ void interceptsDeleteMethod () throws Throwable {
131131 SomeEvent event = new SomeEvent ();
132132 MultipleEvents sample = MultipleEvents .of (Collections .singletonList (event ));
133133 mockInvocation (invocation , SampleRepository .class .getMethod ("delete" , Object .class ), sample );
@@ -152,7 +152,7 @@ void doesNotInterceptNonSaveMethod() throws Throwable {
152152 }
153153
154154 @ Test // DATACMNS-1663
155- public void doesNotInterceptDeleteByIdMethod () throws Throwable {
155+ void doesNotInterceptDeleteByIdMethod () throws Throwable {
156156
157157 doReturn (SampleRepository .class .getMethod ("deleteById" , Object .class )).when (invocation ).getMethod ();
158158
@@ -204,7 +204,7 @@ void publishesEventsForCallToSaveWithIterable() throws Throwable {
204204 }
205205
206206 @ Test // DATACMNS-1663
207- public void publishesEventsForCallToDeleteWithIterable () throws Throwable {
207+ void publishesEventsForCallToDeleteWithIterable () throws Throwable {
208208
209209 SomeEvent event = new SomeEvent ();
210210 MultipleEvents sample = MultipleEvents .of (Collections .singletonList (event ));
@@ -217,6 +217,34 @@ public void publishesEventsForCallToDeleteWithIterable() throws Throwable {
217217 verify (publisher ).publishEvent (any (SomeEvent .class ));
218218 }
219219
220+ @ Test // GH-2448
221+ void publishesEventsForCallToDeleteInBatchWithIterable () throws Throwable {
222+
223+ SomeEvent event = new SomeEvent ();
224+ MultipleEvents sample = MultipleEvents .of (Collections .singletonList (event ));
225+ mockInvocation (invocation , SampleRepository .class .getMethod ("deleteInBatch" , Iterable .class ), sample );
226+
227+ EventPublishingMethodInterceptor //
228+ .of (EventPublishingMethod .of (MultipleEvents .class ), publisher )//
229+ .invoke (invocation );
230+
231+ verify (publisher ).publishEvent (any (SomeEvent .class ));
232+ }
233+
234+ @ Test // GH-2448
235+ void publishesEventsForCallToDeleteAllInBatchWithIterable () throws Throwable {
236+
237+ SomeEvent event = new SomeEvent ();
238+ MultipleEvents sample = MultipleEvents .of (Collections .singletonList (event ));
239+ mockInvocation (invocation , SampleRepository .class .getMethod ("deleteAllInBatch" , Iterable .class ), sample );
240+
241+ EventPublishingMethodInterceptor //
242+ .of (EventPublishingMethod .of (MultipleEvents .class ), publisher )//
243+ .invoke (invocation );
244+
245+ verify (publisher ).publishEvent (any (SomeEvent .class ));
246+ }
247+
220248 @ Test // DATACMNS-975
221249 void publishesEventsAfterSaveInvocation () throws Throwable {
222250
@@ -294,6 +322,17 @@ void publishesEventFromParameter() throws Throwable {
294322 verify (publisher , times (1 )).publishEvent (event );
295323 }
296324
325+ @ Test // GH-2448
326+ void doesNotEmitEventsFromPrimitiveValue () throws Throwable {
327+
328+ Method method = SampleRepository .class .getMethod ("delete" , Object .class );
329+ mockInvocation (invocation , method , "foo" , MultipleEvents .of (Collections .emptySet ()));
330+
331+ EventPublishingMethodInterceptor .of (EventPublishingMethod .of (MultipleEvents .class ), publisher ).invoke (invocation );
332+
333+ verify (publisher , never ()).publishEvent (any ());
334+ }
335+
297336 private static void mockInvocation (MethodInvocation invocation , Method method , Object parameterAndReturnValue )
298337 throws Throwable {
299338
@@ -322,17 +361,23 @@ void clearDomainEvents() {}
322361 }
323362
324363 @ Value (staticConstructor = "of" )
325- static class OneEvent {
364+ private static class OneEvent {
326365 @ Getter (onMethod = @ __ (@ DomainEvents )) Object event ;
327366 }
328367
329368 @ Value
330- static class SomeEvent {
369+ private static class SomeEvent {
331370 UUID id = UUID .randomUUID ();
332371 }
333372
334373 interface SampleRepository extends CrudRepository <MultipleEvents , Long > {
335374
336375 MultipleEvents saveAndFlush (MultipleEvents events );
376+
377+ MultipleEvents delete (String name );
378+
379+ MultipleEvents deleteAllInBatch (Iterable <MultipleEvents > events );
380+
381+ MultipleEvents deleteInBatch (Iterable <MultipleEvents > events );
337382 }
338383}
0 commit comments