org.activiti.engine.runtime.ProcessInstanceQuery Java Examples

The following examples show how to use org.activiti.engine.runtime.ProcessInstanceQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByProcessDefinitionId() {
  final ProcessDefinition processDefinition1 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
  ProcessInstanceQuery query1 = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition1.getId());
  assertEquals(PROCESS_DEFINITION_KEY_DEPLOY_COUNT, query1.count());
  assertEquals(PROCESS_DEFINITION_KEY_DEPLOY_COUNT, query1.list().size());
  try {
    query1.singleResult();
    fail();
  } catch (ActivitiException e) {
    // Exception is expected
  }

  final ProcessDefinition processDefinition2 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY_2).singleResult();
  ProcessInstanceQuery query2 = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition2.getId());
  assertEquals(PROCESS_DEFINITION_KEY_2_DEPLOY_COUNT, query2.count());
  assertEquals(PROCESS_DEFINITION_KEY_2_DEPLOY_COUNT, query2.list().size());
  assertNotNull(query2.singleResult());
}
 
Example #2
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryAllVariableTypes() throws Exception {
  Map<String, Object> vars = new HashMap<String, Object>();
  vars.put("nullVar", null);
  vars.put("stringVar", "string");
  vars.put("longVar", 10L);
  vars.put("doubleVar", 1.2);
  vars.put("integerVar", 1234);
  vars.put("booleanVar", true);
  vars.put("shortVar", (short) 123);

  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);

  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().variableValueEquals("nullVar", null).variableValueEquals("stringVar", "string").variableValueEquals("longVar", 10L)
      .variableValueEquals("doubleVar", 1.2).variableValueEquals("integerVar", 1234).variableValueEquals("booleanVar", true).variableValueEquals("shortVar", (short) 123);

  List<ProcessInstance> processInstances = query.list();
  assertNotNull(processInstances);
  assertEquals(1, processInstances.size());
  assertEquals(processInstance.getId(), processInstances.get(0).getId());

  runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
 
Example #3
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByProcessInstanceIds() {
  Set<String> processInstanceIds = new HashSet<String>(this.processInstanceIds);

  // start an instance that will not be part of the query
  runtimeService.startProcessInstanceByKey("oneTaskProcess2", "2");

  ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(processInstanceIds);
  assertEquals(5, processInstanceQuery.count());

  List<ProcessInstance> processInstances = processInstanceQuery.list();
  assertNotNull(processInstances);
  assertEquals(5, processInstances.size());

  for (ProcessInstance processInstance : processInstances) {
    assertTrue(processInstanceIds.contains(processInstance.getId()));
  }
}
 
Example #4
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByProcessDefinitionIds() {
  final ProcessDefinition processDefinition1 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
  final ProcessDefinition processDefinition2 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY_2).singleResult();

  final Set<String> processDefinitionIdSet = new HashSet<String>(2);
  processDefinitionIdSet.add(processDefinition1.getId());
  processDefinitionIdSet.add(processDefinition2.getId());

  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionIds(processDefinitionIdSet);
  assertEquals(PROCESS_DEPLOY_COUNT, query.count());
  assertEquals(PROCESS_DEPLOY_COUNT, query.list().size());
  try {
    query.singleResult();
    fail();
  } catch (ActivitiException e) {
    // Exception is expected
  }
}
 
Example #5
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByProcessDefinitionId() {
  final ProcessDefinition processDefinition1 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
  ProcessInstanceQuery query1 = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition1.getId());
  assertEquals(PROCESS_DEFINITION_KEY_DEPLOY_COUNT, query1.count());
  assertEquals(PROCESS_DEFINITION_KEY_DEPLOY_COUNT, query1.list().size());
  try {
    query1.singleResult();
    fail();
  } catch (ActivitiException e) {
    // Exception is expected
  }

  final ProcessDefinition processDefinition2 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY_2).singleResult();
  ProcessInstanceQuery query2 = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition2.getId());
  assertEquals(PROCESS_DEFINITION_KEY_2_DEPLOY_COUNT, query2.count());
  assertEquals(PROCESS_DEFINITION_KEY_2_DEPLOY_COUNT, query2.list().size());
  assertNotNull(query2.singleResult());
}
 
