Search in sources :

Example 1 with PersonWithAddress

use of org.kie.kogito.codegen.data.PersonWithAddress in project kogito-runtimes by kiegroup.

the class CallActivityTaskIT 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.get(Processes.class).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 : PersonWithAddress(org.kie.kogito.codegen.data.PersonWithAddress) Address(org.kie.kogito.codegen.data.Address) HashMap(java.util.HashMap) Processes(org.kie.kogito.process.Processes) WorkItem(org.kie.kogito.process.WorkItem) HumanTaskTransition(org.jbpm.process.instance.impl.humantask.HumanTaskTransition) Model(org.kie.kogito.Model) PersonWithAddress(org.kie.kogito.codegen.data.PersonWithAddress) Application(org.kie.kogito.Application) Test(org.junit.jupiter.api.Test)

Aggregations

HashMap (java.util.HashMap)1 HumanTaskTransition (org.jbpm.process.instance.impl.humantask.HumanTaskTransition)1 Test (org.junit.jupiter.api.Test)1 Application (org.kie.kogito.Application)1 Model (org.kie.kogito.Model)1 Address (org.kie.kogito.codegen.data.Address)1 PersonWithAddress (org.kie.kogito.codegen.data.PersonWithAddress)1 Processes (org.kie.kogito.process.Processes)1 WorkItem (org.kie.kogito.process.WorkItem)1