Search in sources :

Example 36 with CorrelationKey

use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.

the class ProcessServiceEJBIntegrationTest method testStartProcessWithCorrelationKey.

@Test
public void testStartProcessWithCorrelationKey() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    assertNotNull(processService);
    CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "customtask", key);
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(key);
    assertNull(pi);
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Test(org.junit.Test)

Example 37 with CorrelationKey

use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.

the class CorrelationKeyTest method testNotUniqueMultiValuedKey.

@Test
public void testNotUniqueMultiValuedKey() {
    CorrelationKey key = keyFactory.newCorrelationKey(COMPOSED_KEY);
    ProcessInstance processInstance = ksession.startProcess(PROCESS, key, null);
    assertProcessInstanceActive(processInstance.getId());
    try {
        ksession.startProcess(PROCESS, key, null);
        Assertions.fail("Not unique correlation key used. Exception should have been thrown.");
    } catch (RuntimeException ex) {
        ex.printStackTrace();
        Assertions.assertThat(ex.getMessage()).contains("already exists");
    }
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test)

Example 38 with CorrelationKey

use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.

the class CorrelationKeyTest method testNotUniqueSimpleKey.

@Test
public void testNotUniqueSimpleKey() {
    CorrelationKey key = keyFactory.newCorrelationKey(SIMPLE_KEY);
    ProcessInstance processInstance = ksession.startProcess(PROCESS, key, null);
    assertProcessInstanceActive(processInstance.getId());
    try {
        ksession.startProcess(PROCESS, key, null);
        Assertions.fail("Not unique correlation key used. Exception should have been thrown.");
    } catch (RuntimeException ex) {
        ex.printStackTrace();
        Assertions.assertThat(ex.getMessage()).contains("already exists");
    }
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test)

Aggregations

CorrelationKey (org.kie.internal.process.CorrelationKey)38 Test (org.junit.Test)27 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)21 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)12 QueryContext (org.kie.api.runtime.query.QueryContext)12 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)9 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)8 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)7 CorrelationKeyFactory (org.kie.internal.process.CorrelationKeyFactory)7 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)6 KieSession (org.kie.api.runtime.KieSession)6 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)5 Collection (java.util.Collection)4 List (java.util.List)4 Map (java.util.Map)4 Collectors.toList (java.util.stream.Collectors.toList)4 RegistryContext (org.drools.core.command.impl.RegistryContext)4 CaseEventSupport (org.jbpm.casemgmt.impl.event.CaseEventSupport)4 RuntimeDataService (org.jbpm.services.api.RuntimeDataService)4