Search in sources :

Example 11 with TaskService

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

the class ProcessEngineTestRule method completeTask.

public void completeTask(String taskKey) {
    TaskService taskService = processEngine.getTaskService();
    Task task = taskService.createTaskQuery().taskDefinitionKey(taskKey).singleResult();
    assertNotNull("Expected a task with key '" + taskKey + "' to exist", task);
    taskService.complete(task.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TimerTask(java.util.TimerTask) TaskService(org.camunda.bpm.engine.TaskService)

Example 12 with TaskService

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

the class ProcessEngineTestRule method completeAnyTask.

public void completeAnyTask(String taskKey) {
    TaskService taskService = processEngine.getTaskService();
    List<Task> tasks = taskService.createTaskQuery().taskDefinitionKey(taskKey).list();
    assertTrue(!tasks.isEmpty());
    taskService.complete(tasks.get(0).getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) TimerTask(java.util.TimerTask) TaskService(org.camunda.bpm.engine.TaskService)

Example 13 with TaskService

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

the class ProcessEngineRuleParameterizedJunit4Test method ruleUsageExample.

/**
 * Unnamed @Deployment annotations don't work with parameterized Unit tests
 */
@Ignore
@Test
@Deployment
public void ruleUsageExample() {
    RuntimeService runtimeService = engineRule.getRuntimeService();
    runtimeService.startProcessInstanceByKey("ruleUsage");
    TaskService taskService = engineRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("My Task", task.getName());
    taskService.complete(task.getId());
    assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
Also used : Task(org.camunda.bpm.engine.task.Task) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) Ignore(org.junit.Ignore) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with TaskService

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

the class BusinessProcessBeanTest method testGetVariableLocal.

@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testGetVariableLocal() {
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    ProcessInstance processInstance = businessProcess.startProcessByKey("businessProcessBeanTest");
    TaskService taskService = getBeanInstance(TaskService.class);
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task);
    businessProcess.startTask(task.getId());
    businessProcess.setVariableLocal("aVariableName", "aVariableValue");
    // Flushing and re-getting should retain the value (CAM-1806):
    businessProcess.flushVariableCache();
    assertTrue(businessProcess.getCachedLocalVariableMap().isEmpty());
    assertEquals("aVariableValue", businessProcess.getVariableLocal("aVariableName"));
}
Also used : Task(org.camunda.bpm.engine.task.Task) TaskService(org.camunda.bpm.engine.TaskService) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BusinessProcess(org.camunda.bpm.engine.cdi.BusinessProcess) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with TaskService

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

the class MockedProcessEngineProvider method mockServices.

private void mockServices(ProcessEngine engine) {
    RepositoryService repoService = mock(RepositoryService.class);
    IdentityService identityService = mock(IdentityService.class);
    TaskService taskService = mock(TaskService.class);
    RuntimeService runtimeService = mock(RuntimeService.class);
    FormService formService = mock(FormService.class);
    HistoryService historyService = mock(HistoryService.class);
    ManagementService managementService = mock(ManagementService.class);
    CaseService caseService = mock(CaseService.class);
    FilterService filterService = mock(FilterService.class);
    ExternalTaskService externalTaskService = mock(ExternalTaskService.class);
    when(engine.getRepositoryService()).thenReturn(repoService);
    when(engine.getIdentityService()).thenReturn(identityService);
    when(engine.getTaskService()).thenReturn(taskService);
    when(engine.getRuntimeService()).thenReturn(runtimeService);
    when(engine.getFormService()).thenReturn(formService);
    when(engine.getHistoryService()).thenReturn(historyService);
    when(engine.getManagementService()).thenReturn(managementService);
    when(engine.getCaseService()).thenReturn(caseService);
    when(engine.getFilterService()).thenReturn(filterService);
    when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) ManagementService(org.camunda.bpm.engine.ManagementService) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) FormService(org.camunda.bpm.engine.FormService) FilterService(org.camunda.bpm.engine.FilterService) HistoryService(org.camunda.bpm.engine.HistoryService) CaseService(org.camunda.bpm.engine.CaseService) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Aggregations

TaskService (org.camunda.bpm.engine.TaskService)22 Task (org.camunda.bpm.engine.task.Task)11 Test (org.junit.Test)6 RuntimeService (org.camunda.bpm.engine.RuntimeService)5 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)4 Deployment (org.camunda.bpm.engine.test.Deployment)4 FilterService (org.camunda.bpm.engine.FilterService)3 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 ArrayList (java.util.ArrayList)2 TimerTask (java.util.TimerTask)2 IdentityService (org.camunda.bpm.engine.IdentityService)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)2 StandaloneProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration)2 RestException (org.camunda.bpm.engine.rest.exception.RestException)2 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)2 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)2 VariableMap (org.camunda.bpm.engine.variable.VariableMap)2 HashMap (java.util.HashMap)1 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1