Class WorkflowMockEnvironment

java.lang.Object
org.imixs.workflow.engine.WorkflowMockEnvironment

public class WorkflowMockEnvironment extends Object
The AbstractWorkflowServiceTest can be used as a base class for junit tests to mock the Imixs WorkflowService. The class mocks the WorkflowService and a workflow environment including the ModelService. Junit tests can extend the AbstractWorkflowServiceTest to verify specific method implementations of the workflowService, Plugin classes or Adapters in a easy way.

Because this is a abstract base test class we annotate the MockitoSettings Strictness to avoid org.mockito.exceptions.misusing.UnnecessaryStubbingException.

Author:
rsoika
  • Field Details

    • logger

      protected static final Logger logger
    • database

      protected Map<String,org.imixs.workflow.ItemCollection> database
    • documentService

      @Mock protected org.imixs.workflow.engine.DocumentService documentService
    • modelService

      @InjectMocks protected org.imixs.workflow.engine.ModelService modelService
    • workflowService

      @InjectMocks protected org.imixs.workflow.engine.WorkflowService workflowService
    • accessAdapter

      @InjectMocks protected org.imixs.workflow.engine.adapters.AccessAdapter accessAdapter
    • workflowContext

      protected WorkflowContextMock workflowContext
    • adapterList

      protected List<org.imixs.workflow.Adapter> adapterList
  • Constructor Details

    • WorkflowMockEnvironment

      public WorkflowMockEnvironment()
  • Method Details

    • getModelService

      public org.imixs.workflow.engine.ModelService getModelService()
    • getWorkflowContext

      public WorkflowContextMock getWorkflowContext()
    • getDocumentService

      public org.imixs.workflow.engine.DocumentService getDocumentService()
    • getWorkflowService

      public org.imixs.workflow.engine.WorkflowService getWorkflowService()
    • registerAdapter

      public void registerAdapter(org.imixs.workflow.Adapter adapter)
      Can be used to register an Adapter before Setup
      Parameters:
      adapter -
    • setUp

      public void setUp() throws org.imixs.workflow.exceptions.PluginException
      The Setup method initializes a mock environment to test the imixs workflow service. It initializes a in-memory database and a model Service as also a Session context object.

      You can overwrite this method in a junit test to add additional test settings.

      Throws:
      org.imixs.workflow.exceptions.PluginException
    • loadBPMNModel

      public void loadBPMNModel(String modelPath)
      Helper method that loads a new model into the ModelService
      Parameters:
      modelPath -
    • createTestDatabase

      protected void createTestDatabase()
      Create a test database with some workItems and a simple model
    • injectMockIntoField

      public void injectMockIntoField(Object targetObject, String fieldName, Object value)
      Helper method to inject a mock into a private/protected field using reflection.
      Parameters:
      targetObject - The object into which the field is to be injected.
      fieldName - The name of the field to inject.
      value - The mock or object to inject into the field.