String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId();
runtimeService.deleteProcessInstance(processInstanceId, null);
HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId);
assertEquals(1, processInstanceQuery.count());
HistoricProcessInstance processInstance = processInstanceQuery.singleResult();
assertEquals(processInstanceId, processInstance.getId());
assertEquals("ACTIVITI_DELETED", processInstance.getDeleteReason());
processInstanceQuery = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).deleted();
assertEquals(1, processInstanceQuery.count());