@Deployment(resources={"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testStartProcessInstanceByProcessInstanceBuilder(){
  ProcessDefinition processDefinition=repositoryService.createProcessDefinitionQuery().singleResult();
  ProcessInstanceBuilder processInstanceBuilder=runtimeService.createProcessInstanceBuilder();
  ProcessInstance processInstance=processInstanceBuilder.processDefinitionKey("oneTaskProcess").businessKey("123").start();
  assertNotNull(processInstance);
  assertEquals("123",processInstance.getBusinessKey());
  assertEquals(1,runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
  processInstanceBuilder=runtimeService.createProcessInstanceBuilder();
  processInstance=processInstanceBuilder.processDefinitionKey("oneTaskProcess").businessKey("456").variable("var","value").name("processName1").start();
  assertNotNull(processInstance);
  assertEquals(2,runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
  assertEquals("processName1",processInstance.getName());
  assertEquals("456",processInstance.getBusinessKey());
  assertEquals("value",runtimeService.getVariable(processInstance.getId(),"var"));
  processInstanceBuilder=runtimeService.createProcessInstanceBuilder();
  processInstance=processInstanceBuilder.processDefinitionId(processDefinition.getId()).businessKey("789").start();
  assertNotNull(processInstance);
  assertEquals(3,runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
  assertEquals("789",processInstance.getBusinessKey());
  processInstanceBuilder=runtimeService.createProcessInstanceBuilder();
  processInstance=processInstanceBuilder.processDefinitionId(processDefinition.getId()).businessKey("101123").variable("var","value2").start();
  assertNotNull(processInstance);
  assertEquals(4,runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
  assertEquals("value2",runtimeService.getVariable(processInstance.getId(),"var"));
  assertEquals("101123",processInstance.getBusinessKey());
  processInstanceBuilder=runtimeService.createProcessInstanceBuilder();
  processInstance=processInstanceBuilder.processDefinitionId(processDefinition.getId()).businessKey("101124").name("processName2").start();
  assertNotNull(processInstance);
  assertEquals(5,runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
  assertEquals("processName2",processInstance.getName());
  assertEquals("101124",processInstance.getBusinessKey());
}
