Class FlowableEventExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.BeforeEachCallback,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.ParameterResolver
- Direct Known Subclasses:
FlowableEventSpringExtension
Usage:
@ExtendWith(FlowableEventExtension.class)
class YourTest {
@BeforeEach
void setUp(EventRegistryEngine eventRegistryEngine) {
...
}
@Test
void myTest(EventRepositoryService eventRepositoryService) {
...
}
...
}
The EventRegistryEngine and the services will be made available to the test class through the parameter resolution (BeforeEach, AfterEach, test methods).
The EventRegistryEngine will be initialized by default with the flowable.eventregistry.cfg.xml resource on the classpath.
To specify a different configuration file, annotate your class with EventConfigurationResource.
Event registry engines will be cached as part of the JUnit Jupiter Extension context.
Right before the first time the setUp is called for a given configuration resource, the event registry engine will be constructed.
You can declare a deployment with the EventDeploymentAnnotation annotation. This extension will make sure that this deployment gets deployed
before the setUp and deleted after the tearDown.
The id of the deployment can be accessed by using EventDeploymentId in a test method.
FlowableEventTestHelper.setCurrentTime(Date) can be used to set the current time used by the event registry engine}
This can be handy to control the exact time that is used by the engine in order to verify e.g. e.g. due dates of timers.
In the tearDown, the internal clock will automatically be reset to use the current system
time rather then the time that was set during a test method.
- Author:
- Filip Hrisafov
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) protected voidassertAndEnsureCleanDb(EventRegistryEngine eventRegistryEngine, org.junit.jupiter.api.extension.ExtensionContext context, EnsureCleanDb ensureCleanDb) Each test is assumed to clean up all DB content it entered.voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) protected voidcleanTestAndAssertAndEnsureCleanDb(org.junit.jupiter.api.extension.ExtensionContext context, EventRegistryEngine eventRegistryEngine) protected EventRegistryEnginecreateEventRegistryEngine(org.junit.jupiter.api.extension.ExtensionContext context) protected StringgetConfigurationResource(org.junit.jupiter.api.extension.ExtensionContext context) protected org.junit.jupiter.api.extension.ExtensionContext.StoregetStore(org.junit.jupiter.api.extension.ExtensionContext context) protected FlowableEventTestHelpergetTestHelper(org.junit.jupiter.api.extension.ExtensionContext context) resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext context) booleansupportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext context)
-
Field Details
-
DEFAULT_CONFIGURATION_RESOURCE
- See Also:
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Details
-
FlowableEventExtension
public FlowableEventExtension()
-
-
Method Details
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback
-
cleanTestAndAssertAndEnsureCleanDb
protected void cleanTestAndAssertAndEnsureCleanDb(org.junit.jupiter.api.extension.ExtensionContext context, EventRegistryEngine eventRegistryEngine) -
assertAndEnsureCleanDb
protected void assertAndEnsureCleanDb(EventRegistryEngine eventRegistryEngine, org.junit.jupiter.api.extension.ExtensionContext context, EnsureCleanDb ensureCleanDb) Each test is assumed to clean up all DB content it entered. After a test method executed, this method scans all tables to see if the DB is completely clean. It throws AssertionFailed in case the DB is not clean. If the DB is not clean, it is cleaned by performing a create a drop. -
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
supportsParameterin interfaceorg.junit.jupiter.api.extension.ParameterResolver
-
resolveParameter
public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
resolveParameterin interfaceorg.junit.jupiter.api.extension.ParameterResolver
-
getConfigurationResource
-
getTestHelper
protected FlowableEventTestHelper getTestHelper(org.junit.jupiter.api.extension.ExtensionContext context) -
createEventRegistryEngine
protected EventRegistryEngine createEventRegistryEngine(org.junit.jupiter.api.extension.ExtensionContext context) -
getStore
protected org.junit.jupiter.api.extension.ExtensionContext.Store getStore(org.junit.jupiter.api.extension.ExtensionContext context)
-