Search in sources :

Example 1 with STATE_ERROR

use of org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR in project kogito-runtimes by kiegroup.

the class CacheProcessInstancesIT method testFindByIdReadMode.

@Test
void testFindByIdReadMode() {
    BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask-Script.bpmn2")).get(0);
    // workaround as BpmnProcess does not compile the scripts but just reads the xml
    for (Node node : ((WorkflowProcess) process.get()).getNodes()) {
        if (node instanceof ActionNode) {
            DroolsAction a = ((ActionNode) node).getAction();
            a.setMetaData("Action", (Action) kcontext -> {
                System.out.println("The variable value is " + kcontext.getVariable("s") + " about to call toString on it");
                kcontext.getVariable("s").toString();
            });
        }
    }
    process.setProcessInstancesFactory(new CacheProcessInstancesFactory(cacheManager));
    process.configure();
    ProcessInstance<BpmnVariables> mutablePi = process.createInstance(BpmnVariables.create(Collections.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"));
    ProcessInstances<BpmnVariables> instances = process.instances();
    assertThat(instances.size()).isOne();
    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();
    assertThat(instances.size()).isZero();
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) BeforeEach(org.junit.jupiter.api.BeforeEach) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) STATE_ACTIVE(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ProcessInstances(org.kie.kogito.process.ProcessInstances) RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) STATE_COMPLETED(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_COMPLETED) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) DroolsAction(org.jbpm.workflow.core.DroolsAction) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Container(org.testcontainers.junit.jupiter.Container) ActionNode(org.jbpm.workflow.core.node.ActionNode) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) StaticIdentityProvider(org.kie.kogito.services.identity.StaticIdentityProvider) Testcontainers(org.testcontainers.junit.jupiter.Testcontainers) ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) SecurityPolicy(org.kie.kogito.auth.SecurityPolicy) Assertions.entry(org.assertj.core.api.Assertions.entry) KogitoProcessInstancesFactory(org.kie.kogito.persistence.KogitoProcessInstancesFactory) Test(org.junit.jupiter.api.Test) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) KogitoInfinispanContainer(org.kie.kogito.testcontainers.KogitoInfinispanContainer) ProcessInstance(org.kie.kogito.process.ProcessInstance) ClassPathResource(org.drools.core.io.impl.ClassPathResource) Node(org.kie.api.definition.process.Node) ProcessInstanceReadMode(org.kie.kogito.process.ProcessInstanceReadMode) STATE_ERROR(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR) Action(org.jbpm.process.instance.impl.Action) Collections(java.util.Collections) WorkItem(org.kie.kogito.process.WorkItem) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) ActionNode(org.jbpm.workflow.core.node.ActionNode) Node(org.kie.api.definition.process.Node) ActionNode(org.jbpm.workflow.core.node.ActionNode) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) ClassPathResource(org.drools.core.io.impl.ClassPathResource) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) Test(org.junit.jupiter.api.Test)

Example 2 with STATE_ERROR

use of org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR in project kogito-runtimes by kiegroup.

the class MockCacheProcessInstancesTest method testBasicFlowWithError.