Example #6
Source File: ActivitiServiceTest.java    From herd with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetProcessInstanceById()
{
    String processInstanceId = "processInstanceId";
    ProcessInstanceQuery processInstanceQuery = mock(ProcessInstanceQuery.class);
    when(activitiRuntimeService.createProcessInstanceQuery()).thenReturn(processInstanceQuery);
    when(processInstanceQuery.processInstanceId(processInstanceId)).thenReturn(processInstanceQuery);
    when(processInstanceQuery.includeProcessVariables()).thenReturn(processInstanceQuery);
    ProcessInstance expectedProcessInstance = mock(ProcessInstance.class);
    when(processInstanceQuery.singleResult()).thenReturn(expectedProcessInstance);
    ProcessInstance actualProcessInstance = activitiService.getProcessInstanceById(processInstanceId);
    assertSame(expectedProcessInstance, actualProcessInstance);
    InOrder inOrder = inOrder(processInstanceQuery);
    inOrder.verify(processInstanceQuery).processInstanceId(processInstanceId);
    inOrder.verify(processInstanceQuery).includeProcessVariables();
    inOrder.verify(processInstanceQuery).singleResult();
    inOrder.verifyNoMoreInteractions();
}
 
Example #7
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByProcessInstanceIds() {
  Set<String> processInstanceIds = new HashSet<String>(this.processInstanceIds);

  // start an instance that will not be part of the query
  runtimeService.startProcessInstanceByKey("oneTaskProcess2", "2");
 
  ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(processInstanceIds);
  assertEquals(5, processInstanceQuery.count());
  
  List<ProcessInstance> processInstances = processInstanceQuery.list();
  assertNotNull(processInstances);
  assertEquals(5, processInstances.size());
  
  for (ProcessInstance processInstance : processInstances) {
    assertTrue(processInstanceIds.contains(processInstance.getId()));
  }
}
 
Example #8
Source File: ActProcessService.java    From Shop-for-JavaWeb with MIT License 6 votes vote down vote up
/**
 * 流程定义列表
 */
public Page<ProcessInstance> runningList(Page<ProcessInstance> page, String procInsId, String procDefKey) {

    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();

    if (StringUtils.isNotBlank(procInsId)){
	    processInstanceQuery.processInstanceId(procInsId);
    }
    
    if (StringUtils.isNotBlank(procDefKey)){
	    processInstanceQuery.processDefinitionKey(procDefKey);
    }
    
    page.setCount(processInstanceQuery.count());
    page.setList(processInstanceQuery.listPage(page.getFirstResult(), page.getMaxResults()));
	return page;
}
 
Example #9
Source File: CtrlrServletTest.java    From oneops with Apache License 2.0 6 votes vote down vote up
@BeforeTest
public void setUp(){
	RuntimeService rts = mock(RuntimeService.class);
	List<ProcessInstance> processList = new ArrayList<ProcessInstance>();
	ExecutionEntity executionEntity = new  ExecutionEntity();
	executionEntity.setActive(false);
	processList.add(executionEntity);
	
	ProcessInstanceQuery pQuery = mock(ProcessInstanceQuery.class);
	when(pQuery.active()).thenReturn(pQuery);
	when(pQuery.list()).thenReturn(processList);
	when(rts.createProcessInstanceQuery()).thenReturn(pQuery);

	this.servlet.setRuntimeService(rts);
	this.servlet.setWoDispatcher(mock(WoDispatcher.class));
	this.servlet.init();
}
 
Example #10
Source File: ProcessInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public ProcessInstanceQuery startedBy(String userId) {
  if (inOrStatement) {
    this.currentOrQueryObject.startedBy = userId;
  } else {
    this.startedBy = userId;
  }
  return this;
}
 
Example #11
Source File: ProcessInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessInstanceQuery variableValueNotEquals(String variableName, Object variableValue) {
  if (inOrStatement) {
    currentOrQueryObject.variableValueNotEquals(variableName, variableValue, false);
    return this;
  } else {
    return variableValueNotEquals(variableName, variableValue, false);
  }
}
 
