Search in sources :

Example 1 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class BusinessProcessBeanTest method testResolveTaskBean.

@Test
@Deployment(resources = "org/activiti/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testResolveTaskBean() {
    BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);
    assertNull(getBeanInstance(Task.class));
    assertNull(getBeanInstance("taskId"));
    businessProcess.startProcessByKey("businessProcessBeanTest");
    String taskId = taskService.createTaskQuery().singleResult().getId();
    businessProcess.startTask(taskId);
    // assert that now we can resolve the Task-bean
    assertEquals(taskId, getBeanInstance(Task.class).getId());
    assertEquals(taskId, getBeanInstance("taskId"));
    taskService.complete(taskService.createTaskQuery().singleResult().getId());
}
Also used : Task(org.activiti.engine.task.Task) BusinessProcess(org.activiti.cdi.BusinessProcess) Test(org.junit.Test) Deployment(org.activiti.engine.test.Deployment)

Example 2 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class CamelVariableTransferTest method testCamelPropertiesAll.

// check that at least all properties are passed from camel to activiti when copyVariablesFromProperties=true is simply true
@Deployment
public void testCamelPropertiesAll() throws Exception {
    ProducerTemplate tpl = camelContext.createProducerTemplate();
    Exchange exchange = camelContext.getEndpoint("direct:startAllProperties").createExchange();
    tpl.send("direct:startAllProperties", exchange);
    assertNotNull(taskService);
    assertNotNull(runtimeService);
    assertEquals(1, taskService.createTaskQuery().count());
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId());
    assertEquals("sampleValueForProperty1", variables.get("property1"));
    assertEquals("sampleValueForProperty2", variables.get("property2"));
    assertEquals("sampleValueForProperty3", variables.get("property3"));
}
Also used : Exchange(org.apache.camel.Exchange) ProducerTemplate(org.apache.camel.ProducerTemplate) Task(org.activiti.engine.task.Task) Deployment(org.activiti.engine.test.Deployment)

Example 3 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class CamelVariableTransferTest method testCamelHeadersAll.

@Deployment(resources = { "org/activiti/camel/variables/CamelVariableTransferTest.testCamelPropertiesAll.bpmn20.xml" })
public void testCamelHeadersAll() throws Exception {
    ProducerTemplate tpl = camelContext.createProducerTemplate();
    Exchange exchange = camelContext.getEndpoint("direct:startAllProperties").createExchange();
    tpl.send("direct:startAllProperties", exchange);
    assertNotNull(taskService);
    assertNotNull(runtimeService);
    assertEquals(1, taskService.createTaskQuery().count());
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId());
    assertEquals("sampleValueForProperty1", variables.get("property1"));
    assertEquals("sampleValueForProperty2", variables.get("property2"));
    assertEquals("sampleValueForProperty3", variables.get("property3"));
}
Also used : Exchange(org.apache.camel.Exchange) ProducerTemplate(org.apache.camel.ProducerTemplate) Task(org.activiti.engine.task.Task) Deployment(org.activiti.engine.test.Deployment)

Example 4 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class BusinessProcess method startTask.

// -------------------------------------
/**
   * Associates the task with the provided taskId with the current conversation.
   * <p/>
   * 
   * @param taskId
   *          the id of the task
   * 
   * @return the resumed task
   * 
   * @throws ActivitiCdiException
   *           if no such task is found
   */
public Task startTask(String taskId) {
    Task currentTask = associationManager.getTask();
    if (currentTask != null && currentTask.getId().equals(taskId)) {
        return currentTask;
    }
    Task task = processEngine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
    if (task == null) {
        throw new ActivitiCdiException("Cannot resume task with id '" + taskId + "', no such task.");
    }
    associationManager.setTask(task);
    associateExecutionById(task.getExecutionId());
    return task;
}
Also used : Task(org.activiti.engine.task.Task)

Example 5 with Task

use of org.activiti.engine.task.Task in project Activiti by Activiti.

the class MultiInstanceTest method testSequentialCallActivityWithList.

@Deployment(resources = "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialCallActivityWithList.bpmn20.xml")
public void testSequentialCallActivityWithList() {
    ArrayList<String> list = new ArrayList<String>();
    list.add("one");
    list.add("two");
    HashMap<String, Object> variables = new HashMap<String, Object>();
    variables.put("list", list);
    String procId = runtimeService.startProcessInstanceByKey("parentProcess", variables).getId();
    Task task1 = taskService.createTaskQuery().processVariableValueEquals("element", "one").singleResult();
    Task task2 = taskService.createTaskQuery().processVariableValueEquals("element", "two").singleResult();
    assertNotNull(task1);
    assertNotNull(task2);
    HashMap<String, Object> subVariables = new HashMap<String, Object>();
    subVariables.put("x", "y");
    taskService.complete(task1.getId(), subVariables);
    taskService.complete(task2.getId(), subVariables);
    Task task3 = taskService.createTaskQuery().processDefinitionKey("midProcess").singleResult();
    assertNotNull(task3);
    taskService.complete(task3.getId(), null);
    Task task4 = taskService.createTaskQuery().processDefinitionKey("parentProcess").singleResult();
    assertNotNull(task4);
    taskService.complete(task4.getId(), null);
    assertProcessEnded(procId);
}
Also used : Task(org.activiti.engine.task.Task) DelegateTask(org.activiti.engine.delegate.DelegateTask) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Deployment(org.activiti.engine.test.Deployment)

Aggregations

Task (org.activiti.engine.task.Task)936 Deployment (org.activiti.engine.test.Deployment)548 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)499 HashMap (java.util.HashMap)191 Test (org.junit.Test)115 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)106 ArrayList (java.util.ArrayList)70 Date (java.util.Date)62 Execution (org.activiti.engine.runtime.Execution)57 DelegateTask (org.activiti.engine.delegate.DelegateTask)54 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)51 TaskQuery (org.activiti.engine.task.TaskQuery)50 Job (org.activiti.engine.runtime.Job)48 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)44 Calendar (java.util.Calendar)43 JsonNode (com.fasterxml.jackson.databind.JsonNode)41 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)41 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)40 JSONObject (org.json.simple.JSONObject)40 TasksClient (org.alfresco.rest.workflow.api.tests.WorkflowApiClient.TasksClient)38