Search in sources :

Example 6 with GetProcessInstanceCommand

use of org.drools.core.command.runtime.process.GetProcessInstanceCommand in project jbpm by kiegroup.

the class ProcessServiceImplPerProcessInstanceTest method testExecuteCommandWithContextOnAbortedProcess.

@Test
public void testExecuteCommandWithContextOnAbortedProcess() {
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), PROCESS_ID_HUMAN_TASK);
    assertNotNull(processInstanceId);
    processService.abortProcessInstance(processInstanceId);
    try {
        processService.execute(deploymentUnit.getIdentifier(), ProcessInstanceIdContext.get(processInstanceId), new GetProcessInstanceCommand(processInstanceId));
        fail("Executing command with context on already aborted process instance should throw ProcessInstanceNotFoundException.");
    } catch (ProcessInstanceNotFoundException e) {
    // expected
    }
}
Also used : ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) GetProcessInstanceCommand(org.drools.core.command.runtime.process.GetProcessInstanceCommand) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 7 with GetProcessInstanceCommand

use of org.drools.core.command.runtime.process.GetProcessInstanceCommand in project jbpm by kiegroup.

the class ProcessServiceEJBIntegrationTest method testStartProcessAndExecuteCmd.

@Test
public void testStartProcessAndExecuteCmd() {
    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.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.execute(deploymentUnit.getIdentifier(), new GetProcessInstanceCommand(processInstanceId));
    assertNotNull(pi);
    processService.abortProcessInstance(processInstanceId);
    pi = processService.getProcessInstance(processInstanceId);
    assertNull(pi);
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) GetProcessInstanceCommand(org.drools.core.command.runtime.process.GetProcessInstanceCommand) Test(org.junit.Test)

Example 8 with GetProcessInstanceCommand

use of org.drools.core.command.runtime.process.GetProcessInstanceCommand in project drools by kiegroup.

the class CommandBasedStatefulKnowledgeSession method getProcessInstance.

public ProcessInstance getProcessInstance(long id, boolean readOnly) {
    GetProcessInstanceCommand command = new GetProcessInstanceCommand();
    command.setProcessInstanceId(id);
    command.setReadOnly(readOnly);
    return runner.execute(command);
}
Also used : GetProcessInstanceCommand(org.drools.core.command.runtime.process.GetProcessInstanceCommand)

Example 9 with GetProcessInstanceCommand

use of org.drools.core.command.runtime.process.GetProcessInstanceCommand in project jbpm by kiegroup.

the class ProcessServiceImplPerProcessInstanceTest method testExecuteCommandOnAbortedProcess.

@Test
public void testExecuteCommandOnAbortedProcess() {
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), PROCESS_ID_HUMAN_TASK);
    assertNotNull(processInstanceId);
    processService.abortProcessInstance(processInstanceId);
    try {
        processService.execute(deploymentUnit.getIdentifier(), new GetProcessInstanceCommand(processInstanceId));
        fail("Executing command on already aborted process instance should throw ProcessInstanceNotFoundException.");
    } catch (ProcessInstanceNotFoundException e) {
    // expected
    }
}
Also used : ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) GetProcessInstanceCommand(org.drools.core.command.runtime.process.GetProcessInstanceCommand) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 10 with GetProcessInstanceCommand

use of org.drools.core.command.runtime.process.GetProcessInstanceCommand in project jbpm by kiegroup.

the class ProcessServiceImplTest method testStartProcessAndExecuteCmd.

@Test
public void testStartProcessAndExecuteCmd() {
    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.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.execute(deploymentUnit.getIdentifier(), new GetProcessInstanceCommand(processInstanceId));
    assertNotNull(pi);
    processService.abortProcessInstance(processInstanceId);
    pi = processService.getProcessInstance(processInstanceId);
    assertNull(pi);
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) GetProcessInstanceCommand(org.drools.core.command.runtime.process.GetProcessInstanceCommand) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

GetProcessInstanceCommand (org.drools.core.command.runtime.process.GetProcessInstanceCommand)11 Test (org.junit.Test)9 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)6 Properties (java.util.Properties)5 SessionConfiguration (org.drools.core.SessionConfiguration)5 StartProcessCommand (org.drools.core.command.runtime.process.StartProcessCommand)5 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)5 PersistableRunner (org.drools.persistence.PersistableRunner)5 JPAWorkItemManagerFactory (org.drools.persistence.jpa.processinstance.JPAWorkItemManagerFactory)5 JPAProcessInstanceManagerFactory (org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory)5 JPASignalManagerFactory (org.jbpm.persistence.processinstance.JPASignalManagerFactory)5 RuleFlowProcessInstance (org.jbpm.ruleflow.instance.RuleFlowProcessInstance)5 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)5 KiePackage (org.kie.api.definition.KiePackage)5 CompleteWorkItemCommand (org.drools.core.command.runtime.process.CompleteWorkItemCommand)3 JpaJDKTimerService (org.drools.persistence.jpa.JpaJDKTimerService)3 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)3 TestWorkItemHandler (org.jbpm.persistence.session.objects.TestWorkItemHandler)3 WorkItem (org.kie.api.runtime.process.WorkItem)3 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)2