Search in sources :

Example 16 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class ProcessServiceImplWithDeploymentIdTest 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(deploymentUnit.getIdentifier(), 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) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 17 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class ProcessServiceImplWithDeploymentIdTest method testStartProcessAndChangeVariables.

@Test
public void testStartProcessAndChangeVariables() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    assertNotNull(processService);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("approval_document", "test");
    params.put("approval_reviewComment", "need review");
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(pi);
    // get variable by name
    Object variableValue = processService.getProcessInstanceVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_document");
    assertNotNull(variableValue);
    assertTrue(variableValue instanceof String);
    assertEquals("test", variableValue);
    // get all variables
    Map<String, Object> variables = processService.getProcessInstanceVariables(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(variables);
    assertEquals(2, variables.size());
    assertTrue(variables.containsKey("approval_document"));
    assertTrue(variables.containsKey("approval_reviewComment"));
    assertEquals("test", variables.get("approval_document"));
    assertEquals("need review", variables.get("approval_reviewComment"));
    // now change single variable
    processService.setProcessVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_reviewComment", "updated review comment");
    // let's verify it
    variableValue = processService.getProcessInstanceVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_reviewComment");
    assertNotNull(variableValue);
    assertTrue(variableValue instanceof String);
    assertEquals("updated review comment", variableValue);
    // and lastly let's update both variables
    params = new HashMap<String, Object>();
    params.put("approval_document", "updated document");
    params.put("approval_reviewComment", "final review");
    processService.setProcessVariables(deploymentUnit.getIdentifier(), processInstanceId, params);
    variables = processService.getProcessInstanceVariables(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(variables);
    assertEquals(2, variables.size());
    assertTrue(variables.containsKey("approval_document"));
    assertTrue(variables.containsKey("approval_reviewComment"));
    assertEquals("updated document", variables.get("approval_document"));
    assertEquals("final review", variables.get("approval_reviewComment"));
    processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNull(pi);
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 18 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class ProcessServiceImplWithDeploymentIdTest method testStartProcess.

@Test
public void testStartProcess() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    assertNotNull(processService);
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "customtask");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNull(pi);
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 19 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class ProcessServiceImplWithoutAuditTest method testStartProcessAndAbortAlreadyAborted.

@Test
public void testStartProcessAndAbortAlreadyAborted() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("approval_document", "test");
    params.put("approval_reviewComment", "need review");
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
    assertNotNull(processInstanceId);
    processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNull(pi);
    assertThatExceptionOfType(ProcessInstanceNotFoundException.class).isThrownBy(() -> {
        processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    });
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 20 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class ProcessServiceImplWithoutAuditTest method testStartAndSignalProcess.

@Test
public void testStartAndSignalProcess() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    assertNotNull(processService);
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.signal");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(pi);
    Collection<String> signals = processService.getAvailableSignals(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(signals);
    assertEquals(1, signals.size());
    assertTrue(signals.contains("MySignal"));
    processService.signalProcessInstance(deploymentUnit.getIdentifier(), processInstanceId, "MySignal", null);
    pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNull(pi);
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)170 Test (org.junit.Test)131 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)97 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)83 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)55 HashMap (java.util.HashMap)46 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)42 ArrayList (java.util.ArrayList)34 QueryContext (org.kie.api.runtime.query.QueryContext)34 ReleaseId (org.kie.api.builder.ReleaseId)29 KieServices (org.kie.api.KieServices)26 File (java.io.File)22 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)22 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)21 DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)19 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)19 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)19 Before (org.junit.Before)18 FileOutputStream (java.io.FileOutputStream)17 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)17