Commit Graph

55 Commits

Author SHA1 Message Date
Oliver Drotbohm
34ce0add03 GH-919 - Add @CheckReturnValue and use it in Scenario API. 2024-10-29 22:15:12 +01:00
Oliver Drotbohm
6da5d1dafb GH-874 - Add LICENSE and NOTICE files to binaries. 2024-10-14 22:14:51 +02:00
Oliver Drotbohm
de4668319c GH-872 - Switch test execution log output to use ApplicationModuleIdentifiers. 2024-10-13 19:41:51 +02:00
Oliver Drotbohm
0f84de8377 GH-725 - Fix test context cache key contributions.
Both ModuleContextCustomizer and ModuleTypeExcludeFilter contribute to the calculation of the context configuration which the Spring Test Context Framework uses to decide whether it's necessary to create new ApplicationContext instances.

Both of them previously used a Supplier<ModuleTestExecution> to calculate equals(…) and hashCode() which -- by definition -- does not result in the same result even when created with identical input. We now rather use the source class instance eventually backing the ModuleTestExecution, as that is the internal cache key in turn.
2024-08-10 23:56:01 +02:00
Oliver Drotbohm
3b853507c1 GH-466 - Polishing.
Moved integration test to integration tests module.
2024-07-18 23:08:29 +02:00
Lukas Dohmen
bf120cf44b GH-466 - Allow using ApplicationModuleTest outside of module packages. 2024-07-17 00:14:41 +02:00
Oliver Drotbohm
21bd2cef75 GH-587 - ModulithMetadata now exposes all base packages.
Previously, we had a variety of places calculating the overall packages to inspect for types. This is now all consolidated into the ModulithMetadata abstraction exposing them directly.
2024-05-20 19:58:30 +02:00
Oliver Drotbohm
04c1203f65 GH-587 - Additional modulith packages are now considered for application classes. 2024-05-20 19:57:23 +02:00
Oliver Drotbohm
e41d7ec083 GH-520 - Early reject invalid ApplicationModules bootstraps.
We now immediately reject the ApplicationModules bootstrap in case the initial scanning of the root packages yield no classes at all.
2024-03-05 19:34:47 +01:00
Oliver Drotbohm
c32227bdfb GH-463 - Update copyright headers. 2024-01-17 19:45:40 +01:00
Oliver Drotbohm
1e71649073 GH-449 - Guard against AutoConfiguration- and EntityScanPackages bean definitions not having any constructor argument defined. 2024-01-16 18:09:34 +01:00
Oliver Drotbohm
88f65f18cb GH-428 - Avoid duplicate inclusions of modules in test executions. 2023-12-21 22:19:36 +01:00
Oliver Drotbohm
e2cc4fe2a4 GH-345 - Properly handle manually declared entity scan and autoconfiguration packages.
If Spring Modulith packages were explicitly configured as autoconfiguration or entity scan packages, the test autoconfiguration would fail as it previously attempted to manipulate an immutable list. We now create a copy of that list to fix this.
2023-11-03 20:16:38 +01:00
Oliver Drotbohm
cef3ffbe7e GH-356 - Removed legacy way of tweaking autoconfiguration and entity scan packages for test runs. 2023-11-02 14:06:11 +01:00
Oliver Drotbohm
9148a57b02 GH-317 - Detect violations from types located in root packages.
We now create artificial root application modules for all root packages to detect violations (for example, types located in root packages referring to module-internal types).
2023-10-16 07:57:16 +02:00
Oliver Drotbohm
4a857dcddf GH-323 - Move off of Google's Suppliers.memoize(…). 2023-10-15 19:23:08 +02:00
Oliver Drotbohm
c8b81e0737 GH-320 - Explicitly drop non-bootstrapped module beans during test run.
We now explicitly drop all beans resulting in a type that's contained in an application module *not* included in the current test bootstrap.
2023-10-13 23:02:40 +02:00
Oliver Drotbohm
941394f2d5 GH-273 - Remove experimental declaration from Scenario. 2023-08-17 17:35:09 +02:00
Oliver Drotbohm
3055212e4b GH-253 - Let @ApplicationModuleTest be meta-annotated with @SpringBootTest.
@ApplicationModuleTest is now meta-annotated with @SpringBootTest. This allows us to remove a couple of declarations that we actually had copied from it (such as the TestContextBootstrapper, the SpringExtension etc.)

