use of org.drools.util.io.ClassPathResource in project kogito-runtimes by kiegroup.
the class KafkaProcessInstancesIT method testBasicFlow.
@Test
void testBasicFlow() {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
listener.setKafkaStreams(createStreams());
process.setProcessInstancesFactory(factory);
process.configure();
listener.getKafkaStreams().start();
ProcessInstances<BpmnVariables> instances = process.instances();
assertThat(instances.size()).isZero();
ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(singletonMap("test", "test")));
processInstance.start();
assertEquals(STATE_ACTIVE, processInstance.status());
await().atMost(TIMEOUT).until(() -> instances.values().size() == 1);
SecurityPolicy asJohn = SecurityPolicy.of(IdentityProviders.of("john"));
assertThat(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());
await().atMost(TIMEOUT).until(() -> instances.size() == 0);
}
use of org.drools.util.io.ClassPathResource in project kogito-runtimes by kiegroup.
the class ActionNodeTest method testSingleActionNode.
@Test
public void testSingleActionNode() throws Exception {
builder.add(new ClassPathResource("ActionNodeTest.xml", ActionNodeTest.class), ResourceType.DRF);
KogitoProcessRuntime kruntime = createKogitoProcessRuntime();
List<String> list = new ArrayList<String>();
kruntime.getKieSession().setGlobal("list", list);
kruntime.startProcess("process name");
assertEquals(1, list.size());
assertEquals("action node was here", list.get(0));
}
use of org.drools.util.io.ClassPathResource in project kogito-runtimes by kiegroup.
the class KafkaProcessInstancesIT method testFindByIdReadMode.
@Test
void testFindByIdReadMode() {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask-Script.bpmn2")).get(0);
listener.setKafkaStreams(createStreams());
process.setProcessInstancesFactory(factory);
process.configure();
listener.getKafkaStreams().start();
ProcessInstances<BpmnVariables> instances = process.instances();
assertThat(instances.size()).isZero();
ProcessInstance<BpmnVariables> mutablePi = process.createInstance(BpmnVariables.create(singletonMap("var", "value")));
mutablePi.start();
assertThat(mutablePi.status()).isEqualTo(STATE_ERROR);
assertThat(mutablePi.error()).hasValueSatisfying(error -> {
assertThat(error.errorMessage()).contains("java.lang.NullPointerException");
assertThat(error.failedNodeId()).isEqualTo("ScriptTask_1");
});
assertThat(mutablePi.variables().toMap()).containsExactly(entry("var", "value"));
await().atMost(TIMEOUT).until(() -> instances.values().size() == 1);
ProcessInstance<BpmnVariables> pi = instances.findById(mutablePi.id(), ProcessInstanceReadMode.READ_ONLY).get();
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> pi.abort());
ProcessInstance<BpmnVariables> readOnlyPi = instances.findById(mutablePi.id(), ProcessInstanceReadMode.READ_ONLY).get();
assertThat(readOnlyPi.status()).isEqualTo(STATE_ERROR);
assertThat(readOnlyPi.error()).hasValueSatisfying(error -> {
assertThat(error.errorMessage()).contains("java.lang.NullPointerException");
assertThat(error.failedNodeId()).isEqualTo("ScriptTask_1");
});
assertThat(readOnlyPi.variables().toMap()).containsExactly(entry("var", "value"));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> readOnlyPi.abort());
instances.findById(mutablePi.id()).get().abort();
await().atMost(TIMEOUT).until(() -> instances.size() == 0);
}
use of org.drools.util.io.ClassPathResource in project kogito-runtimes by kiegroup.
the class KafkaProcessInstancesIT method testValuesReadMode.
@Test
void testValuesReadMode() {
BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
listener.setKafkaStreams(createStreams());
process.setProcessInstancesFactory(factory);
process.configure();
listener.getKafkaStreams().start();
ProcessInstances<BpmnVariables> instances = process.instances();
assertThat(instances.size()).isZero();
ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(singletonMap("test", "test")));
processInstance.start();
await().atMost(TIMEOUT).until(() -> instances.values().size() == 1);
ProcessInstance<BpmnVariables> pi = instances.values().stream().findFirst().get();
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> pi.abort());
instances.values(ProcessInstanceReadMode.MUTABLE).stream().findFirst().get().abort();
await().atMost(TIMEOUT).until(() -> instances.size() == 0);
}
use of org.drools.util.io.ClassPathResource 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"));
}
Aggregations