GH-100 - Introduce AssertablePublishedEvents.

In case AssertJ is on the classpath, test cases using the PublishedEventsExtension (for example, implicitly activated via @ApplicationModuleTest) can get an AssertablePublishedEvents injected into the method. In contrast to the original PublishedEvents, that one acts as AssertProvider so that it can be used in assertThat(…).… expressions to verify application events published.

Polished API in PublishedEvents for a more consistent experience.
This commit is contained in:
Oliver Drotbohm
2023-01-03 02:44:01 +01:00
parent 4e13fbf7f8
commit 5d285e0e03
8 changed files with 316 additions and 19 deletions

View File

@@ -36,7 +36,7 @@ import org.springframework.util.ReflectionUtils;
*
* @author Oliver Drotbohm
*/
public class PublishedEventsParameterResolverUnitTests {
class PublishedEventsParameterResolverUnitTests {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@@ -46,6 +46,7 @@ public class PublishedEventsParameterResolverUnitTests {
PublishedEventsParameterResolver resolver = new PublishedEventsParameterResolver(__ -> context);
assertThat(resolver.supportsParameter(getParameterContext(PublishedEvents.class), null)).isTrue();
assertThat(resolver.supportsParameter(getParameterContext(AssertablePublishedEvents.class), null)).isTrue();
assertThat(resolver.supportsParameter(getParameterContext(Object.class), null)).isFalse();
}
@@ -99,5 +100,7 @@ public class PublishedEventsParameterResolverUnitTests {
void with(PublishedEvents events);
void with(Object object);
void with(AssertablePublishedEvents events);
}
}