Search in sources :

Example 1 with HumanTaskTransition

use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition in project automatiko-engine by automatiko-io.

the class UserTaskTest method testBasicUserTaskProcessPhases.

@Test
public void testBasicUserTaskProcessPhases() throws Exception {
    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());
    WorkItem wi = workItems.get(0);
    assertEquals("FirstTask", 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_ACTIVE);
    workItems = processInstance.workItems(securityPolicy);
    assertEquals(1, workItems.size());
    wi = workItems.get(0);
    assertEquals("SecondTask", 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 : HumanTaskTransition(io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition) HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) Application(io.automatiko.engine.api.Application) WorkItem(io.automatiko.engine.api.workflow.WorkItem) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 2 with HumanTaskTransition

use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition in project automatiko-engine by automatiko-io.

the class UserTaskTest method testBasicUserTaskProcessReleaseAndCompletePhases.

@Test
public void testBasicUserTaskProcessReleaseAndCompletePhases() throws Exception {
    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());
    WorkItem wi = workItems.get(0);
    assertEquals("FirstTask", wi.getName());
    assertEquals(Active.ID, wi.getPhase());
    assertEquals(Active.STATUS, wi.getPhaseStatus());
    assertEquals(0, wi.getResults().size());
    final String wiId = wi.getId();
    assertThrows(InvalidTransitionException.class, () -> processInstance.transitionWorkItem(wiId, new HumanTaskTransition(Release.ID, null, securityPolicy)));
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    workItems = processInstance.workItems(securityPolicy);
    assertEquals(1, workItems.size());
    wi = workItems.get(0);
    assertEquals("FirstTask", wi.getName());
    assertEquals(Active.ID, wi.getPhase());
    assertEquals(Active.STATUS, wi.getPhaseStatus());
    assertEquals(0, wi.getResults().size());
    processInstance.transitionWorkItem(workItems.get(0).getId(), new HumanTaskTransition(Complete.ID, null, securityPolicy));
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    workItems = processInstance.workItems(securityPolicy);
    assertEquals(1, workItems.size());
    wi = workItems.get(0);
    assertEquals("SecondTask", wi.getName());
    assertEquals(Active.ID, wi.getPhase());
    assertEquals(Active.STATUS, wi.getPhaseStatus());
    assertEquals(0, wi.getResults().size());
    processInstance.abort();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
Also used : HumanTaskTransition(io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition) HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) Application(io.automatiko.engine.api.Application) WorkItem(io.automatiko.engine.api.workflow.WorkItem) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 3 with HumanTaskTransition

use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition in project automatiko-engine by automatiko-io.

the class UserTaskTest method testBasicUserTaskProcessClaimAndCompletePhases.

@Test
public void testBasicUserTaskProcessClaimAndCompletePhases() throws Exception {
    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());
    WorkItem wi = workItems.get(0);
    assertEquals("FirstTask", wi.getName());
    assertEquals(Active.ID, wi.getPhase());
    assertEquals(Active.STATUS, wi.getPhaseStatus());
    assertEquals(0, wi.getResults().size());
    processInstance.transitionWorkItem(workItems.get(0).getId(), new HumanTaskTransition(Claim.ID, Collections.singletonMap("test", "value"), securityPolicy));
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    workItems = processInstance.workItems(securityPolicy);
    assertEquals(1, workItems.size());
    wi = workItems.get(0);
    assertEquals("FirstTask", wi.getName());
    assertEquals(Claim.ID, wi.getPhase());
    assertEquals(Claim.STATUS, wi.getPhaseStatus());
    assertEquals(2, wi.getResults().size());
    assertEquals("value", wi.getResults().get("test"));
    assertEquals("john", wi.getResults().get("ActorId"));
    processInstance.transitionWorkItem(workItems.get(0).getId(), new HumanTaskTransition(Complete.ID, null, securityPolicy));
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    workItems = processInstance.workItems(securityPolicy);
    assertEquals(1, workItems.size());
    wi = workItems.get(0);
    assertEquals("SecondTask", wi.getName());
    assertEquals(Active.ID, wi.getPhase());
    assertEquals(Active.STATUS, wi.getPhaseStatus());
    assertEquals(0, wi.getResults().size());
    processInstance.abort();
    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ABORTED);
}
Also used : HumanTaskTransition(io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition) HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) Application(io.automatiko.engine.api.Application) WorkItem(io.automatiko.engine.api.workflow.WorkItem) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Example 4 with HumanTaskTransition

use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition 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)

Example 5 with HumanTaskTransition

use of io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition in project automatiko-engine by automatiko-io.

the class CallActivityTaskTest method testCallActivityTaskWithExpressionsForIO.

@Test
public void testCallActivityTaskWithExpressionsForIO() throws Exception {
    Application app = generateCodeProcessesOnly("subprocess/CallActivityWithIOexpression.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<>();
    parameters.put("person", new Person("john", 0));
    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");
    Person person = (Person) result.toMap().get("person");
    assertEquals("new value", person.getName());
    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 : HumanTaskTransition(io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition) HashMap(java.util.HashMap) Model(io.automatiko.engine.api.Model) Application(io.automatiko.engine.api.Application) Person(io.automatiko.engine.codegen.data.Person) WorkItem(io.automatiko.engine.api.workflow.WorkItem) AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Test(org.junit.jupiter.api.Test)

Aggregations

Application (io.automatiko.engine.api.Application)13 Model (io.automatiko.engine.api.Model)13 WorkItem (io.automatiko.engine.api.workflow.WorkItem)13 AbstractCodegenTest (io.automatiko.engine.codegen.AbstractCodegenTest)13 HumanTaskTransition (io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskTransition)13 HashMap (java.util.HashMap)13 Test (org.junit.jupiter.api.Test)13 Process (io.automatiko.engine.api.workflow.Process)2 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)2 StaticIdentityProvider (io.automatiko.engine.services.identity.StaticIdentityProvider)2 IdentityProvider (io.automatiko.engine.api.auth.IdentityProvider)1 SecurityPolicy (io.automatiko.engine.api.auth.SecurityPolicy)1 DefaultProcessEventListener (io.automatiko.engine.api.event.process.DefaultProcessEventListener)1 ProcessWorkItemTransitionEvent (io.automatiko.engine.api.event.process.ProcessWorkItemTransitionEvent)1 Address (io.automatiko.engine.codegen.data.Address)1 Person (io.automatiko.engine.codegen.data.Person)1 PersonWithAddress (io.automatiko.engine.codegen.data.PersonWithAddress)1 ArrayList (java.util.ArrayList)1