Search in sources :

Example 86 with Deployment

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

the class DelegationAuthorizationTest method testCustomFormFieldValidatorAsDelegateExpression.

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

Example 87 with Deployment

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

the class DelegationAuthorizationTest method testExecutionListenerExecutesQueryAfterUserCompletesTaskAsExpression.

@Deployment
public void testExecutionListenerExecutesQueryAfterUserCompletesTaskAsExpression() {
    // given
    processEngineConfiguration.getBeans().put("myListener", new ExecuteQueryListener());
    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 : ExecuteQueryListener(org.camunda.bpm.engine.test.api.authorization.service.ExecuteQueryListener) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 88 with Deployment

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

the class ProcessApplicationEventListenerTest method testExecutionListener.

@Deployment
public void testExecutionListener() {
    final AtomicInteger eventCount = new AtomicInteger();
    EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {

        public ExecutionListener getExecutionListener() {
            // this process application returns an execution listener
            return new ExecutionListener() {

                public void notify(DelegateExecution execution) throws Exception {
                    eventCount.incrementAndGet();
                }
            };
        }
    };
    // register app so that it is notified about events
    managementService.registerProcessApplication(deploymentId, processApplication.getReference());
    // start process instance
    runtimeService.startProcessInstanceByKey("startToEnd");
    // 7 events received
    assertEquals(7, eventCount.get());
}
Also used : EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 89 with Deployment

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

the class ProcessApplicationEventListenerTest method testExecutionListenerWithMultiInstanceBody.

@Deployment
public void testExecutionListenerWithMultiInstanceBody() {
    final AtomicInteger eventCountForMultiInstanceBody = new AtomicInteger();
    EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {

        public ExecutionListener getExecutionListener() {
            return new ExecutionListener() {

                public void notify(DelegateExecution execution) throws Exception {
                    if ("miTasks#multiInstanceBody".equals(execution.getCurrentActivityId()) && (ExecutionListener.EVENTNAME_START.equals(execution.getEventName()) || ExecutionListener.EVENTNAME_END.equals(execution.getEventName()))) {
                        eventCountForMultiInstanceBody.incrementAndGet();
                    }
                }
            };
        }
    };
    // register app so that it is notified about events
    managementService.registerProcessApplication(deploymentId, processApplication.getReference());
    // start process instance
    runtimeService.startProcessInstanceByKey("executionListener");
    // complete task
    List<Task> miTasks = taskService.createTaskQuery().list();
    for (Task task : miTasks) {
        taskService.complete(task.getId());
    }
    // 2 events are expected: one for mi body start; one for mi body end
    assertEquals(2, eventCountForMultiInstanceBody.get());
}
Also used : DelegateTask(org.camunda.bpm.engine.delegate.DelegateTask) Task(org.camunda.bpm.engine.task.Task) EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 90 with Deployment

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

the class ProcessApplicationEventListenerTest method testIntermediateSignalEvent.

@Deployment
public void testIntermediateSignalEvent() {
    // given
    final List<String> timerEvents = new ArrayList<String>();
    EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {

        public ExecutionListener getExecutionListener() {
            return new ExecutionListener() {

                public void notify(DelegateExecution delegateExecution) {
                    String currentActivityId = delegateExecution.getCurrentActivityId();
                    String eventName = delegateExecution.getEventName();
                    if ("signal".equals(currentActivityId) && (ExecutionListener.EVENTNAME_START.equals(eventName) || ExecutionListener.EVENTNAME_END.equals(eventName))) {
                        timerEvents.add(delegateExecution.getEventName());
                    }
                }
            };
        }
    };
    // register app so that it is notified about events
    managementService.registerProcessApplication(deploymentId, processApplication.getReference());
    // when
    runtimeService.startProcessInstanceByKey("process");
    runtimeService.signalEventReceived("abort");
    // then
    assertEquals(2, timerEvents.size());
    // "start" event listener
    assertEquals(ExecutionListener.EVENTNAME_START, timerEvents.get(0));
    // "end" event listener
    assertEquals(ExecutionListener.EVENTNAME_END, timerEvents.get(1));
}
Also used : EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) ArrayList(java.util.ArrayList) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener) 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