Example #12
Source File: ProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessInstanceQuery endOr() {
    if (!inOrStatement) {
        throw new ActivitiException("endOr() can only be called after calling or()");
    }

    inOrStatement = false;
    currentOrQueryObject = null;
    return this;
}
 
Example #13
Source File: ProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessInstanceQuery variableValueGreaterThan(String name, Object value) {
    if (inOrStatement) {
        currentOrQueryObject.variableValueGreaterThan(name, value, false);
        return this;
    } else {
        return variableValueGreaterThan(name, value, false);
    }
}
 
Example #14
Source File: ProcessEngineService.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 读取运行中的流程
 *
 * @param processDefinitionKey
 * @param startRow
 * @param endRow
 * @return
 */
public List<ProcessInstance> findRunningProcessInstaces(String processDefinitionKey, int startRow, int endRow) {
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().active()
            .orderByProcessInstanceId().desc();
    if (org.apache.commons.lang3.StringUtils.isNotEmpty(processDefinitionKey)) {
        query.processDefinitionKey(processDefinitionKey);
    }
    List<ProcessInstance> list = query.listPage(startRow, endRow);
    return list;
}
 
Example #15
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByProcessDefinitionKeys() {
  final Set<String> processDefinitionKeySet = new HashSet<String>(2);
  processDefinitionKeySet.add(PROCESS_DEFINITION_KEY);
  processDefinitionKeySet.add(PROCESS_DEFINITION_KEY_2);

  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKeys(processDefinitionKeySet);
  assertEquals(PROCESS_DEPLOY_COUNT, query.count());
  assertEquals(PROCESS_DEPLOY_COUNT, query.list().size());
  try {
    query.singleResult();
    fail();
  } catch (ActivitiException e) {
    // Exception is expected
  }
}
 
Example #16
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByProcessDefinitionKeyMultipleResults() {
  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY);
  assertEquals(PROCESS_DEFINITION_KEY_DEPLOY_COUNT, query.count());
  assertEquals(PROCESS_DEFINITION_KEY_DEPLOY_COUNT, query.list().size());

  try {
    query.singleResult();
    fail();
  } catch (ActivitiException e) {
    // Exception is expected
  }
}
 
Example #17
Source File: ActivitiKit.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * 查询运行时 流程实例
 *
 * @param processInstanceId       流程实例id
 * @param includeProcessVariables 是否包含流程变量
 * @return 流程实例
 */
public static ProcessInstance getRuntimeProcessInstance(String processInstanceId, boolean includeProcessVariables) {
    ProcessInstanceQuery query = getRuntimeService()
            .createProcessInstanceQuery()
            .processInstanceId(processInstanceId);
    if (includeProcessVariables) {
        query.includeProcessVariables();
    }
    return query.singleResult();
}
 
Example #18
Source File: ProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessInstanceQuery active() {
    if (inOrStatement) {
        this.currentOrQueryObject.suspensionState = SuspensionState.ACTIVE;
    } else {
        this.suspensionState = SuspensionState.ACTIVE;
    }
    return this;
}
 
Example #19
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryVariablesUpdatedToNullValue() {
  // Start process instance with different types of variables
  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put("longVar", 928374L);
  variables.put("shortVar", (short) 123);
  variables.put("integerVar", 1234);
  variables.put("stringVar", "coca-cola");
  variables.put("dateVar", new Date());
  variables.put("booleanVar", true);
  variables.put("nullVar", null);
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);

  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().variableValueEquals("longVar", null).variableValueEquals("shortVar", null).variableValueEquals("integerVar", null)
      .variableValueEquals("stringVar", null).variableValueEquals("booleanVar", null).variableValueEquals("dateVar", null);

  ProcessInstanceQuery notQuery = runtimeService.createProcessInstanceQuery().variableValueNotEquals("longVar", null).variableValueNotEquals("shortVar", null)
      .variableValueNotEquals("integerVar", null).variableValueNotEquals("stringVar", null).variableValueNotEquals("booleanVar", null).variableValueNotEquals("dateVar", null);

  assertNull(query.singleResult());
  assertNotNull(notQuery.singleResult());

  // Set all existing variables values to null
  runtimeService.setVariable(processInstance.getId(), "longVar", null);
  runtimeService.setVariable(processInstance.getId(), "shortVar", null);
  runtimeService.setVariable(processInstance.getId(), "integerVar", null);
  runtimeService.setVariable(processInstance.getId(), "stringVar", null);
  runtimeService.setVariable(processInstance.getId(), "dateVar", null);
  runtimeService.setVariable(processInstance.getId(), "nullVar", null);
  runtimeService.setVariable(processInstance.getId(), "booleanVar", null);

  Execution queryResult = query.singleResult();
  assertNotNull(queryResult);
  assertEquals(processInstance.getId(), queryResult.getId());
  assertNull(notQuery.singleResult());
}
 
