Search in sources :

Example 81 with Deployment

use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.

the class DelegationAuthorizationTest method testTaskListenerExecutesCommandAfterUserCompletesTaskAsExpression.

@Deployment
public void testTaskListenerExecutesCommandAfterUserCompletesTaskAsExpression() {
    // given
    processEngineConfiguration.getBeans().put("myListener", new ExecuteCommandTaskListener());
    startProcessInstanceByKey(DEFAULT_PROCESS_KEY);
    String taskId = selectSingleTask().getId();
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    // when
    taskService.complete(taskId);
    // then
    assertNotNull(MyDelegationService.CURRENT_AUTHENTICATION);
    assertEquals(userId, MyDelegationService.CURRENT_AUTHENTICATION.getUserId());
    disableAuthorization();
    assertEquals(2, runtimeService.createProcessInstanceQuery().count());
    enableAuthorization();
}
Also used : ExecuteCommandTaskListener(org.camunda.bpm.engine.test.api.authorization.service.ExecuteCommandTaskListener) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 82 with Deployment

use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.

the class DelegationAuthorizationTest method testScriptExecutionListenerExecutesCommandAfterUserCompletesTask.

@Deployment
public void testScriptExecutionListenerExecutesCommandAfterUserCompletesTask() {
    // given
    String processInstanceId = startProcessInstanceByKey(DEFAULT_PROCESS_KEY).getId();
    String taskId = selectSingleTask().getId();
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    // when
    taskService.complete(taskId);
    // then
    disableAuthorization();
    VariableInstance variableUser = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstanceId).variableName("userId").singleResult();
    assertNotNull(variableUser);
    assertEquals(userId, variableUser.getValue());
    assertEquals(2, runtimeService.createProcessInstanceQuery().count());
    enableAuthorization();
}
Also used : VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 83 with Deployment

use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.

the class DelegationAuthorizationTest method testExecutionListenerExecutesCommandAfterUserCompletesTaskAsDelegateExpression.

@Deployment
public void testExecutionListenerExecutesCommandAfterUserCompletesTaskAsDelegateExpression() {
    // given
    processEngineConfiguration.getBeans().put("myListener", new ExecuteCommandListener());
    startProcessInstanceByKey(DEFAULT_PROCESS_KEY);
    String taskId = selectSingleTask().getId();
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    // when
    taskService.complete(taskId);
    // then
    assertNotNull(MyDelegationService.CURRENT_AUTHENTICATION);
    assertEquals(userId, MyDelegationService.CURRENT_AUTHENTICATION.getUserId());
    disableAuthorization();
    assertEquals(2, runtimeService.createProcessInstanceQuery().count());
    enableAuthorization();
}
Also used : ExecuteCommandListener(org.camunda.bpm.engine.test.api.authorization.service.ExecuteCommandListener) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 84 with Deployment

use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.

the class DelegationAuthorizationTest method testScriptTaskListenerExecutesQueryAfterUserCompletesTask.

@Deployment
public void testScriptTaskListenerExecutesQueryAfterUserCompletesTask() {
    // given
    startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
    Task task = selectAnyTask();
    String taskId = task.getId();
    String processInstanceId = task.getProcessInstanceId();
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    // when
    taskService.complete(taskId);
    // then
    disableAuthorization();
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstanceId);
    VariableInstance variableUser = query.variableName("userId").singleResult();
    assertNotNull(variableUser);
    assertEquals(userId, variableUser.getValue());
    VariableInstance variableCount = query.variableName("count").singleResult();
    assertNotNull(variableCount);
    assertEquals(5l, variableCount.getValue());
    enableAuthorization();
}
Also used : Task(org.camunda.bpm.engine.task.Task) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 85 with Deployment

use of org.camunda.bpm.engine.test.Deployment in project camunda-bpm-platform by camunda.

the class DelegationAuthorizationTest method testJavaDelegateExecutesQueryAfterUserCompletesTaskAsDelegateExpression.

@Deployment
public void testJavaDelegateExecutesQueryAfterUserCompletesTaskAsDelegateExpression() {
    // given
    processEngineConfiguration.getBeans().put("myDelegate", new ExecuteQueryDelegate());
    startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
    String taskId = selectAnyTask().getId();
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    // when
    taskService.complete(taskId);
    // then
    assertNotNull(MyDelegationService.CURRENT_AUTHENTICATION);
    assertEquals(userId, MyDelegationService.CURRENT_AUTHENTICATION.getUserId());
    assertEquals(Long.valueOf(5), MyDelegationService.INSTANCES_COUNT);
}
Also used : ExecuteQueryDelegate(org.camunda.bpm.engine.test.api.authorization.service.ExecuteQueryDelegate) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

Deployment (org.camunda.bpm.engine.test.Deployment)3376 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1325 Task (org.camunda.bpm.engine.task.Task)788 Test (org.junit.Test)635 HashMap (java.util.HashMap)441 Job (org.camunda.bpm.engine.runtime.Job)310 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)277 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)265 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)256 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)251 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)230 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)206 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)195 Execution (org.camunda.bpm.engine.runtime.Execution)189 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)175 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)161 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)149 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)143 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)134 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)134