private void testBasicFlowWithError(Consumer<ProcessInstance<BpmnVariables>> op) {
    BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask-Script.bpmn2")).get(0);
    // workaround as BpmnProcess does not compile the scripts but just reads the xml
    for (Node node : ((WorkflowProcess) process.get()).getNodes()) {
        if (node instanceof ActionNode) {
            DroolsAction a = ((ActionNode) node).getAction();
            a.setMetaData("Action", (Action) kcontext -> {
                System.out.println("The variable value is " + kcontext.getVariable("s") + " about to call toString on it");
                kcontext.getVariable("s").toString();
            });
        }
    }
    process.setProcessInstancesFactory(new CacheProcessInstancesFactory(cacheManager));
    process.configure();
    ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create());
    processInstance.start();
    assertThat(processInstance.status()).isEqualTo(STATE_ERROR);
    Optional<ProcessError> errorOp = processInstance.error();
    assertThat(errorOp).isPresent();
    assertThat(errorOp.get().failedNodeId()).isEqualTo("ScriptTask_1");
    assertThat(errorOp.get().errorMessage()).isNotNull().contains("java.lang.NullPointerException");
    op.accept(processInstance);
    assertThat(processInstance.error()).isNotPresent();
    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 : DroolsAction(org.jbpm.workflow.core.DroolsAction) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) MetadataValueImpl(org.infinispan.client.hotrod.impl.MetadataValueImpl) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) STATE_ACTIVE(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RemoteCache(org.infinispan.client.hotrod.RemoteCache) ProcessInstances(org.kie.kogito.process.ProcessInstances) RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) STATE_COMPLETED(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_COMPLETED) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) DroolsAction(org.jbpm.workflow.core.DroolsAction) RemoteCacheManagerAdmin(org.infinispan.client.hotrod.RemoteCacheManagerAdmin) ActionNode(org.jbpm.workflow.core.node.ActionNode) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) StaticIdentityProvider(org.kie.kogito.services.identity.StaticIdentityProvider) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SecurityPolicy(org.kie.kogito.auth.SecurityPolicy) Mockito.when(org.mockito.Mockito.when) Assertions.entry(org.assertj.core.api.Assertions.entry) KogitoProcessInstancesFactory(org.kie.kogito.persistence.KogitoProcessInstancesFactory) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) List(java.util.List) ProcessInstance(org.kie.kogito.process.ProcessInstance) ClassPathResource(org.drools.core.io.impl.ClassPathResource) Node(org.kie.api.definition.process.Node) ProcessError(org.kie.kogito.process.ProcessError) ProcessInstanceReadMode(org.kie.kogito.process.ProcessInstanceReadMode) STATE_ERROR(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR) Optional(java.util.Optional) Action(org.jbpm.process.instance.impl.Action) Collections(java.util.Collections) WorkItem(org.kie.kogito.process.WorkItem) ProcessInstanceNotFoundException(org.kie.kogito.process.ProcessInstanceNotFoundException) Mockito.mock(org.mockito.Mockito.mock) StaticIdentityProvider(org.kie.kogito.services.identity.StaticIdentityProvider) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) ActionNode(org.jbpm.workflow.core.node.ActionNode) Node(org.kie.api.definition.process.Node) ActionNode(org.jbpm.workflow.core.node.ActionNode) WorkItem(org.kie.kogito.process.WorkItem) ClassPathResource(org.drools.core.io.impl.ClassPathResource) ProcessError(org.kie.kogito.process.ProcessError) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables)

Example 3 with STATE_ERROR

use of org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR in project kogito-runtimes by kiegroup.

the class MockCacheProcessInstancesTest method testFindByIdReadMode.

@Test
void testFindByIdReadMode() {
    BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask-Script.bpmn2")).get(0);
    // workaround as BpmnProcess does not compile the scripts but just reads the xml
    for (Node node : ((WorkflowProcess) process.get()).getNodes()) {
        if (node instanceof ActionNode) {
            DroolsAction a = ((ActionNode) node).getAction();
            a.setMetaData("Action", (Action) kcontext -> {
                System.out.println("The variable value is " + kcontext.getVariable("s") + " about to call toString on it");
                kcontext.getVariable("s").toString();
            });
        }
    }
    process.setProcessInstancesFactory(new CacheProcessInstancesFactory(cacheManager));
    process.configure();
    ProcessInstance<BpmnVariables> mutablePi = process.createInstance(BpmnVariables.create(Collections.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"));
    ProcessInstances<BpmnVariables> instances = process.instances();
    assertThat(instances.size()).isOne();
    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();
    assertThat(instances.size()).isZero();
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) MetadataValueImpl(org.infinispan.client.hotrod.impl.MetadataValueImpl) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) STATE_ACTIVE(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RemoteCache(org.infinispan.client.hotrod.RemoteCache) ProcessInstances(org.kie.kogito.process.ProcessInstances) RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) STATE_COMPLETED(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_COMPLETED) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) DroolsAction(org.jbpm.workflow.core.DroolsAction) RemoteCacheManagerAdmin(org.infinispan.client.hotrod.RemoteCacheManagerAdmin) ActionNode(org.jbpm.workflow.core.node.ActionNode) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) StaticIdentityProvider(org.kie.kogito.services.identity.StaticIdentityProvider) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SecurityPolicy(org.kie.kogito.auth.SecurityPolicy) Mockito.when(org.mockito.Mockito.when) Assertions.entry(org.assertj.core.api.Assertions.entry) KogitoProcessInstancesFactory(org.kie.kogito.persistence.KogitoProcessInstancesFactory) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) List(java.util.List) ProcessInstance(org.kie.kogito.process.ProcessInstance) ClassPathResource(org.drools.core.io.impl.ClassPathResource) Node(org.kie.api.definition.process.Node) ProcessError(org.kie.kogito.process.ProcessError) ProcessInstanceReadMode(org.kie.kogito.process.ProcessInstanceReadMode) STATE_ERROR(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR) Optional(java.util.Optional) Action(org.jbpm.process.instance.impl.Action) Collections(java.util.Collections) WorkItem(org.kie.kogito.process.WorkItem) ProcessInstanceNotFoundException(org.kie.kogito.process.ProcessInstanceNotFoundException) Mockito.mock(org.mockito.Mockito.mock) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) ActionNode(org.jbpm.workflow.core.node.ActionNode) Node(org.kie.api.definition.process.Node) ActionNode(org.jbpm.workflow.core.node.ActionNode) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) ClassPathResource(org.drools.core.io.impl.ClassPathResource) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) Test(org.junit.jupiter.api.Test)

