JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
managementService.executeJob(jobQuery.singleResult().getId());
HistoricActivityInstanceQuery historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("userTask");
assertEquals(1, historicActivityInstanceQuery.count());
assertNull(historicActivityInstanceQuery.singleResult().getEndTime());
historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("end1");
assertEquals(0, historicActivityInstanceQuery.count());
historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("timer");
assertEquals(1, historicActivityInstanceQuery.count());
assertNotNull(historicActivityInstanceQuery.singleResult().getEndTime());
historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().activityId("end2");
assertEquals(1, historicActivityInstanceQuery.count());
assertNotNull(historicActivityInstanceQuery.singleResult().getEndTime());
}