Search in sources :

Example 6 with SetProcessDefinitionVersionCmd

use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.

the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionNonExistingPI.

public void testSetProcessDefinitionVersionNonExistingPI() {
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    try {
        commandExecutor.execute(new SetProcessDefinitionVersionCmd("42", 23));
        fail("ProcessEngineException expected");
    } catch (ProcessEngineException ae) {
        assertTextPresent("No process instance found for id = '42'.", ae.getMessage());
    }
}
Also used : CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) SetProcessDefinitionVersionCmd(org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 7 with SetProcessDefinitionVersionCmd

use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.

the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionWithWithTask.

@Deployment(resources = { TEST_PROCESS_USER_TASK_V1 })
public void testSetProcessDefinitionVersionWithWithTask() {
    try {
        // start process instance
        ProcessInstance pi = runtimeService.startProcessInstanceByKey("userTask");
        // check that user task has been reached
        assertEquals(1, taskService.createTaskQuery().processInstanceId(pi.getId()).count());
        // deploy new version of the process definition
        org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_USER_TASK_V2).deploy();
        assertEquals(2, repositoryService.createProcessDefinitionQuery().processDefinitionKey("userTask").count());
        ProcessDefinition newProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("userTask").processDefinitionVersion(2).singleResult();
        // migrate process instance to new process definition version
        processEngineConfiguration.getCommandExecutorTxRequired().execute(new SetProcessDefinitionVersionCmd(pi.getId(), 2));
        // check UserTask
        Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
        assertEquals(newProcessDefinition.getId(), task.getProcessDefinitionId());
        assertEquals("testFormKey", formService.getTaskFormData(task.getId()).getFormKey());
        // continue
        taskService.complete(task.getId());
        assertProcessEnded(pi.getId());
        // undeploy "manually" deployed process definition
        repositoryService.deleteDeployment(deployment.getId(), true);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) SetProcessDefinitionVersionCmd(org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 8 with SetProcessDefinitionVersionCmd

use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.

the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionNonExistingPD.

@Deployment(resources = { TEST_PROCESS })
public void testSetProcessDefinitionVersionNonExistingPD() {
    // start process instance
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    try {
        commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 23));
        fail("ProcessEngineException expected");
    } catch (ProcessEngineException ae) {
        assertTextPresent("no processes deployed with key = 'receiveTask', version = '23'", ae.getMessage());
    }
}
Also used : CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) SetProcessDefinitionVersionCmd(org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with SetProcessDefinitionVersionCmd

use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.

the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionWithCallActivity.

@Deployment(resources = { TEST_PROCESS_CALL_ACTIVITY })
public void testSetProcessDefinitionVersionWithCallActivity() {
    // start process instance
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("parentProcess");
    // check that receive task has been reached
    Execution execution = runtimeService.createExecutionQuery().activityId("waitState1").processDefinitionKey("childProcess").singleResult();
    assertNotNull(execution);
    // deploy new version of the process definition
    org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_CALL_ACTIVITY).deploy();
    assertEquals(2, repositoryService.createProcessDefinitionQuery().processDefinitionKey("parentProcess").count());
    // migrate process instance to new process definition version
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 2));
    // signal process instance
    runtimeService.signal(execution.getId());
    // should be finished now
    assertEquals(0, runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).count());
    // undeploy "manually" deployed process definition
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) SetProcessDefinitionVersionCmd(org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 10 with SetProcessDefinitionVersionCmd

use of org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd in project camunda-bpm-platform by camunda.

the class SetProcessDefinitionVersionCmdTest method testSetProcessDefinitionVersionMigrateIncident.

@Deployment(resources = TEST_PROCESS_ONE_JOB)
public void testSetProcessDefinitionVersionMigrateIncident() {
    // given a process instance
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneJobProcess", Variables.createVariables().putValue("shouldFail", true));
    // with a failed job
    executeAvailableJobs();
    // and an incident
    Incident incident = runtimeService.createIncidentQuery().singleResult();
    assertNotNull(incident);
    // and a second deployment of the process
    org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_ONE_JOB).deploy();
    ProcessDefinition newDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
    assertNotNull(newDefinition);
    // when the process instance is migrated
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new SetProcessDefinitionVersionCmd(instance.getId(), 2));
    // then the the incident should also be migrated
    Incident migratedIncident = runtimeService.createIncidentQuery().singleResult();
    assertNotNull(migratedIncident);
    assertEquals(newDefinition.getId(), migratedIncident.getProcessDefinitionId());
    assertEquals(instance.getId(), migratedIncident.getProcessInstanceId());
    assertEquals(instance.getId(), migratedIncident.getExecutionId());
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) SetProcessDefinitionVersionCmd(org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Incident(org.camunda.bpm.engine.runtime.Incident) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

SetProcessDefinitionVersionCmd (org.camunda.bpm.engine.impl.cmd.SetProcessDefinitionVersionCmd)15 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)13 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)12 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)12 Deployment (org.camunda.bpm.engine.test.Deployment)12 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)9 Execution (org.camunda.bpm.engine.runtime.Execution)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 Job (org.camunda.bpm.engine.runtime.Job)4 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)2 Task (org.camunda.bpm.engine.task.Task)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 Incident (org.camunda.bpm.engine.runtime.Incident)1