Example 4 with STATE_ERROR

use of org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR in project kogito-runtimes by kiegroup.

the class FileSystemProcessInstancesTest method testFindByIdReadMode.

@Test
void testFindByIdReadMode() {
    BpmnProcess process = createProcess("BPMN2-UserTask-Script.bpmn2");
    // workaround as BpmnProcess does not compile the scripts but just reads the xml
    for (Node node : ((WorkflowProcess) process.get()).getNodes()) {
        if (node instanceof ActionNode) {
            DroolsAction a = ((ActionNode) node).getAction();
            a.setMetaData("Action", (Action) kcontext -> {
                System.out.println("The variable value is " + kcontext.getVariable("s") + " about to call toString on it");
                kcontext.getVariable("s").toString();
            });
        }
    }
    ProcessInstance<BpmnVariables> mutablePi = process.createInstance(BpmnVariables.create(Collections.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"));
    ProcessInstances<BpmnVariables> instances = process.instances();
    assertThat(instances.size()).isOne();
    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();
    assertThat(instances.size()).isZero();
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) UnitOfWork(org.kie.kogito.uow.UnitOfWork) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) STATE_ACTIVE(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mockito.spy(org.mockito.Mockito.spy) ProcessInstances(org.kie.kogito.process.ProcessInstances) STATE_COMPLETED(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_COMPLETED) UnitOfWorkManager(org.kie.kogito.uow.UnitOfWorkManager) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) DroolsAction(org.jbpm.workflow.core.DroolsAction) Process(org.kie.kogito.process.Process) ActionNode(org.jbpm.workflow.core.node.ActionNode) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) StaticIdentityProvider(org.kie.kogito.services.identity.StaticIdentityProvider) SecurityPolicy(org.kie.kogito.auth.SecurityPolicy) Mockito.times(org.mockito.Mockito.times) Assertions.entry(org.assertj.core.api.Assertions.entry) KogitoProcessInstancesFactory(org.kie.kogito.persistence.KogitoProcessInstancesFactory) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) FileSystemProcessInstances(org.kie.kogito.persistence.filesystem.FileSystemProcessInstances) ProcessInstance(org.kie.kogito.process.ProcessInstance) ClassPathResource(org.drools.core.io.impl.ClassPathResource) Node(org.kie.api.definition.process.Node) ProcessInstanceReadMode(org.kie.kogito.process.ProcessInstanceReadMode) STATE_ERROR(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR) Action(org.jbpm.process.instance.impl.Action) Collections(java.util.Collections) WorkItem(org.kie.kogito.process.WorkItem) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) ActionNode(org.jbpm.workflow.core.node.ActionNode) Node(org.kie.api.definition.process.Node) ActionNode(org.jbpm.workflow.core.node.ActionNode) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) Test(org.junit.jupiter.api.Test)

Example 5 with STATE_ERROR

use of org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR in project kogito-runtimes by kiegroup.

the class MongoDBProcessInstancesIT method testFindByIdReadMode.

