}
@Deployment(resources={
"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void startProcessInstanceWithBusinessKey() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
// by key
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "123");
assertNotNull(processInstance);
assertEquals("123", processInstance.getBusinessKey());
assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
// by key with variables
processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "456", CollectionUtil.singletonMap("var", "value"));
assertNotNull(processInstance);
assertEquals(2, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
assertEquals("var", runtimeService.getVariable(processInstance.getId(), "var"));
// by id
processInstance = runtimeService.startProcessInstanceById(processDefinition.getId(), "789");
assertNotNull(processInstance);
assertEquals(3, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
// by id with variables
processInstance = runtimeService.startProcessInstanceById(processDefinition.getId(), "101123", CollectionUtil.singletonMap("var", "value2"));
assertNotNull(processInstance);
assertEquals(4, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
assertEquals("var", runtimeService.getVariable(processInstance.getId(), "var"));
}