|
35 | 35 | import org.springframework.context.PayloadApplicationEvent;
|
36 | 36 | import org.springframework.modulith.test.PublishedEventsAssert.PublishedEventAssert;
|
37 | 37 | import org.springframework.modulith.test.Scenario.When;
|
| 38 | +import org.springframework.transaction.TransactionException; |
| 39 | +import org.springframework.transaction.support.SimpleTransactionStatus; |
| 40 | +import org.springframework.transaction.support.TransactionCallback; |
38 | 41 | import org.springframework.transaction.support.TransactionOperations;
|
39 | 42 |
|
40 | 43 | /**
|
|
43 | 46 | * @author Oliver Drotbohm
|
44 | 47 | */
|
45 | 48 | @ExtendWith(MockitoExtension.class)
|
46 |
| -public class ScenarioUnitTests { |
| 49 | +class ScenarioUnitTests { |
47 | 50 |
|
48 | 51 | private static final Duration DELAY = Duration.ofMillis(50);
|
49 | 52 | private static final Duration WAIT_TIME = Duration.ofMillis(101);
|
50 | 53 | private static final Duration TIMED_OUT = Duration.ofMillis(150);
|
51 | 54 |
|
52 |
| - @Mock TransactionOperations tx; |
53 | 55 | @Mock ApplicationEventPublisher publisher;
|
| 56 | + TransactionOperations tx = StubTransactionOperations.INSTANCE; |
54 | 57 |
|
55 | 58 | @Test // GH-136
|
56 | 59 | void timesOutIfNoEventArrivesInTime() throws Throwable {
|
@@ -417,6 +420,20 @@ private void foo() {
|
417 | 420 |
|
418 | 421 | record SomeEvent(String payload) {}
|
419 | 422 |
|
| 423 | + enum StubTransactionOperations implements TransactionOperations { |
| 424 | + |
| 425 | + INSTANCE; |
| 426 | + |
| 427 | + /* |
| 428 | + * (non-Javadoc) |
| 429 | + * @see org.springframework.transaction.support.TransactionOperations#execute(org.springframework.transaction.support.TransactionCallback) |
| 430 | + */ |
| 431 | + @Override |
| 432 | + public <T> T execute(TransactionCallback<T> action) throws TransactionException { |
| 433 | + return action.doInTransaction(new SimpleTransactionStatus()); |
| 434 | + } |
| 435 | + } |
| 436 | + |
420 | 437 | static class CapturingExceptionHandler implements UncaughtExceptionHandler {
|
421 | 438 |
|
422 | 439 | Throwable caught;
|
|
0 commit comments