Example #20
Source File: ProcessInstanceQueryAndWithExceptionTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryWithException() throws InterruptedException{
  ProcessInstance processNoException = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_NO_EXCEPTION);
  
  ProcessInstanceQuery queryNoException = runtimeService.createProcessInstanceQuery();
  assertEquals(1, queryNoException.count());
  assertEquals(1, queryNoException.list().size());
  assertEquals(processNoException.getId(), queryNoException.list().get(0).getId());

  ProcessInstanceQuery queryWithException = runtimeService.createProcessInstanceQuery();
  assertEquals(0, queryWithException.withJobException().count());
  assertEquals(0, queryWithException.withJobException().list().size());
  
  ProcessInstance processWithException1 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1);
  TimerJobQuery jobQuery1 = managementService.createTimerJobQuery().processInstanceId(processWithException1.getId());
  assertEquals(1, jobQuery1.withException().count());
  assertEquals(1, jobQuery1.withException().list().size());
  assertEquals(1, queryWithException.withJobException().count());
  assertEquals(1, queryWithException.withJobException().list().size());
  assertEquals(processWithException1.getId(), queryWithException.withJobException().list().get(0).getId());

  ProcessInstance processWithException2 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2);
  TimerJobQuery jobQuery2 = managementService.createTimerJobQuery().processInstanceId(processWithException2.getId());
  assertEquals(2, jobQuery2.withException().count());
  assertEquals(2, jobQuery2.withException().list().size());

  assertEquals(2, queryWithException.withJobException().count());
  assertEquals(2, queryWithException.withJobException().list().size());
  assertEquals(processWithException1.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1).list().get(0).getId());
  assertEquals(processWithException2.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2).list().get(0).getId());
}
 
Example #21
Source File: ProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessInstanceQuery variableValueEquals(String variableName, Object variableValue) {
    if (inOrStatement) {
        currentOrQueryObject.variableValueEquals(variableName, variableValue, false);
        return this;
    } else {
        return variableValueEquals(variableName, variableValue, false);
    }
}
 
Example #22
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryNoSpecificsSingleResult() {
  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
  try { 
    query.singleResult();
    fail();
  } catch (ActivitiException e) {
    // Exception is expected
  }
}
 
Example #23
Source File: ProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessInstanceQuery variableValueNotEqualsIgnoreCase(String name, String value) {
    if (inOrStatement) {
        currentOrQueryObject.variableValueNotEqualsIgnoreCase(name, value, false);
        return this;
    } else {
        return variableValueNotEqualsIgnoreCase(name, value, false);
    }
}
 
Example #24
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByProcessDefinitionKeyMultipleResults() {
  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_DEFINITION_KEY);
  assertEquals(PROCESS_DEFINITION_KEY_DEPLOY_COUNT, query.count());
  assertEquals(PROCESS_DEFINITION_KEY_DEPLOY_COUNT, query.list().size());

  try {
    query.singleResult();
    fail();
  } catch (ActivitiException e) {
    // Exception is expected
  }
}
 
Example #25
Source File: ProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessInstanceQuery variableValueLessThanOrEqual(String name, Object value) {
    if (inOrStatement) {
        currentOrQueryObject.variableValueLessThanOrEqual(name, value, false);
        return this;
    } else {
        return variableValueLessThanOrEqual(name, value, false);
    }
}
 
Example #26
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/activiti5/engine/test/api/runtime/superProcess.bpmn20.xml",
                         "org/activiti5/engine/test/api/runtime/subProcess.bpmn20.xml"})