The presence of the original annotation allow test-related auto-configuration to inspect @SprignBootTest for particular configuration. For example, we now alias the WebEnvironment to make it configurable for the test execution.
2023-08-03 09:46:42 +02:00
Oliver Drotbohm
5dfffa2244 GH-216 - Forward an ApplicationContext's ExecutorService to Scenario instances by default.
We now register a default customizer on the Scenario instances created to pick up an ExecutorService defined in the ApplicationContext so that customizations made to that are considered in the test execution.
2023-06-23 12:49:06 +02:00
Oliver Drotbohm
516c48dc07 GH-208 - Switch to CopyOnWriteArrayList for DefaultPublishedEvents. 2023-06-23 12:49:06 +02:00
Oliver Drotbohm
6dabfb425b GH-191 - Prevent premature access of ApplicationContext from ParameterResolver implementations.
We now avoid accessing the ApplicationContext from a BeforeAllCallback as this might cause the context initialization before other extensions had time to kick in.
2023-04-30 22:35:14 +02:00
Oliver Drotbohm
0b6dccf334 GH-190 - Introduce @EnableScenarios.
The dedicated annotation allows using Scenario as test parameter in @SpringBootTest-based integration tests, too.

ScenarioParameterResolver now throws a better error message if a TransactionTemplate bean is missing from the ApplicationContext.
2023-04-30 22:35:14 +02:00
Oliver Drotbohm
bb800ba046 GH-185 - Additional simplification of delayed event verification on Scenarios. 2023-04-25 14:34:23 +02:00
Oliver Drotbohm
3a923519f2 GH-185 - Allow verification of events after method invocation stimulus. 2023-04-24 17:31:21 +02:00
Oliver Drotbohm
cd76c96250 GH-165 - Introduce ScenarioCustomizer extension.
We now provide a ScenarioCustomizer that can be used to prepare Scenario instances for test methods with a common customizer. This avoids the need to call ….customize(…) for all Scenarios declared in a test class with the same logic.
2023-04-20 14:15:10 +02:00
Oliver Drotbohm
6d2fdd6fdc GH-173 - Polishing.
@ApplicationModuleTest is now explicitly declared to only be usable on types, documented and inherited.
2023-03-27 17:56:12 +02:00
Oliver Drotbohm
822febd00e GH-173 - Support for @ApplicationModuleTest in JUnit 5 nested test classes.
We now use Spring Test Context's TestContextAnnotationUtils to lookup the @ApplicationModuleTest annotation to eventually bootstrap an ApplicationModules instance. That ensures that we find the annotation on JUnit 5's @Nested classes.
2023-03-27 17:56:04 +02:00
Oliver Drotbohm
ce264aaf96 GH-150 - Scenario now execute stimulus within new transaction.
To make sure that we trigger transactional event listeners from Scenario based integration tests, we trigger stimulus executions using transactions configured to require a new transaction. This makes sure that Scenarios work in integration tests using @Transactional, of course circumventing the default rollback behavior of those transactions. There's no other way to implement this as we *need* to commit a transaction to trigger the delivery of transaction-bound events.

Fixed a bug in the handling of Scenario.stimulus(Supplier<T>) as for this, the Supplier handed into the method had not been executed transactionally at all.
2023-02-26 20:26:53 +01:00
Oliver Drotbohm
1f6c888e28 GH-136 - Polish Javadoc. 2023-02-23 23:11:46 +01:00
Oliver Drotbohm
bb466f99e9 GH-136 - API polishing for Scenario.
Move the registration of cleanup callbacks to the intermediate When type to avoid overloads of Scenario.stimulate(…). Also, to prevent multiple lambda-style parameters for ….stimulate(…) as they don't distinguish nice on the declaration side. Removed the varargs from ….publish(…) methods and wait for the actual request to add support for preparing, in transaction callbacks (potentially to be introduced as ….prepare(…) method).

The default acceptance criteria for state change expectations now also considers a boolean true as concluding method result.
2023-02-23 22:14:20 +01:00
Oliver Drotbohm
707d27e335 GH-136 - Simple suppliers need to be executed transactionally in Scenario. 2023-02-20 20:03:09 +01:00
Oliver Drotbohm
52fdc221a1 GH-136 - Introduce Scenario as application module integration test API.
See the Javadoc of Scenario for details.
2023-02-20 16:04:10 +01:00
Oliver Drotbohm
71f928f5b0 GH-130 - Polishing.
Organized imports.
2023-02-03 11:09:07 +01:00
Oliver Drotbohm
6616aaaffa GH-116 - PublishedEvents now sees events from asynchronous event listeners as well.
The ApplicationListener we deploy to capture events published  during a test method execution now uses an InheritableThreadLocal so that events published on threads spawned from the main test execution thread also end up in the PublishedEvents instance prepared for the test method.

