Search in sources :

Example 1 with ExecuteCommandTaskListener

use of org.camunda.bpm.engine.test.api.authorization.service.ExecuteCommandTaskListener in project camunda-bpm-platform by camunda.

the class DelegationAuthorizationTest method testTaskListenerExecutesCommandAfterUserCompletesTaskAsDelegateExpression.

@Deployment
public void testTaskListenerExecutesCommandAfterUserCompletesTaskAsDelegateExpression() {
    // 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 2 with ExecuteCommandTaskListener

use of org.camunda.bpm.engine.test.api.authorization.service.ExecuteCommandTaskListener 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)

Aggregations

Deployment (org.camunda.bpm.engine.test.Deployment)2 ExecuteCommandTaskListener (org.camunda.bpm.engine.test.api.authorization.service.ExecuteCommandTaskListener)2