Search in sources :

Example 1 with COMPLETED

use of io.automatiko.engine.api.workflow.flexible.ItemDescription.Status.COMPLETED in project automatiko-engine by automatiko-io.

the class MilestoneTest method testSimpleMilestone.

@Test
void testSimpleMilestone() throws Exception {
    Application app = generateCodeProcessesOnly("cases/milestones/SimpleMilestone.bpmn");
    assertThat(app).isNotNull();
    Process<? extends Model> p = app.processes().processById("TestCase.SimpleMilestone_1_0");
    ProcessInstance<?> processInstance = p.createInstance(p.createModel());
    assertState(processInstance, ProcessInstance.STATE_PENDING);
    Collection<Milestone> expected = new ArrayList<>();
    expected.add(Milestone.builder().withName("AutoStartMilestone").withStatus(AVAILABLE).build());
    expected.add(Milestone.builder().withName("SimpleMilestone").withStatus(AVAILABLE).build());
    assertMilestones(expected, processInstance.milestones());
    processInstance.start();
    assertState(processInstance, ProcessInstance.STATE_COMPLETED);
    expected = expected.stream().map(m -> Milestone.builder().withId(m.getId()).withName(m.getName()).withStatus(COMPLETED).build()).collect(Collectors.toList());
    assertMilestones(expected, processInstance.milestones());
    ExecutableProcessInstance legacyProcessInstance = (ExecutableProcessInstance) ((AbstractProcessInstance<?>) processInstance).processInstance();
    assertThat(legacyProcessInstance.getNodeInstances()).isEmpty();
    Optional<String> milestoneId = Stream.of(legacyProcessInstance.getNodeContainer().getNodes()).filter(node -> node.getName().equals("SimpleMilestone")).map(n -> (String) n.getMetaData().get(Metadata.UNIQUE_ID)).findFirst();
    assertTrue(milestoneId.isPresent());
    assertThat(legacyProcessInstance.getCompletedNodeIds()).contains(milestoneId.get());
}
Also used : AbstractCodegenTest(io.automatiko.engine.codegen.AbstractCodegenTest) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) AbstractProcessInstance(io.automatiko.engine.workflow.AbstractProcessInstance) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Metadata(io.automatiko.engine.workflow.process.executable.core.Metadata) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) HashMap(java.util.HashMap) COMPLETED(io.automatiko.engine.api.workflow.flexible.ItemDescription.Status.COMPLETED) ArrayList(java.util.ArrayList) Application(io.automatiko.engine.api.Application) Map(java.util.Map) Process(io.automatiko.engine.api.workflow.Process) Model(io.automatiko.engine.api.Model) Collection(java.util.Collection) ExecutableProcessInstance(io.automatiko.engine.workflow.process.executable.instance.ExecutableProcessInstance) ProcessTestUtils.assertState(io.automatiko.engine.codegen.tests.ProcessTestUtils.assertState) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) AVAILABLE(io.automatiko.engine.api.workflow.flexible.ItemDescription.Status.AVAILABLE) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) List(java.util.List) Stream(java.util.stream.Stream) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) Milestone(io.automatiko.engine.api.workflow.flexible.Milestone) WorkItem(io.automatiko.engine.api.workflow.WorkItem) Milestone(io.automatiko.engine.api.workflow.flexible.Milestone) ArrayList(java.util.ArrayList) ExecutableProcessInstance(io.automatiko.engine.workflow.process.executable.instance.ExecutableProcessInstance) 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 Process (io.automatiko.engine.api.workflow.Process)1 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)1 WorkItem (io.automatiko.engine.api.workflow.WorkItem)1 AVAILABLE (io.automatiko.engine.api.workflow.flexible.ItemDescription.Status.AVAILABLE)1 COMPLETED (io.automatiko.engine.api.workflow.flexible.ItemDescription.Status.COMPLETED)1 Milestone (io.automatiko.engine.api.workflow.flexible.Milestone)1 AbstractCodegenTest (io.automatiko.engine.codegen.AbstractCodegenTest)1 ProcessTestUtils.assertState (io.automatiko.engine.codegen.tests.ProcessTestUtils.assertState)1 AbstractProcessInstance (io.automatiko.engine.workflow.AbstractProcessInstance)1 Metadata (io.automatiko.engine.workflow.process.executable.core.Metadata)1 ExecutableProcessInstance (io.automatiko.engine.workflow.process.executable.instance.ExecutableProcessInstance)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1