Search in sources :

Example 6 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class ConnectProcessEnginePluginTest method testConnectorBpmnErrorThrownInScriptResourceOutputMappingIsHandledByBoundaryEvent.

@Deployment(resources = "org/camunda/connect/plugin/ConnectProcessEnginePluginTest.testConnectorWithThrownExceptionInScriptResourceInputOutputMapping.bpmn")
public void testConnectorBpmnErrorThrownInScriptResourceOutputMappingIsHandledByBoundaryEvent() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("throwInMapping", "out");
    variables.put("exception", new BpmnError("error"));
    runtimeService.startProcessInstanceByKey("testProcess", variables);
    // we will only reach the user task if the BPMNError from the script was handled by the boundary event
    Task task = taskService.createTaskQuery().singleResult();
    assertThat(task.getName(), is("User Task"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class EventNotificationTest method testMultiInstanceEventsAfterExternalTrigger.

@Test
@Deployment
public void testMultiInstanceEventsAfterExternalTrigger() {
    runtimeService.startProcessInstanceByKey("process");
    TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
    listenerBean.reset();
    List<Task> tasks = taskService.createTaskQuery().list();
    assertEquals(3, tasks.size());
    for (Task task : tasks) {
        taskService.complete(task.getId());
    }
    // 6: three user task instances (complete + end)
    // 1: one mi body instance (end)
    // 1: one sequence flow instance (take)
    // 2: one end event instance (start + end)
    // = 5
    Set<BusinessProcessEvent> eventsReceived = listenerBean.getEventsReceived();
    assertThat(eventsReceived.size(), is(10));
}
Also used : Task(org.camunda.bpm.engine.task.Task) BusinessProcessEvent(org.camunda.bpm.engine.cdi.BusinessProcessEvent) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 8 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class EventNotificationTest method testMultiInstanceEvents.

@Test
@Deployment
public void testMultiInstanceEvents() {
    TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
    listenerBean.reset();
    assertThat(listenerBean.getEventsReceived().size(), is(0));
    runtimeService.startProcessInstanceByKey("process1");
    waitForJobExecutorToProcessAllJobs(TimeUnit.SECONDS.toMillis(5L), 500L);
    Task task = taskService.createTaskQuery().singleResult();
    assertThat(task.getName(), is("User Task"));
    // 2: start event (start + end)
    // 1: transition to first mi activity
    // 2: first mi body (start + end)
    // 4: two instances of the inner activity (start + end)
    // 1: transition to second mi activity
    // 2: second mi body (start + end)
    // 4: two instances of the inner activity (start + end)
    // 1: transition to the user task
    // 2: user task (start + task create event)
    // = 19
    assertThat(listenerBean.getEventsReceived().size(), is(19));
}
Also used : Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class EventNotificationTest method testReceiveAll.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/cdi/test/impl/event/EventNotificationTest.process1.bpmn20.xml" })
public void testReceiveAll() {
    TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
    listenerBean.reset();
    // assert that the bean has received 0 events
    assertEquals(0, listenerBean.getEventsReceived().size());
    runtimeService.startProcessInstanceByKey("process1");
    // complete user task
    Task task = taskService.createTaskQuery().singleResult();
    taskService.complete(task.getId());
    assertEquals(16, listenerBean.getEventsReceived().size());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 10 with Task

use of org.camunda.bpm.engine.task.Task in project camunda-bpm-platform by camunda.

the class TaskRestServiceInteractionTest method testPostCreateTaskDelegationStateResolved.

@Test
public void testPostCreateTaskDelegationStateResolved() {
    Map<String, Object> json = new HashMap<String, Object>();
    json.put("delegationState", "RESOLVED");
    Task newTask = mock(Task.class);
    when(taskServiceMock.newTask(anyString())).thenReturn(newTask);
    given().body(json).contentType(ContentType.JSON).header("accept", MediaType.APPLICATION_JSON).expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(TASK_CREATE_URL);
    verify(taskServiceMock).newTask(null);
    verify(newTask).setDelegationState(DelegationState.valueOf((String) json.get("delegationState")));
    verify(taskServiceMock).saveTask(newTask);
}
Also used : Task(org.camunda.bpm.engine.task.Task) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

Task (org.camunda.bpm.engine.task.Task)1654 Deployment (org.camunda.bpm.engine.test.Deployment)788 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)660 Test (org.junit.Test)648 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)230 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)190 HashMap (java.util.HashMap)140 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)139 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)108 Execution (org.camunda.bpm.engine.runtime.Execution)99 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)98 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)87 Job (org.camunda.bpm.engine.runtime.Job)71 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)67 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)52 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)46 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)46 Times (org.camunda.bpm.qa.upgrade.Times)46 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)45 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)45