Search in sources :

Example 16 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class DelegateExecutionHierarchyTest method testSingleNonScopeActivity.

public void testSingleNonScopeActivity() {
    deployment(Bpmn.createExecutableProcess("testProcess").startEvent().serviceTask().camundaClass(AssertingJavaDelegate.class.getName()).endEvent().done());
    AssertingJavaDelegate.addAsserts(new DelegateExecutionAsserter() {

        public void doAssert(DelegateExecution execution) {
            assertEquals(execution, execution.getProcessInstance());
            assertNull(execution.getSuperExecution());
        }
    });
    runtimeService.startProcessInstanceByKey("testProcess");
}
Also used : DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) DelegateExecutionAsserter(org.camunda.bpm.engine.test.api.delegate.AssertingJavaDelegate.DelegateExecutionAsserter)

Example 17 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class DelegateExecutionHierarchyTest method testSubProcessInstance.

public void testSubProcessInstance() {
    deployment(Bpmn.createExecutableProcess("testProcess").startEvent().callActivity().calledElement("testProcess2").endEvent().done(), Bpmn.createExecutableProcess("testProcess2").startEvent().serviceTask().camundaClass(AssertingJavaDelegate.class.getName()).endEvent().done());
    AssertingJavaDelegate.addAsserts(new DelegateExecutionAsserter() {

        public void doAssert(DelegateExecution execution) {
            assertTrue(execution.equals(execution.getProcessInstance()));
            assertNotNull(execution.getSuperExecution());
        }
    });
    runtimeService.startProcessInstanceByKey("testProcess");
}
Also used : DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) DelegateExecutionAsserter(org.camunda.bpm.engine.test.api.delegate.AssertingJavaDelegate.DelegateExecutionAsserter)

Example 18 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class DelegateExecutionHierarchyTest method testConcurrentServiceTasks.

public void testConcurrentServiceTasks() {
    deployment(Bpmn.createExecutableProcess("testProcess").startEvent().parallelGateway("fork").serviceTask().camundaClass(AssertingJavaDelegate.class.getName()).parallelGateway("join").endEvent().moveToNode("fork").serviceTask().camundaClass(AssertingJavaDelegate.class.getName()).connectTo("join").done());
    AssertingJavaDelegate.addAsserts(new DelegateExecutionAsserter() {

        public void doAssert(DelegateExecution execution) {
            assertFalse(execution.equals(execution.getProcessInstance()));
            assertNull(execution.getSuperExecution());
        }
    });
    runtimeService.startProcessInstanceByKey("testProcess");
}
Also used : DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) DelegateExecutionAsserter(org.camunda.bpm.engine.test.api.delegate.AssertingJavaDelegate.DelegateExecutionAsserter)

Example 19 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class AssigneeOverwriteFromVariable method notify.

@SuppressWarnings("unchecked")
public void notify(DelegateTask delegateTask) {
    // get mapping table from variable
    DelegateExecution execution = delegateTask.getExecution();
    Map<String, String> assigneeMappingTable = (Map<String, String>) execution.getVariable("assigneeMappingTable");
    // get assignee from process
    String assigneeFromProcessDefinition = delegateTask.getAssignee();
    // overwrite assignee if there is an entry in the mapping table
    if (assigneeMappingTable.containsKey(assigneeFromProcessDefinition)) {
        String assigneeFromMappingTable = assigneeMappingTable.get(assigneeFromProcessDefinition);
        delegateTask.setAssignee(assigneeFromMappingTable);
    }
}
Also used : DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) Map(java.util.Map)

Example 20 with DelegateExecution

use of org.camunda.bpm.engine.delegate.DelegateExecution in project camunda-bpm-platform by camunda.

the class ProcessApplicationEventListenerTest method testExecutionListenerWithErrorBoundaryEvent.

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

        public ExecutionListener getExecutionListener() {
            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());
    // 1. (start)startEvent(end) -(take)-> (start)serviceTask(end) -(take)-> (start)endEvent(end) (8 Events)
    // start process instance
    runtimeService.startProcessInstanceByKey("executionListener");
    assertEquals(10, eventCount.get());
    // reset counter
    eventCount.set(0);
    // 2. (start)startEvent(end) -(take)-> (start)serviceTask(end)/(start)errorBoundaryEvent(end) -(take)-> (start)endEvent(end) (10 Events)
    // start process instance
    runtimeService.startProcessInstanceByKey("executionListener", Collections.<String, Object>singletonMap("shouldThrowError", true));
    assertEquals(12, 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)

Aggregations

DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)23 EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)9 ExecutionListener (org.camunda.bpm.engine.delegate.ExecutionListener)9 Deployment (org.camunda.bpm.engine.test.Deployment)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 DelegateExecutionAsserter (org.camunda.bpm.engine.test.api.delegate.AssertingJavaDelegate.DelegateExecutionAsserter)6 DelegateTask (org.camunda.bpm.engine.delegate.DelegateTask)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 Task (org.camunda.bpm.engine.task.Task)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 IdentityService (org.camunda.bpm.engine.IdentityService)2 Authentication (org.camunda.bpm.engine.impl.identity.Authentication)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 ProcessApplicationUnavailableException (org.camunda.bpm.application.ProcessApplicationUnavailableException)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)1