Search in sources :

Example 1 with PersonWithAddress

use of io.automatiko.engine.codegen.data.PersonWithAddress in project automatiko-engine by automatiko-io.

the class CallActivityTaskTest method testCallActivityTaskWithExpressionsForIONested.

@Test
public void testCallActivityTaskWithExpressionsForIONested() throws Exception {
    Application app = generateCodeProcessesOnly("subprocess/CallActivityWithIOexpressionNested.bpmn2", "subprocess/CallActivitySubProcess.bpmn2");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("ParentProcess");
    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    PersonWithAddress pa = new PersonWithAddress("john", 0);
    pa.setAddress(new Address("test", null, null, null));
    parameters.put("person", pa);
    m.fromMap(parameters);
    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    Model result = (Model) processInstance.variables();
    assertThat(result.toMap()).hasSize(1).containsKeys("person");
    PersonWithAddress person = (PersonWithAddress) result.toMap().get("person");
    assertEquals("john", person.getName());
    assertEquals("test", person.getAddress().getStreet());
    assertEquals("new value", person.getAddress().getCity());
    List<WorkItem> workItems = processInstance.workItems(securityPolicy);
    assertEquals(1, workItems.size());
    WorkItem wi = workItems.get(0);
    assertEquals("MyTask", wi.getName());
    assertEquals(Active.ID, wi.getPhase());
    assertEquals(Active.STATUS, wi.getPhaseStatus());
    processInstance.transitionWorkItem(workItems.get(0).getId(), new HumanTaskTransition(Complete.ID, null, securityPolicy));
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
Also used : Address(io.automatiko.engine.codegen.data.Address) PersonWithAddress(io.automatiko.engine.codegen.data.PersonWithAddress) HashMap(java.util.HashMap) WorkItem(io.automatiko.engine.api.workflow.WorkItem) HumanTaskTransition(io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition) Model(io.automatiko.engine.api.Model) PersonWithAddress(io.automatiko.engine.codegen.data.PersonWithAddress) Application(io.automatiko.engine.api.Application) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Aggregations

Application (io.automatiko.engine.api.Application)1 Model (io.automatiko.engine.api.Model)1 WorkItem (io.automatiko.engine.api.workflow.WorkItem)1 AbstractCodegenTest (io.automatiko.engine.codegen.AbstractCodegenTest)1 Address (io.automatiko.engine.codegen.data.Address)1 PersonWithAddress (io.automatiko.engine.codegen.data.PersonWithAddress)1 HumanTaskTransition (io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1