Also, the registration of that particular event listener avoids duplicate registrations by inspecting the application context in use for the test method execution for an already registered listener, falling back to registering one.
2023-01-13 16:13:34 +01:00
Oliver Drotbohm
5c34886907 GH-114 - Rename ….modulith.model to ….modulith.core. 2023-01-12 16:34:07 +01:00
Oliver Drotbohm
0d009f06c9 GH-111 - Package and publish Javadoc.
A lot of Javadoc polish. Not done yet.
2023-01-12 16:20:20 +01:00
Oliver Drotbohm
9ce6bf23ae GH-14 - Remove Lombok from production sources.
Polished a lot of Javadoc.
2023-01-12 01:05:35 +01:00
Oliver Drotbohm
30203ecca8 GH-104 - Polish log output for test execution.
Also added ApplicationModules.toString().
2023-01-05 10:21:42 +01:00
Oliver Drotbohm
a7e033172b GH-102 - ApplicationModules now allows traversing modules in topological order.
We now optionally integrate with the JGraphT library to calculate the topological order of modules based on their dependency structure. That order is then exposed in ApplicationModules' iteration and via ….getComparator().

Renamed FormattableJavaClass to FormattableType and allow it to be created from a plain Class as well.
2023-01-05 10:21:36 +01:00
Oliver Drotbohm
3b1bde5c36 GH-100 - Polishing. 2023-01-03 08:50:27 +01:00
Oliver Drotbohm
5d285e0e03 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.
2023-01-03 02:44:01 +01:00
Oliver Drotbohm
4e13fbf7f8 GH-99 - Extend license headers to 2023. 2023-01-02 18:12:29 +01:00
Oliver Drotbohm
c1fc3032b7 GH-87 - Expose module structure as actuator endpoint.
Introduce Spring Modulith Actuator module to expose the application module structure as Spring Boot actuator. This required a Spring Modulith Runtime module to be extracted from the Spring Modulith Observability one. The former now contains the auto-configured ApplicationRuntime and ApplicationModulesRuntime bean instances to be able to bootstrap a ApplicationModules asynchronously on application startup. The actuator module then contains a Spring Boot @Endpoint implementation consuming the ApplicationModules to render JSON describing the application module structure.
2022-12-23 10:56:47 +01:00
Oliver Drotbohm
02881539b6 GH-77 - Avoid exposing TestUtils to user applications.
Moved TestUtils from spring-modulith-test to spring-modulith-integration-test as it's only used there and doesn't need to be exposed to user applications.
2022-11-24 22:35:32 +01:00
Oliver Drotbohm
b402f00c77 GH-77 - Upgrade to Spring Boot 3.0.
Adapt to API changes in Micrometer and Spring Boot's test context loader API now exposing a checked ContextLoadException to signal failures during ApplicationContext bootstraps.
2022-11-24 22:31:49 +01:00
Oliver Drotbohm
55b16857f3 GH-69 - Switch to Stream.toList(). 2022-11-11 18:49:03 +01:00
Oliver Drotbohm
d96263fe30 GH-11, GH-66, GH-67, GH-68 - Improve module canvas.
Overhauled the module canvas in various ways. By default, we now skip "empty" rows. In other words, if we do not find any published events for example, we skip the entire row. CanvasOptions.revealEmptyRows() can be used to keep those empty rows around. We now also expose all value types and Spring bean references.

Refactored the dependency lookup APIs on ApplicationModule. Both DependencyType and DependencyDepth are now top-level types. Also, ApplicationModuleDependency and ApplicationModuleDependencies were introduced as explicit types. In the course of that, ApplicationModule.getDependencies(…) has got its return type changed from List<ApplicationModule> to ApplicationModuleDependencies. The internal ModuleDependency type has been renamed to QualifiedDependency.
2022-11-11 18:33:03 +01:00
Oliver Drotbohm
b9d46173f7 GH-56 - ModuleTestAutoConfiguration is now autoconfiguration of highest precedence.
Also, keep autoconfiguration packages as String array to avoid ClassCastExceptions when the bean definition's constructor arguments are inspected manually (like in AutoConfigurationPackages.addBasePackages(…).
2022-10-24 14:13:53 +02:00
Oliver Drotbohm
2430dc90e2 GH-46 - Bootstrap dependencies must only contain DependencyType.USES_COMPONENT. 2022-10-21 11:11:24 +02:00