31
31
import org .awaitility .Awaitility ;
32
32
import org .awaitility .core .ConditionFactory ;
33
33
import org .springframework .context .ApplicationEventPublisher ;
34
+ import org .springframework .lang .CheckReturnValue ;
34
35
import org .springframework .lang .Nullable ;
35
- import org .springframework .modulith .core .util .CheckReturnValue ;
36
36
import org .springframework .modulith .test .PublishedEvents .TypedPublishedEvents ;
37
37
import org .springframework .modulith .test .PublishedEventsAssert .PublishedEventAssert ;
38
38
import org .springframework .transaction .TransactionDefinition ;
53
53
* @author Oliver Drotbohm
54
54
* @see ApplicationModuleTest
55
55
*/
56
- @ CheckReturnValue
57
56
public class Scenario {
58
57
59
58
private static final Predicate <Object > DEFAULT_ACCEPTANCE = it -> {
@@ -110,6 +109,7 @@ public class Scenario {
110
109
* @param event must not be {@literal null}.
111
110
* @return will never be {@literal null}.
112
111
*/
112
+ @ CheckReturnValue
113
113
public When <Void > publish (Object event ) {
114
114
return stimulate ((tx , e ) -> {
115
115
tx .executeWithoutResult (__ -> e .publishEvent (event ));
@@ -123,6 +123,7 @@ public When<Void> publish(Object event) {
123
123
* @param event must not be {@literal null}.
124
124
* @return will never be {@literal null}.
125
125
*/
126
+ @ CheckReturnValue
126
127
public When <Void > publish (Supplier <Object > event ) {
127
128
128
129
return stimulate ((tx , e ) -> {
@@ -136,6 +137,7 @@ public When<Void> publish(Supplier<Object> event) {
136
137
* @param runnable must not be {@literal null}.
137
138
* @return will never be {@literal null}.
138
139
*/
140
+ @ CheckReturnValue
139
141
public When <Void > stimulate (Runnable runnable ) {
140
142
141
143
Assert .notNull (runnable , "Runnable must not be null!" );
@@ -156,6 +158,7 @@ public When<Void> stimulate(Runnable runnable) {
156
158
* @see org.springframework.modulith.test.Scenario.When.StateChangeResult#andVerify(Consumer)
157
159
* @see org.springframework.modulith.test.Scenario.When.EventResult#toArriveAndVerify(Consumer)
158
160
*/
161
+ @ CheckReturnValue
159
162
public <S > When <S > stimulate (Supplier <S > supplier ) {
160
163
return stimulate (tx -> tx .execute (__ -> supplier .get ()));
161
164
}
@@ -168,6 +171,7 @@ public <S> When<S> stimulate(Supplier<S> supplier) {
168
171
* @param function must not be {@literal null}.
169
172
* @return will never be {@literal null}.
170
173
*/
174
+ @ CheckReturnValue
171
175
public <S > When <S > stimulate (Function <TransactionOperations , S > function ) {
172
176
return stimulate ((tx , __ ) -> {
173
177
return function .apply (tx );
@@ -181,6 +185,7 @@ public <S> When<S> stimulate(Function<TransactionOperations, S> function) {
181
185
* @param stimulus must not be {@literal null}.
182
186
* @return will never be {@literal null}.
183
187
*/
188
+ @ CheckReturnValue
184
189
public When <Void > stimulate (BiConsumer <TransactionOperations , ApplicationEventPublisher > stimulus ) {
185
190
186
191
Assert .notNull (stimulus , "Stimulus must not be null!" );
@@ -199,6 +204,7 @@ public When<Void> stimulate(BiConsumer<TransactionOperations, ApplicationEventPu
199
204
* @param stimulus must not be {@literal null}.
200
205
* @return will never be {@literal null}.
201
206
*/
207
+ @ CheckReturnValue
202
208
public <S > When <S > stimulate (BiFunction <TransactionOperations , ApplicationEventPublisher , S > stimulus ) {
203
209
204
210
Assert .notNull (stimulus , "Stimulus must not be null!" );
@@ -221,7 +227,6 @@ Scenario setDefaultCustomizer(Function<ConditionFactory, ConditionFactory> custo
221
227
return this ;
222
228
}
223
229
224
- @ CheckReturnValue
225
230
public class When <T > {
226
231
227
232
private final BiFunction <TransactionOperations , ApplicationEventPublisher , T > stimulus ;
@@ -247,6 +252,7 @@ public class When<T> {
247
252
* @param runnable must not be {@literal null}.
248
253
* @return will never be {@literal null}.
249
254
*/
255
+ @ CheckReturnValue
250
256
public When <T > andCleanup (Runnable runnable ) {
251
257
252
258
Assert .notNull (runnable , "Cleanup callback must not be null!" );
@@ -261,6 +267,7 @@ public When<T> andCleanup(Runnable runnable) {
261
267
* @param consumer must not be {@literal null}.
262
268
* @return will never be {@literal null}.
263
269
*/
270
+ @ CheckReturnValue
264
271
public When <T > andCleanup (Consumer <T > consumer ) {
265
272
266
273
Assert .notNull (consumer , "Cleanup callback must not be null!" );
@@ -277,6 +284,7 @@ public When<T> andCleanup(Consumer<T> consumer) {
277
284
* @param duration must not be {@literal null}.
278
285
* @return will never be {@literal null}.
279
286
*/
287
+ @ CheckReturnValue
280
288
public When <T > andWaitAtMost (Duration duration ) {
281
289
282
290
Assert .notNull (duration , "Duration must not be null!" );
@@ -292,6 +300,7 @@ public When<T> andWaitAtMost(Duration duration) {
292
300
* @param customizer must not be {@literal null}.
293
301
* @return will never be {@literal null}.
294
302
*/
303
+ @ CheckReturnValue
295
304
public When <T > customize (Function <ConditionFactory , ConditionFactory > customizer ) {
296
305
297
306
Assert .notNull (customizer , "Customizer must not be null!" );
@@ -310,6 +319,7 @@ public When<T> customize(Function<ConditionFactory, ConditionFactory> customizer
310
319
* @return will never be {@literal null}.
311
320
* @see #andWaitForEventOfType(Class)
312
321
*/
322
+ @ CheckReturnValue
313
323
public <E > EventResult <E > forEventOfType (Class <E > type ) {
314
324
return andWaitForEventOfType (type );
315
325
}
@@ -323,6 +333,7 @@ public <E> EventResult<E> forEventOfType(Class<E> type) {
323
333
* @return will never be {@literal null}.
324
334
* @see #andWaitForStateChange(Supplier)
325
335
*/
336
+ @ CheckReturnValue
326
337
public <S > StateChangeResult <S > forStateChange (Supplier <S > supplier ) {
327
338
return forStateChange (supplier , DEFAULT_ACCEPTANCE );
328
339
}
@@ -337,6 +348,7 @@ public <S> StateChangeResult<S> forStateChange(Supplier<S> supplier) {
337
348
* @return will never be {@literal null}.
338
349
* @see #andWaitForStateChange(Supplier, Predicate)
339
350
*/
351
+ @ CheckReturnValue
340
352
public <S > StateChangeResult <S > forStateChange (Supplier <S > supplier , Predicate <? super S > acceptanceCriteria ) {
341
353
return andWaitForStateChange (supplier , acceptanceCriteria );
342
354
}
@@ -350,6 +362,7 @@ public <S> StateChangeResult<S> forStateChange(Supplier<S> supplier, Predicate<?
350
362
* @return will never be {@literal null}.
351
363
* @see #forEventOfType(Class)
352
364
*/
365
+ @ CheckReturnValue
353
366
public <E > EventResult <E > andWaitForEventOfType (Class <E > type ) {
354
367
return new EventResult <E >(type , Function .identity (), null );
355
368
}
@@ -365,6 +378,7 @@ public <E> EventResult<E> andWaitForEventOfType(Class<E> type) {
365
378
* @return will never be {@literal null}.
366
379
* @see #forStateChange(Supplier)
367
380
*/
381
+ @ CheckReturnValue
368
382
public <S > StateChangeResult <S > andWaitForStateChange (Supplier <S > supplier ) {
369
383
return andWaitForStateChange (supplier , DEFAULT_ACCEPTANCE );
370
384
}
@@ -379,6 +393,7 @@ public <S> StateChangeResult<S> andWaitForStateChange(Supplier<S> supplier) {
379
393
* @return will never be {@literal null}.
380
394
* @see #andWaitForStateChange(Supplier, Predicate)
381
395
*/
396
+ @ CheckReturnValue
382
397
public <S > StateChangeResult <S > andWaitForStateChange (Supplier <S > supplier ,
383
398
Predicate <? super S > acceptanceCriteria ) {
384
399
0 commit comments