void testFindByIdReadMode(MongoDBTransactionManager transactionManager) {
    BpmnProcess process = BpmnProcess.from(new ClassPathResource("BPMN2-UserTask-Script.bpmn2")).get(0);
    // workaround as BpmnProcess does not compile the scripts but just reads the xml
    for (Node node : ((WorkflowProcess) process.get()).getNodes()) {
        if (node instanceof ActionNode) {
            DroolsAction a = ((ActionNode) node).getAction();
            a.setMetaData("Action", (Action) kcontext -> {
                System.out.println("The variable value is " + kcontext.getVariable("s") + " about to call toString on it");
                kcontext.getVariable("s").toString();
            });
        }
    }
    process.setProcessInstancesFactory(new MongoDBProcessInstancesFactory(mongoClient, transactionManager));
    process.configure();
    ProcessInstance<BpmnVariables> mutablePi = process.createInstance(BpmnVariables.create(Collections.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"));
    ProcessInstances<BpmnVariables> instances = process.instances();
    assertThat(instances.size()).isOne();
    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();
    assertThat(instances.size()).isZero();
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) Document(org.bson.Document) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) MongoClient(com.mongodb.client.MongoClient) MongoCollection(com.mongodb.client.MongoCollection) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) STATE_ACTIVE(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE) MongoDBTransactionManager(org.kie.kogito.mongodb.transaction.MongoDBTransactionManager) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) ProcessInstances(org.kie.kogito.process.ProcessInstances) ArrayList(java.util.ArrayList) AfterAll(org.junit.jupiter.api.AfterAll) STATE_COMPLETED(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_COMPLETED) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) StreamSupport(java.util.stream.StreamSupport) DroolsAction(org.jbpm.workflow.core.DroolsAction) UnitOfWorkStartEvent(org.kie.kogito.uow.events.UnitOfWorkStartEvent) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Container(org.testcontainers.junit.jupiter.Container) ActionNode(org.jbpm.workflow.core.node.ActionNode) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) StaticIdentityProvider(org.kie.kogito.services.identity.StaticIdentityProvider) Collection(java.util.Collection) Testcontainers(org.testcontainers.junit.jupiter.Testcontainers) MongoClients(com.mongodb.client.MongoClients) SecurityPolicy(org.kie.kogito.auth.SecurityPolicy) Assertions.entry(org.assertj.core.api.Assertions.entry) KogitoProcessInstancesFactory(org.kie.kogito.persistence.KogitoProcessInstancesFactory) DOCUMENT_ID(org.kie.kogito.mongodb.utils.DocumentConstants.DOCUMENT_ID) Test(org.junit.jupiter.api.Test) DocumentConstants(org.kie.kogito.mongodb.utils.DocumentConstants) List(java.util.List) ProcessInstance(org.kie.kogito.process.ProcessInstance) ClassPathResource(org.drools.core.io.impl.ClassPathResource) Node(org.kie.api.definition.process.Node) ProcessInstanceReadMode(org.kie.kogito.process.ProcessInstanceReadMode) STATE_ERROR(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR) Action(org.jbpm.process.instance.impl.Action) KogitoMongoDBContainer(org.kie.kogito.testcontainers.KogitoMongoDBContainer) Collections(java.util.Collections) WorkItem(org.kie.kogito.process.WorkItem) UnitOfWorkEndEvent(org.kie.kogito.uow.events.UnitOfWorkEndEvent) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) ActionNode(org.jbpm.workflow.core.node.ActionNode) Node(org.kie.api.definition.process.Node) ActionNode(org.jbpm.workflow.core.node.ActionNode) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess) ClassPathResource(org.drools.core.io.impl.ClassPathResource) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables)

Aggregations

Collections (java.util.Collections)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)5 Assertions.entry (org.assertj.core.api.Assertions.entry)5 ClassPathResource (org.drools.core.io.impl.ClassPathResource)5 Action (org.jbpm.process.instance.impl.Action)5 DroolsAction (org.jbpm.workflow.core.DroolsAction)5 WorkflowProcess (org.jbpm.workflow.core.WorkflowProcess)5 ActionNode (org.jbpm.workflow.core.node.ActionNode)5 Test (org.junit.jupiter.api.Test)5 Node (org.kie.api.definition.process.Node)5 SecurityPolicy (org.kie.kogito.auth.SecurityPolicy)5 STATE_ACTIVE (org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE)5 STATE_COMPLETED (org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_COMPLETED)5 STATE_ERROR (org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ERROR)5 KogitoProcessInstancesFactory (org.kie.kogito.persistence.KogitoProcessInstancesFactory)5 ProcessInstance (org.kie.kogito.process.ProcessInstance)5 ProcessInstanceReadMode (org.kie.kogito.process.ProcessInstanceReadMode)5 ProcessInstances (org.kie.kogito.process.ProcessInstances)5 WorkItem (org.kie.kogito.process.WorkItem)5