Extensions: How to mock build items and capabilities produced by other extensions without introducing a circular dependency? #48424
Unanswered
stephanpelikan
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm developing a Quarkus extension for our business process management system (BPMS) framework VanillaBP. It is about bringing in hexagonal architecture in the context of business processing applications.
There is one main extension doing some annotation based wiring and processing. Any adapter (in the manner of a hexagonal architecture) for a BPMS is a separate extension providing custom build items. The main extension consumes those build items to fulfill the wiring. Additionally, I use Capabilities to validate whether configuration properties given match the adapter extensions provided.
At the moment I stuck building tests for the main extension: It needs the presence of adapter extensions to work properly. My first approach was to build a dummy adapter extension used only in test scope. This worked with capabilities only but fails once I introduced custom build items because of a circular dependency. The main extension provides the build item class > the dummy adapter extension uses the main extension deployment as a dependency > the main extension tests fail because the dummy adapter was not build yet.
It seems to me it would be better to mock adapter extensions in the tests for the main extension. Unfortunately, I didn't find any hints in the docs or the web how to mock custom build items (in real life provided by adapter extensions) and how to mock capabilities (in real life set by adapter extensions) to make this code of the main extension work:
How to test this? There are a lot of extensions consuming "custom" build items which also have to be tested.
While writing this post I digged into arc extension which consumes custom build items and I found a test which shows how to "mock" build-items. I applied this to my situation:
This works! It gives the warning
but I guess it is OK, since this is just a warning. I hope this post will help others, since documentation seems to be missing for this.
Cheery,
Stephan
Beta Was this translation helpful? Give feedback.
All reactions