use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project automatiko-engine by automatiko-io.
the class FileSystemProcessInstancesTest method testBasicFlowWithTransientVariable.
@Test
void testBasicFlowWithTransientVariable() {
BpmnProcess process = createProcess(null, "BPMN2-UserTask.bpmn2");
ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(Collections.singletonMap("temp", "test")));
processInstance.start();
assertThat(processInstance.variables().get("temp")).isEqualTo("test");
assertThat(processInstance.status()).isEqualTo(STATE_ACTIVE);
assertThat(processInstance.description()).isEqualTo("User Task");
FileSystemProcessInstances fileSystemBasedStorage = (FileSystemProcessInstances) process.instances();
assertThat(fileSystemBasedStorage.size()).isOne();
ProcessInstance<BpmnVariables> processInstanceLoaded = (ProcessInstance<BpmnVariables>) fileSystemBasedStorage.findById(processInstance.id()).get();
assertThat(processInstanceLoaded.variables().get("temp")).isNull();
WorkItem workItem = processInstance.workItems(securityPolicy).get(0);
assertThat(workItem).isNotNull();
assertThat(workItem.getParameters().get("ActorId")).isEqualTo("john");
processInstance.completeWorkItem(workItem.getId(), null, securityPolicy);
assertThat(processInstance.status()).isEqualTo(STATE_COMPLETED);
fileSystemBasedStorage = (FileSystemProcessInstances) process.instances();
verify(fileSystemBasedStorage, times(2)).remove(any(), any());
assertThat(fileSystemBasedStorage.size()).isZero();
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project automatiko-engine by automatiko-io.
the class PredictionAwareHumanTaskLifeCycleTest method testUserTaskWithoutPredictionService.
@Test
public void testUserTaskWithoutPredictionService() {
BpmnProcess process = (BpmnProcess) BpmnProcess.from(config, new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
process.configure();
ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(Collections.singletonMap("test", "test")));
processInstance.start();
assertEquals(STATE_ACTIVE, processInstance.status());
WorkItem workItem = processInstance.workItems(securityPolicy).get(0);
assertNotNull(workItem);
assertEquals("john", workItem.getParameters().get("ActorId"));
processInstance.completeWorkItem(workItem.getId(), Collections.singletonMap("output", "given value"), securityPolicy);
assertEquals(STATE_COMPLETED, processInstance.status());
Model result = (Model) processInstance.variables();
assertEquals(2, result.toMap().size());
assertEquals("given value", result.toMap().get("s"));
assertEquals(1, trainedTasks.size());
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project kogito-runtimes by kiegroup.
the class SmileRandomForestPredictionTest method testUserTaskWithPredictionService.
@Test
public void testUserTaskWithPredictionService() {
BpmnProcess process = (BpmnProcess) BpmnProcess.from(config, new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
process.configure();
ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(Collections.singletonMap("test", "test")));
processInstance.start();
assertEquals(STATE_COMPLETED, processInstance.status());
Model result = (Model) processInstance.variables();
assertEquals(2, result.toMap().size());
assertEquals("predicted value", result.toMap().get("s"));
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project kogito-runtimes by kiegroup.
the class PredictionAwareHumanTaskLifeCycleTest method testUserTaskWithoutPredictionService.
@Test
public void testUserTaskWithoutPredictionService() {
BpmnProcess process = BpmnProcess.from(config, new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
process.configure();
ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(Collections.singletonMap("test", "test")));
processInstance.start();
assertEquals(STATE_ACTIVE, processInstance.status());
WorkItem workItem = processInstance.workItems(securityPolicy).get(0);
assertNotNull(workItem);
assertEquals("john", workItem.getParameters().get("ActorId"));
processInstance.completeWorkItem(workItem.getId(), Collections.singletonMap("output", "given value"), securityPolicy);
assertEquals(STATE_COMPLETED, processInstance.status());
Model result = (Model) processInstance.variables();
assertEquals(2, result.toMap().size());
assertEquals("given value", result.toMap().get("s"));
assertEquals(1, trainedTasks.size());
}
use of io.automatiko.engine.workflow.bpmn2.BpmnVariables in project kogito-runtimes by kiegroup.
the class CacheProcessInstancesIT method testBasicFlow.
@Test
void testBasicFlow() {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
process.setProcessInstancesFactory(new CacheProcessInstancesFactory(cacheManager));
process.configure();
ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(Collections.singletonMap("test", "test")));
processInstance.start();
assertEquals(STATE_ACTIVE, processInstance.status());
assertThat(process.instances().size()).isOne();
SecurityPolicy asJohn = SecurityPolicy.of(new StaticIdentityProvider("john"));
assertThat(process.instances().values().iterator().next().workItems(asJohn)).hasSize(1);
List<WorkItem> workItems = processInstance.workItems(asJohn);
assertThat(workItems).hasSize(1);
WorkItem workItem = workItems.get(0);
assertEquals("john", workItem.getParameters().get("ActorId"));
processInstance.completeWorkItem(workItem.getId(), null, asJohn);
assertEquals(STATE_COMPLETED, processInstance.status());
assertThat(process.instances().size()).isZero();
}
Aggregations