Details
-
New Feature
-
Resolution: Unresolved
-
Low
-
None
-
None
-
None
-
None
Description
*UPD 21.02.2023*
- the mentioned test class is now here
- The not-so-favored @NodeApiTest approach has been implemented.
Context
While developing some Norsu integrations in magnolia integration modules we've noticed that we need a `ContentAPI` object to query the Norsu backend from within the test code, E2E fashion (example of usage of an annotation that bootstraps a Norsu Postgresql container: https://git.magnolia-cms.com/projects/CLOUD/repos/norsu/browse/rest-integration/src/test/java/info/magnolia/norsu/rest/NorsuDeliveryEndpointTest.java#64 ).
Current status
All integration tests which need a `ContentAPI` instance have to do their own bootstrapping of the `ContentAPI` class (example: https://git.magnolia-cms.com/projects/CLOUD/repos/norsu/browse/rest-integration/src/test/java/info/magnolia/norsu/rest/NorsuDeliveryEndpointTest.java#218-223 ) using the `DataSource` which the `@NorsuTest` provides.
While creating another extension such as `@NodeAPITest` might be a possible solution, we think it's a workaround that can be better solved elsewhere. (BTW: `@NorsuTest` is a prerequisite to the ContentAPI so it cannot be retrofitted to include such feature). Providing this `@ContentAPITest` extension might be proposed in a separate effort and a ticket would be issued in that case.
Proposal
The better solution is, in our opinion, to have a way to bootstrap a basic, for tests, magnolia platform in our magnolia integration modules test (ie: having the IoC framework and other parts) which will be able to provide the basic magnolia building blocks to an integration test, much like what somehow currently `FakeMagnoliaUI` does.
In this particular case, the solution, when adequately integrated with Norsu (or whatever other integration) would bootstrap the actual `ContentAPI` that a running magnolia bundle would use; and we could just grab it (like with an `@Inject` field) and then use it in the test. (This is much similar to what `@SpringBootTest` does)