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());
}
Aggregations