Search in sources :

Example 51 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class FormAuthorizationTest method testSubmitStartForm.

public void testSubmitStartForm() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(FORM_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, FORM_PROCESS_KEY, userId, CREATE_INSTANCE);
    createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, CREATE);
    // when
    ProcessInstance instance = formService.submitStartForm(processDefinitionId, null);
    // then
    assertNotNull(instance);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance)

Example 52 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class CmmnDisabledTest method testVariableInstanceQuery.

public void testVariableInstanceQuery() {
    ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()).addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml").deploy();
    VariableMap variables = Variables.createVariables().putValue("my-variable", "a-value");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
    // variable instance query
    List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list();
    assertEquals(1, result.size());
    VariableInstance variableInstance = result.get(0);
    assertEquals("my-variable", variableInstance.getName());
    // get variable
    assertNotNull(runtimeService.getVariable(processInstance.getId(), "my-variable"));
    // get variable local
    assertNotNull(runtimeService.getVariableLocal(processInstance.getId(), "my-variable"));
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) VariableMap(org.camunda.bpm.engine.variable.VariableMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance)

Example 53 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class ProcessApplicationElResolverTest method testCallActivityOutputExpression.

/**
 * Tests that an expression for a call activity output parameter is resolved
 * in the context of the called process definition's application.
 */
public void testCallActivityOutputExpression() {
    // given an instance of the calling process that calls the called process
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("callingProcess");
    // when the called process is completed
    Task calledProcessTask = taskService.createTaskQuery().singleResult();
    taskService.complete(calledProcessTask.getId());
    // then the output mapping should have successfully resolved the expression
    String outVariable = (String) runtimeService.getVariable(instance.getId(), "outVar");
    assertEquals(CalledProcessApplication.STRING_VARIABLE_VALUE, outVariable);
}
Also used : Task(org.camunda.bpm.engine.task.Task) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance)

Example 54 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class ExternalTaskQueryByPriorityTest method testFilterByExternalTaskPriorityLowerAndHigher.

@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml")
public void testFilterByExternalTaskPriorityLowerAndHigher() {
    // given five jobs with priorities from 1 to 5
    List<ProcessInstance> instances = new ArrayList<ProcessInstance>();
    for (int i = 0; i < 5; i++) {
        instances.add(runtimeService.startProcessInstanceByKey("twoExternalTaskWithPriorityProcess", Variables.createVariables().putValue("priority", i)));
    }
    // when making a external task query and filtering by external task priority
    // then the correct external task is returned
    ExternalTask task = externalTaskService.createExternalTaskQuery().priorityHigherThanOrEquals(2L).priorityLowerThanOrEquals(2L).singleResult();
    assertNotNull(task);
    assertEquals(2, task.getPriority());
    assertEquals(instances.get(2).getId(), task.getProcessInstanceId());
}
Also used : ArrayList(java.util.ArrayList) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 55 with ProcessInstance

use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.

the class ExternalTaskQueryByPriorityTest method testFilterByExternalTaskPriorityLowerThanOrEquals.

@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml")
public void testFilterByExternalTaskPriorityLowerThanOrEquals() {
    // given five jobs with priorities from 1 to 5
    // each process has two external tasks - one with priority expression and one without priority
    List<ProcessInstance> instances = new ArrayList<ProcessInstance>();
    for (int i = 0; i < 5; i++) {
        instances.add(runtimeService.startProcessInstanceByKey("twoExternalTaskWithPriorityProcess", Variables.createVariables().putValue("priority", i)));
    }
    // when making a external task query and filtering by priority
    // then the correct external tasks are returned
    List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().priorityLowerThanOrEquals(2).list();
    assertEquals(8, tasks.size());
    for (ExternalTask task : tasks) {
        assertTrue(task.getPriority() <= 2);
    }
}
Also used : ArrayList(java.util.ArrayList) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2392 Deployment (org.camunda.bpm.engine.test.Deployment)1325 Test (org.junit.Test)1168 Task (org.camunda.bpm.engine.task.Task)660 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)415 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)372 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)272 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)258 HashMap (java.util.HashMap)235 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)230 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)203 Job (org.camunda.bpm.engine.runtime.Job)189 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)184 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)149 Execution (org.camunda.bpm.engine.runtime.Execution)144 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)130 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)129 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)122 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)86 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)84