With the new project Imixs-Mock you can now simulate your Imixs-Workflow BPMN models in an easy way. The project provides a full mock of the Imixs-Workflow engine and allows to test and simulate different workflow scenarios. Imixs-Mock simulates the full processing life-cycle including all workflow plug-ins. You can specify also a subset of plug-ins to test specific business logic in your workflow project.
To add the mock into your own workflow project just add the following dependencies:
<dependency>
<groupId>org.imixs.workflow</groupId>
<artifactId>imixs-mock</artifactId>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
<!-- JUnit Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
Now you can write your jUnit test class to verify your BPMN model. See the following example code:
@Test
public void testSimple() {
workitem = new ItemCollection();
workitem.model("ticket-workflow-1.0").task(1000).event(10);
workitem.replaceItemValue("_subject", "Hello World");
try {
workitem = workflowMockEnvironment.getWorkflowService().processWorkItem(workitem);
Assert.assertNotNull(workitem);
Assert.assertEquals(1100, workitem.getTaskID());
Assert.assertEquals("manfred", workitem.getItemValue("namowner", String.class));
} catch (AccessDeniedException | ProcessingErrorException | PluginException | ModelException e) {
e.printStackTrace();
Assert.fail();
}
}
The Imixs-Mock allows you to simulate different users processing a process instance. In this way you can verify the Access Control List (ACL) of a process instance and the assignment of process owners in complex workflow scenarios.
You will find the full example on Github.