Search in sources :

Example 21 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class EventSubscriptionQueryTest method testQueryByExecutionId.

@Deployment
public void testQueryByExecutionId() {
    // starting two instances:
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("catchSignal");
    runtimeService.startProcessInstanceByKey("catchSignal");
    // test query by process instance id
    EventSubscriptionEntity subscription = newEventSubscriptionQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(subscription);
    Execution executionWaitingForSignal = runtimeService.createExecutionQuery().activityId("signalEvent").processInstanceId(processInstance.getId()).singleResult();
    // test query by execution id
    EventSubscriptionEntity signalSubscription = newEventSubscriptionQuery().executionId(executionWaitingForSignal.getId()).singleResult();
    assertNotNull(signalSubscription);
    assertEquals(signalSubscription, subscription);
    cleanDb();
}
Also used : Execution(org.activiti.engine.runtime.Execution) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity) Deployment(org.activiti.engine.test.Deployment)

Example 22 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class ProcessInstanceIdentityLinkTest method testSetAuthenticatedUserAndCompleteLastTask.

// Test specific for fix introduced by https://activiti.atlassian.net/browse/ACT-1591
// (Referential integrity constraint violation on PROC_INST and IDENTITY_LINK)
@Deployment
public void testSetAuthenticatedUserAndCompleteLastTask() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("identityLinktest");
    // There are two tasks
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());
    identityService.setAuthenticatedUserId("kermit");
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.complete(task.getId());
    identityService.setAuthenticatedUserId(null);
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.activiti.engine.task.Task) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 23 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class ProcessInstanceIdentityLinkTest method testSetAuthenticatedUserWithNoWaitStates.

// Test specific for fix introduced by https://activiti.atlassian.net/browse/ACT-1591
// (Referential integrity constraint violation on PROC_INST and IDENTITY_LINK)
@Deployment
public void testSetAuthenticatedUserWithNoWaitStates() {
    identityService.setAuthenticatedUserId("kermit");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("identityLinktest");
    assertProcessEnded(processInstance.getId());
    identityService.setAuthenticatedUserId(null);
}
Also used : ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 24 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class TaskDueDateExtensionsTest method testRelativeDueDateStringExtension.

@Deployment
public void testRelativeDueDateStringExtension() throws Exception {
    Clock clock = processEngineConfiguration.getClock();
    clock.setCurrentCalendar(new GregorianCalendar(2015, 0, 1));
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("dateVariable", "P2DT5H40M");
    // Start process-instance, passing ISO8601 duration formatted String that should be used to calculate dueDate
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dueDateExtension", variables);
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task.getDueDate());
    Period period = new Period(task.getCreateTime().getTime(), task.getDueDate().getTime());
    assertEquals(2, period.getDays());
    assertEquals(5, period.getHours());
    assertEquals(40, period.getMinutes());
    clock.reset();
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Period(org.joda.time.Period) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Clock(org.activiti.engine.runtime.Clock) Deployment(org.activiti.engine.test.Deployment)

Example 25 with ProcessInstance

use of org.activiti.engine.runtime.ProcessInstance in project Activiti by Activiti.

the class TaskDueDateExtensionsTest method testRelativeDueDateStringWithCalendarNameExtension.

@Deployment
public void testRelativeDueDateStringWithCalendarNameExtension() throws Exception {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("dateVariable", "P2DT5H40M");
    // Start process-instance, passing ISO8601 duration formatted String that should be used to calculate dueDate
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("dueDateExtension", variables);
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task.getDueDate());
    assertThat(task.getDueDate(), is(new Date(0)));
}
Also used : Task(org.activiti.engine.task.Task) HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ProcessInstance (org.activiti.engine.runtime.ProcessInstance)822 Deployment (org.activiti.engine.test.Deployment)708 Task (org.activiti.engine.task.Task)374 HashMap (java.util.HashMap)242 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)182 Execution (org.activiti.engine.runtime.Execution)76 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)64 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)57 Job (org.activiti.engine.runtime.Job)55 Date (java.util.Date)53 JsonNode (com.fasterxml.jackson.databind.JsonNode)49 Calendar (java.util.Calendar)48 ActivitiException (org.activiti.engine.ActivitiException)41 ArrayList (java.util.ArrayList)38 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)38 HttpGet (org.apache.http.client.methods.HttpGet)38 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)27 StringEntity (org.apache.http.entity.StringEntity)27 HttpPost (org.apache.http.client.methods.HttpPost)25 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)24