Search in sources :

Example 1 with ExecuteCommandListener

use of org.camunda.bpm.engine.test.api.authorization.service.ExecuteCommandListener 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 2 with ExecuteCommandListener

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

the class DelegationAuthorizationTest method testExecutionListenerExecutesCommandAfterUserCompletesTaskAsExpression.

@Deployment
public void testExecutionListenerExecutesCommandAfterUserCompletesTaskAsExpression() {
    // 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)

Aggregations

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