Search in sources :

Example 1 with STATE_ABORTED

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

the class VariableTagsTest method testRequiredVariableFiltering.

@Test
public void testRequiredVariableFiltering() {
    List<BpmnProcess> processes = BpmnProcess.from(new ClassPathResource("variable-tags/approval-with-custom-variable-tags.bpmn2"));
    BpmnProcess process = processes.get(0);
    Map<String, Object> params = new HashMap<>();
    params.put("approver", "john");
    org.kie.kogito.process.ProcessInstance<BpmnVariables> instance = process.createInstance(BpmnVariables.create(params));
    instance.start();
    assertEquals(STATE_ACTIVE, instance.status());
    assertThat(instance.variables().toMap()).hasSize(1);
    assertThat(instance.variables().toMap(BpmnVariables.OUTPUTS_ONLY)).hasSize(0);
    assertThat(instance.variables().toMap(BpmnVariables.INPUTS_ONLY)).hasSize(0);
    assertThat(instance.variables().toMap(BpmnVariables.INTERNAL_ONLY)).hasSize(0);
    assertThat(instance.variables().toMap(v -> v.hasTag("onlyAdmin"))).hasSize(1).containsEntry("approver", "john");
    instance.abort();
    assertEquals(STATE_ABORTED, instance.status());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) STATE_ABORTED(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ABORTED) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) STATE_ACTIVE(org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ClassPathResource(org.drools.util.io.ClassPathResource) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) HashMap(java.util.HashMap) DefaultKogitoProcessEventListener(org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener) TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) Test(org.junit.jupiter.api.Test) List(java.util.List) Map(java.util.Map) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Collections(java.util.Collections) VariableViolationException(org.kie.kogito.process.VariableViolationException) ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) BpmnProcess(org.kie.kogito.process.bpmn2.BpmnProcess) HashMap(java.util.HashMap) ClassPathResource(org.drools.util.io.ClassPathResource) BpmnVariables(org.kie.kogito.process.bpmn2.BpmnVariables) Test(org.junit.jupiter.api.Test)

Aggregations

Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 ClassPathResource (org.drools.util.io.ClassPathResource)1 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1 Test (org.junit.jupiter.api.Test)1 ProcessVariableChangedEvent (org.kie.api.event.process.ProcessVariableChangedEvent)1 DefaultKogitoProcessEventListener (org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener)1 KogitoProcessInstance (org.kie.kogito.internal.process.runtime.KogitoProcessInstance)1 STATE_ABORTED (org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ABORTED)1 STATE_ACTIVE (org.kie.kogito.internal.process.runtime.KogitoProcessInstance.STATE_ACTIVE)1 KogitoWorkItem (org.kie.kogito.internal.process.runtime.KogitoWorkItem)1 VariableViolationException (org.kie.kogito.process.VariableViolationException)1 BpmnProcess (org.kie.kogito.process.bpmn2.BpmnProcess)1 BpmnVariables (org.kie.kogito.process.bpmn2.BpmnVariables)1