public void testQueryBySuperProcessInstanceId() {
  ProcessInstance superProcessInstance = runtimeService.startProcessInstanceByKey("subProcessQueryTest");
  
  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().superProcessInstanceId(superProcessInstance.getId());
  ProcessInstance subProcessInstance = query.singleResult();
  assertNotNull(subProcessInstance);
  assertEquals(1, query.list().size());
  assertEquals(1, query.count());
}
 
Example #27
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/activiti5/engine/test/api/runtime/superProcess.bpmn20.xml",
  "org/activiti5/engine/test/api/runtime/subProcess.bpmn20.xml"})
public void testOrQueryBySuperProcessInstanceId() {
  ProcessInstance superProcessInstance = runtimeService.startProcessInstanceByKey("subProcessQueryTest");
  
  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().or().superProcessInstanceId(superProcessInstance.getId()).processDefinitionId("undefined").endOr();
  ProcessInstance subProcessInstance = query.singleResult();
  assertNotNull(subProcessInstance);
  assertEquals(1, query.list().size());
  assertEquals(1, query.count());
}
 
Example #28
Source File: ProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessInstanceQuery processInstanceNameLike(String nameLike) {
    if (inOrStatement) {
        this.currentOrQueryObject.nameLike = nameLike;
    } else {
        this.nameLike = nameLike;
    }
    return this;
}
 
Example #29
Source File: ProcessInstanceQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment(resources={
  "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void testQueryAllVariableTypes() throws Exception {
  Map<String, Object> vars = new HashMap<String, Object>();
  vars.put("nullVar", null);
  vars.put("stringVar", "string");
  vars.put("longVar", 10L);
  vars.put("doubleVar", 1.2);
  vars.put("integerVar", 1234);
  vars.put("booleanVar", true);
  vars.put("shortVar", (short) 123);
  
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
  
  ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery()
    .variableValueEquals("nullVar", null)
    .variableValueEquals("stringVar", "string")
    .variableValueEquals("longVar", 10L)
    .variableValueEquals("doubleVar", 1.2)
    .variableValueEquals("integerVar", 1234)
    .variableValueEquals("booleanVar", true)
    .variableValueEquals("shortVar", (short) 123);
  
  List<ProcessInstance> processInstances = query.list();
  assertNotNull(processInstances);
  assertEquals(1, processInstances.size());
  assertEquals(processInstance.getId(), processInstances.get(0).getId());

  runtimeService.deleteProcessInstance(processInstance.getId(), "test");
}
 
Example #30
Source File: ProcessInstanceQueryAndWithExceptionTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryWithException() throws InterruptedException{
  ProcessInstance processNoException = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_NO_EXCEPTION);
  
  ProcessInstanceQuery queryNoException = runtimeService.createProcessInstanceQuery();
  assertEquals(1, queryNoException.count());
  assertEquals(1, queryNoException.list().size());
  assertEquals(processNoException.getId(), queryNoException.list().get(0).getId());

  ProcessInstanceQuery queryWithException = runtimeService.createProcessInstanceQuery();
  assertEquals(0, queryWithException.withJobException().count());
  assertEquals(0, queryWithException.withJobException().list().size());
  
  ProcessInstance processWithException1 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1);
  TimerJobQuery jobQuery1 = managementService.createTimerJobQuery().processInstanceId(processWithException1.getId());
  assertEquals(1, jobQuery1.withException().count());
  assertEquals(1, jobQuery1.withException().list().size());
  assertEquals(1, queryWithException.withJobException().count());
  assertEquals(1, queryWithException.withJobException().list().size());
  assertEquals(processWithException1.getId(), queryWithException.withJobException().list().get(0).getId());

  ProcessInstance processWithException2 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2);
  TimerJobQuery jobQuery2 = managementService.createTimerJobQuery().processInstanceId(processWithException2.getId());
  assertEquals(2, jobQuery2.withException().count());
  assertEquals(2, jobQuery2.withException().list().size());

  assertEquals(2, queryWithException.withJobException().count());
  assertEquals(2, queryWithException.withJobException().list().size());
  assertEquals(processWithException1.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1).list().get(0).getId());
  assertEquals(processWithException2.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2).list().get(0).getId());
}