Package org.imixs.workflow.engine
Class WorkflowMockEnvironment
java.lang.Object
org.imixs.workflow.engine.WorkflowMockEnvironment
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 Summary
FieldsModifier and TypeFieldDescriptionprotected org.imixs.workflow.engine.adapters.AccessAdapterprotected List<org.imixs.workflow.Adapter>protected org.imixs.workflow.engine.DocumentServiceprotected static final Loggerprotected org.imixs.workflow.engine.ModelServiceprotected WorkflowContextMockprotected org.imixs.workflow.engine.WorkflowService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCreate a test database with some workItems and a simple modelorg.imixs.workflow.engine.DocumentServiceorg.imixs.workflow.engine.ModelServiceorg.imixs.workflow.engine.WorkflowServicevoidinjectMockIntoField(Object targetObject, String fieldName, Object value) Helper method to inject a mock into a private/protected field using reflection.voidloadBPMNModel(String modelPath) Helper method that loads a new model into the ModelServicevoidregisterAdapter(org.imixs.workflow.Adapter adapter) Can be used to register an Adapter before SetupvoidsetUp()The Setup method initializes a mock environment to test the imixs workflow service.
-
Field Details
-
logger
-
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
-
adapterList
-
-
Constructor Details
-
WorkflowMockEnvironment
public WorkflowMockEnvironment()
-
-
Method Details
-
getModelService
public org.imixs.workflow.engine.ModelService getModelService() -
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.PluginExceptionThe 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
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
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.
-