DATACMNS-1067 - Polishing.

Revert change to only invoke cleanup method if events have been exposed. We now again invoke the cleanup method for every aggregate. Changed the publication of events from the aggregate instances that were handed into the method to the ones the save method returns as the save call might return different object instances.

Cleanups in the unit tests. Moved newly introduced methods to the bottom of the test case class. Extracted method to set up mock method invocation.

Original pull request: #216.
This commit is contained in:
Oliver Gierke
2017-05-15 15:39:52 +02:00
parent 417fad340b
commit 71977c9309
2 changed files with 50 additions and 51 deletions

View File

@@ -94,9 +94,7 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
return result;
}
for (Object argument : invocation.getArguments()) {
eventMethod.publishEventsFrom(argument, publisher);
}
eventMethod.publishEventsFrom(result, publisher);
return result;
}
@@ -165,12 +163,12 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
}
for (Object aggregateRoot : asCollection(object)) {
Collection<Object> events = asCollection(ReflectionUtils.invokeMethod(publishingMethod, aggregateRoot));
for (Object event : events) {
for (Object event : asCollection(ReflectionUtils.invokeMethod(publishingMethod, aggregateRoot))) {
publisher.publishEvent(event);
}
if (clearingMethod != null && !events.isEmpty()) {
if (clearingMethod != null) {
ReflectionUtils.invokeMethod(clearingMethod, aggregateRoot);
}
}