use of io.automatiko.engine.workflow.marshalling.ProcessInstanceMarshaller in project automatiko-engine by automatiko-io.
the class ExportProcessInstanceTest method testBasicUserTaskProcess.
@Test
public void testBasicUserTaskProcess() throws Exception {
ProcessInstanceMarshaller marshaller = new ProcessInstanceMarshaller();
Application app = generateCodeProcessesOnly("usertask/UserTasksProcess.bpmn2");
assertThat(app).isNotNull();
Process<? extends Model> p = app.processes().processById("UserTasksProcess");
Model m = p.createModel();
Map<String, Object> parameters = new HashMap<>();
m.fromMap(parameters);
ProcessInstance<?> processInstance = p.createInstance(m);
processInstance.start();
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
List<WorkItem> workItems = processInstance.workItems(securityPolicy);
assertEquals(1, workItems.size());
assertEquals("FirstTask", workItems.get(0).getName());
processInstance.completeWorkItem(workItems.get(0).getId(), null, securityPolicy);
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
// exprt process instance
ExportedProcessInstance exported = marshaller.exportProcessInstance(processInstance);
assertThat(exported).isNotNull();
ProcessInstance<?> imported = marshaller.importProcessInstance(exported, p);
workItems = imported.workItems(securityPolicy);
assertEquals(1, workItems.size());
assertEquals("SecondTask", workItems.get(0).getName());
imported.completeWorkItem(workItems.get(0).getId(), null, securityPolicy);
assertThat(imported.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Aggregations