Search in sources :

Example 26 with ClassPathResource

use of org.drools.core.io.impl.ClassPathResource in project kogito-runtimes by kiegroup.

the class MockCacheProcessInstancesTest method testBasicFlow.

@Test
public 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();
    assertThat(processInstance.status()).isEqualTo(STATE_ACTIVE);
    WorkItem workItem = processInstance.workItems(SecurityPolicy.of(new StaticIdentityProvider("john"))).get(0);
    assertThat(workItem).isNotNull();
    assertThat(workItem.getParameters().get("ActorId")).isEqualTo("john");
    processInstance.completeWorkItem(workItem.getId(), null, SecurityPolicy.of(new StaticIdentityProvider("john")));
    assertThat(processInstance.status()).isEqualTo(STATE_COMPLETED);
}
Also used : StaticIdentityProvider(org.kie.kogito.services.identity.StaticIdentityProvider) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) WorkItem(org.kie.kogito.process.WorkItem) ClassPathResource(org.drools.core.io.impl.ClassPathResource) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) Test(org.junit.jupiter.api.Test)

Example 27 with ClassPathResource

use of org.drools.core.io.impl.ClassPathResource in project kogito-runtimes by kiegroup.

the class MockCacheProcessInstancesTest method testProcessInstanceNotFound.

@Test
public void testProcessInstanceNotFound() {
    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();
    assertThat(processInstance.status()).isEqualTo(STATE_ACTIVE);
    mockCache.clear();
    assertThatThrownBy(() -> processInstance.workItems().get(0)).isInstanceOf(ProcessInstanceNotFoundException.class);
    Optional<? extends ProcessInstance<BpmnVariables>> loaded = process.instances().findById(processInstance.id());
    assertThat(loaded).isNotPresent();
}
Also used : BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) ClassPathResource(org.drools.core.io.impl.ClassPathResource) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) Test(org.junit.jupiter.api.Test)

Example 28 with ClassPathResource

use of org.drools.core.io.impl.ClassPathResource in project kogito-runtimes by kiegroup.

the class AbstractProcessInstancesIT method createProcess.

public static BpmnProcess createProcess(TestProcessInstancesFactory factory, String fileName) {
    BpmnProcess process = BpmnProcess.from(new ClassPathResource(fileName)).get(0);
    process.setProcessInstancesFactory(factory);
    process.configure();
    process.instances().values(ProcessInstanceReadMode.MUTABLE).forEach(p -> p.abort());
    return process;
}
Also used : BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) ClassPathResource(org.drools.core.io.impl.ClassPathResource)

Example 29 with ClassPathResource

use of org.drools.core.io.impl.ClassPathResource in project kogito-runtimes by kiegroup.

the class PersistentProcessInstancesWithLockIT method createProcess.

private BpmnProcess createProcess(MongoDBProcessInstancesFactory factory) {
    BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0);
    process.setProcessInstancesFactory(factory);
    process.configure();
    return process;
}
Also used : BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) ClassPathResource(org.drools.core.io.impl.ClassPathResource)

Example 30 with ClassPathResource

use of org.drools.core.io.impl.ClassPathResource in project kogito-runtimes by kiegroup.

the class PostgreProcessInstancesWithLockIT method createProcess.

private BpmnProcess createProcess(String fileName) {
    BpmnProcess process = BpmnProcess.from(new ClassPathResource(fileName)).get(0);
    process.setProcessInstancesFactory(new PostgreProcessInstancesFactory(client));
    process.configure();
    return process;
}
Also used : BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) ClassPathResource(org.drools.core.io.impl.ClassPathResource)

Aggregations

ClassPathResource (org.drools.core.io.impl.ClassPathResource)88 BpmnProcess (org.kie.kogito.process.bpmn2.BpmnProcess)45 Test (org.junit.jupiter.api.Test)38 BpmnVariables (org.kie.kogito.process.bpmn2.BpmnVariables)33 Test (org.junit.Test)24 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)21 HashMap (java.util.HashMap)16 ProcessMetaData (org.jbpm.compiler.canonical.ProcessMetaData)16 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)14 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)12 VerifierBuilder (org.drools.verifier.builder.VerifierBuilder)11 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)11 VerifierReport (org.drools.verifier.data.VerifierReport)10 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)10 WorkItem (org.kie.kogito.process.WorkItem)10 StaticIdentityProvider (org.kie.kogito.services.identity.StaticIdentityProvider)9 ArrayList (java.util.ArrayList)6 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)6 KieSession (org.kie.api.runtime.KieSession)6 SecurityPolicy (org.kie.kogito.auth.SecurityPolicy)6