diff --git a/spring-modulith-core/src/main/java/org/springframework/modulith/core/util/CheckReturnValue.java b/spring-modulith-core/src/main/java/org/springframework/modulith/core/util/CheckReturnValue.java index 38442719..0b3378ba 100644 --- a/spring-modulith-core/src/main/java/org/springframework/modulith/core/util/CheckReturnValue.java +++ b/spring-modulith-core/src/main/java/org/springframework/modulith/core/util/CheckReturnValue.java @@ -27,6 +27,7 @@ import java.lang.annotation.Target; * "https://github.com/findbugsproject/findbugs/blob/264ae7baf890d2b347d91805c90057062b5dcb1e/findbugs/src/java/edu/umd/cs/findbugs/detect/BuildCheckReturnAnnotationDatabase.java#L120">Findbugs * source code * @since 1.3 + * @deprecated since 1.4, use Spring Framework's {@link org.springframework.lang.CheckReturnValue} instead. */ @Target({ ElementType.CONSTRUCTOR, @@ -34,5 +35,6 @@ import java.lang.annotation.Target; ElementType.PACKAGE, ElementType.TYPE, }) +@Deprecated(since = "1.4", forRemoval = true) @Retention(RetentionPolicy.CLASS) public @interface CheckReturnValue {} diff --git a/spring-modulith-test/src/main/java/org/springframework/modulith/test/Scenario.java b/spring-modulith-test/src/main/java/org/springframework/modulith/test/Scenario.java index a6838a90..1ff8d032 100644 --- a/spring-modulith-test/src/main/java/org/springframework/modulith/test/Scenario.java +++ b/spring-modulith-test/src/main/java/org/springframework/modulith/test/Scenario.java @@ -31,8 +31,8 @@ import java.util.function.Supplier; import org.awaitility.Awaitility; import org.awaitility.core.ConditionFactory; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.lang.CheckReturnValue; import org.springframework.lang.Nullable; -import org.springframework.modulith.core.util.CheckReturnValue; import org.springframework.modulith.test.PublishedEvents.TypedPublishedEvents; import org.springframework.modulith.test.PublishedEventsAssert.PublishedEventAssert; import org.springframework.transaction.TransactionDefinition; @@ -53,7 +53,6 @@ import org.springframework.util.Assert; * @author Oliver Drotbohm * @see ApplicationModuleTest */ -@CheckReturnValue public class Scenario { private static final Predicate DEFAULT_ACCEPTANCE = it -> { @@ -110,6 +109,7 @@ public class Scenario { * @param event must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When publish(Object event) { return stimulate((tx, e) -> { tx.executeWithoutResult(__ -> e.publishEvent(event)); @@ -123,6 +123,7 @@ public class Scenario { * @param event must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When publish(Supplier event) { return stimulate((tx, e) -> { @@ -136,6 +137,7 @@ public class Scenario { * @param runnable must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When stimulate(Runnable runnable) { Assert.notNull(runnable, "Runnable must not be null!"); @@ -156,6 +158,7 @@ public class Scenario { * @see org.springframework.modulith.test.Scenario.When.StateChangeResult#andVerify(Consumer) * @see org.springframework.modulith.test.Scenario.When.EventResult#toArriveAndVerify(Consumer) */ + @CheckReturnValue public When stimulate(Supplier supplier) { return stimulate(tx -> tx.execute(__ -> supplier.get())); } @@ -168,6 +171,7 @@ public class Scenario { * @param function must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When stimulate(Function function) { return stimulate((tx, __) -> { return function.apply(tx); @@ -181,6 +185,7 @@ public class Scenario { * @param stimulus must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When stimulate(BiConsumer stimulus) { Assert.notNull(stimulus, "Stimulus must not be null!"); @@ -199,6 +204,7 @@ public class Scenario { * @param stimulus must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When stimulate(BiFunction stimulus) { Assert.notNull(stimulus, "Stimulus must not be null!"); @@ -221,7 +227,6 @@ public class Scenario { return this; } - @CheckReturnValue public class When { private final BiFunction stimulus; @@ -247,6 +252,7 @@ public class Scenario { * @param runnable must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When andCleanup(Runnable runnable) { Assert.notNull(runnable, "Cleanup callback must not be null!"); @@ -261,6 +267,7 @@ public class Scenario { * @param consumer must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When andCleanup(Consumer consumer) { Assert.notNull(consumer, "Cleanup callback must not be null!"); @@ -277,6 +284,7 @@ public class Scenario { * @param duration must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When andWaitAtMost(Duration duration) { Assert.notNull(duration, "Duration must not be null!"); @@ -292,6 +300,7 @@ public class Scenario { * @param customizer must not be {@literal null}. * @return will never be {@literal null}. */ + @CheckReturnValue public When customize(Function customizer) { Assert.notNull(customizer, "Customizer must not be null!"); @@ -310,6 +319,7 @@ public class Scenario { * @return will never be {@literal null}. * @see #andWaitForEventOfType(Class) */ + @CheckReturnValue public EventResult forEventOfType(Class type) { return andWaitForEventOfType(type); } @@ -323,6 +333,7 @@ public class Scenario { * @return will never be {@literal null}. * @see #andWaitForStateChange(Supplier) */ + @CheckReturnValue public StateChangeResult forStateChange(Supplier supplier) { return forStateChange(supplier, DEFAULT_ACCEPTANCE); } @@ -337,6 +348,7 @@ public class Scenario { * @return will never be {@literal null}. * @see #andWaitForStateChange(Supplier, Predicate) */ + @CheckReturnValue public StateChangeResult forStateChange(Supplier supplier, Predicate acceptanceCriteria) { return andWaitForStateChange(supplier, acceptanceCriteria); } @@ -350,6 +362,7 @@ public class Scenario { * @return will never be {@literal null}. * @see #forEventOfType(Class) */ + @CheckReturnValue public EventResult andWaitForEventOfType(Class type) { return new EventResult(type, Function.identity(), null); } @@ -365,6 +378,7 @@ public class Scenario { * @return will never be {@literal null}. * @see #forStateChange(Supplier) */ + @CheckReturnValue public StateChangeResult andWaitForStateChange(Supplier supplier) { return andWaitForStateChange(supplier, DEFAULT_ACCEPTANCE); } @@ -379,6 +393,7 @@ public class Scenario { * @return will never be {@literal null}. * @see #andWaitForStateChange(Supplier, Predicate) */ + @CheckReturnValue public StateChangeResult andWaitForStateChange(Supplier supplier, Predicate acceptanceCriteria) {