+ * {@link Scenario} can be used as JUnit test method parameter in {@link ApplicationModuleTest}s.
+ *
+ * @author Oliver Drotbohm
+ * @see ApplicationModuleTest
+ */
+@API(status = Status.EXPERIMENTAL)
+public class Scenario {
+
+ private final TransactionOperations transactionOperations;
+ private final ApplicationEventPublisher publisher;
+ private final AssertablePublishedEvents events;
+
+ /**
+ * Creates a new {@link Scenario} for the given {@link TransactionOperations}, {@link ApplicationEventPublisher} and
+ * {@link AssertablePublishedEvents}.
+ *
+ * @param transactionOperations must not be {@literal null}.
+ * @param publisher must not be {@literal null}.
+ * @param events must not be {@literal null}.
+ */
+ Scenario(TransactionOperations transactionOperations, ApplicationEventPublisher publisher,
+ AssertablePublishedEvents events) {
+
+ Assert.notNull(transactionOperations, "TransactionOperations must not be null!");
+ Assert.notNull(publisher, "ApplicationEventPublisher must not be null!");
+ Assert.notNull(events, "AssertablePublishedEvents must not be null!");
+
+ this.transactionOperations = transactionOperations;
+ this.publisher = publisher;
+ this.events = events;
+ }
+
+ /**
+ * Publishes the given event. The event will be published in a transaction to make sure that transactional event
+ * listeners are invoked as well.
+ *
+ * @param event must not be {@literal null}.
+ * @return will never be {@literal null}.
+ */
+ public When