Class FlowableDmnExtension

java.lang.Object
org.flowable.dmn.engine.test.FlowableDmnExtension
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:
FlowableDmnSpringExtension

public class FlowableDmnExtension extends Object implements org.junit.jupiter.api.extension.ParameterResolver, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
JUnit Jupiter extension for the Flowable DmnEngine and services initialization.

Usage:

 @ExtendWith(FlowableDmnExtension.class)
 class YourTest {

   @BeforeEach
   void setUp(DmnEngine dmnEngine) {
       ...
   }

   @Test
   void myTest(DmnRuleService ruleService) {
       ...
   }

   ...
 }
 

The DmnEngine and the services will be made available to the test class through the parameter resolution (BeforeEach, AfterEach, test methods). The DmnEngine will be initialized by default with the flowable.dmn.cfg.xml resource on the classpath. To specify a different configuration file, annotate your class with DmnConfigurationResource. Dmn 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 dmn engine will be constructed.

You can declare a deployment with the DmnDeployment or DmnDeploymentAnnotation annotation. If both annotations are used then DmnDeployment takes precedence and DmnDeploymentAnnotation will be ignored. This extensions will make sure that this deployment gets deployed before the setUp and DmnRepositoryService.deleteDeployment(String) cascade deleted} after the tearDown. The id of the deployment can be accessed by using DmnDeploymentId in a test or lifecycle method.

FlowableDmnTestHelper.setCurrentTime(Instant) can be used to set the current time used by the dmn engine} This can be handy to control the exact time that is used by the engine in order to verify e.g. due dates. Or start, end and duration times in the history service. 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 Details

    • DEFAULT_CONFIGURATION_RESOURCE

      public static final String DEFAULT_CONFIGURATION_RESOURCE
      See Also:
    • logger

      protected final org.slf4j.Logger logger
  • Constructor Details

    • FlowableDmnExtension

      public FlowableDmnExtension()
  • Method Details

    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
    • supportsParameter

      public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      supportsParameter in interface org.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:
      resolveParameter in interface org.junit.jupiter.api.extension.ParameterResolver
    • getConfigurationResource

      protected String getConfigurationResource(org.junit.jupiter.api.extension.ExtensionContext context)
    • getTestHelper

      protected FlowableDmnTestHelper getTestHelper(org.junit.jupiter.api.extension.ExtensionContext context)
    • createDmnEngine

      protected DmnEngine createDmnEngine(org.junit.jupiter.api.extension.ExtensionContext context)
    • getStore

      protected org.junit.jupiter.api.extension.ExtensionContext.Store getStore(org.junit.jupiter.api.extension.ExtensionContext context)