use of org.drools.util.io.ClassPathResource in project kogito-runtimes by kiegroup.
the class PredictionAwareHumanTaskLifeCycleTest method testUserTaskWithPredictionService.
@Test
public void testUserTaskWithPredictionService() {
predictNow.set(true);
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_COMPLETED, processInstance.status());
Model result = (Model) processInstance.variables();
assertEquals(2, result.toMap().size());
assertEquals("predicted value", result.toMap().get("s"));
assertEquals(0, trainedTasks.size());
}
use of org.drools.util.io.ClassPathResource in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testUserTaskProcess.
@Test
public void testUserTaskProcess() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
ProcessMetaData metaData = ProcessToExecModelGenerator.INSTANCE.generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
Map<String, String> classData = new HashMap<>();
classData.put("org.drools.bpmn2.UserTaskProcess", content);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
Map<String, BpmnProcess> processes = createProcesses(classData, Collections.singletonMap("Human Task", workItemHandler));
ProcessInstance<BpmnVariables> processInstance = processes.get("UserTask").createInstance();
processInstance.start();
assertEquals(STATE_ACTIVE, processInstance.status());
KogitoWorkItem workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
assertEquals("john", workItem.getParameter("ActorId"));
processInstance.completeWorkItem(workItem.getStringId(), null, SecurityPolicy.of(new StaticIdentityProvider("john")));
assertEquals(STATE_COMPLETED, processInstance.status());
}
use of org.drools.util.io.ClassPathResource in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testExclusiveSplitRetriggerAfterError.
@Test
public void testExclusiveSplitRetriggerAfterError() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-ExclusiveSplit.bpmn2")).get(0);
ProcessMetaData metaData = ProcessToExecModelGenerator.INSTANCE.generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
Map<String, String> classData = new HashMap<>();
classData.put("org.drools.bpmn2.TestProcess", content);
SystemOutWorkItemHandler workItemHandler = new SystemOutWorkItemHandler();
Map<String, BpmnProcess> processes = createProcesses(classData, Collections.singletonMap("Email", workItemHandler));
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "First1");
params.put("y", "Second1");
ProcessInstance<BpmnVariables> processInstance = processes.get("com.sample.test").createInstance(BpmnVariables.create(params));
processInstance.start();
assertEquals(KogitoProcessInstance.STATE_ERROR, processInstance.status());
Optional<ProcessError> errorOptional = processInstance.error();
assertThat(errorOptional).isPresent();
ProcessError error = errorOptional.get();
assertThat(error.failedNodeId()).isEqualTo("_2");
assertThat(error.errorMessage()).contains("XOR split could not find at least one valid outgoing connection for split Split");
params.put("x", "First");
processInstance.updateVariables(BpmnVariables.create(params));
error.retrigger();
assertEquals(STATE_COMPLETED, processInstance.status());
}
use of org.drools.util.io.ClassPathResource in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testExclusiveSplit.
@Test
public void testExclusiveSplit() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-ExclusiveSplit.bpmn2")).get(0);
ProcessMetaData metaData = ProcessToExecModelGenerator.INSTANCE.generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
Map<String, String> classData = new HashMap<>();
classData.put("org.drools.bpmn2.TestProcess", content);
SystemOutWorkItemHandler workItemHandler = new SystemOutWorkItemHandler();
Map<String, BpmnProcess> processes = createProcesses(classData, Collections.singletonMap("Email", workItemHandler));
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "First");
params.put("y", "Second");
ProcessInstance<BpmnVariables> processInstance = processes.get("com.sample.test").createInstance(BpmnVariables.create(params));
processInstance.start();
assertEquals(STATE_COMPLETED, processInstance.status());
}
use of org.drools.util.io.ClassPathResource in project kogito-runtimes by kiegroup.
the class ActivityGenerationModelTest method testParallelGateway.
@Test
public void testParallelGateway() throws Exception {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-ParallelSplit.bpmn2")).get(0);
ProcessMetaData metaData = ProcessToExecModelGenerator.INSTANCE.generate((WorkflowProcess) process.get());
String content = metaData.getGeneratedClassModel().toString();
assertThat(content).isNotNull();
log(content);
Map<String, String> classData = new HashMap<>();
classData.put("org.drools.bpmn2.TestProcess", content);
Map<String, BpmnProcess> processes = createProcesses(classData, Collections.emptyMap());
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance<BpmnVariables> processInstance = processes.get("com.sample.test").createInstance(BpmnVariables.create(params));
processInstance.start();
assertEquals(STATE_COMPLETED, processInstance.status());
}
Aggregations