.formProperties()
.processInstanceId(processInstance.getId())
.orderByFormPropertyId().asc()
.list();
HistoricFormProperty historicProperty1 = (HistoricFormProperty) props.get(0);
assertEquals("formProp1", historicProperty1.getPropertyId());
assertEquals("Activiti rocks", historicProperty1.getPropertyValue());
assertEquals(startedDate, historicProperty1.getTime());
assertEquals(processInstance.getId(), historicProperty1.getProcessInstanceId());
assertNull(historicProperty1.getTaskId());
assertNotNull(historicProperty1.getActivityInstanceId());
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(historicProperty1.getActivityInstanceId()).singleResult();
assertNotNull(historicActivityInstance);
assertEquals("start", historicActivityInstance.getActivityId());
HistoricFormProperty historicProperty2 = (HistoricFormProperty) props.get(1);
assertEquals("formProp2", historicProperty2.getPropertyId());
assertEquals("12345", historicProperty2.getPropertyValue());
assertEquals(startedDate, historicProperty2.getTime());
assertEquals(processInstance.getId(), historicProperty2.getProcessInstanceId());
assertNull(historicProperty2.getTaskId());
assertNotNull(historicProperty2.getActivityInstanceId());
historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(historicProperty2.getActivityInstanceId()).singleResult();
assertNotNull(historicActivityInstance);
assertEquals("start", historicActivityInstance.getActivityId());
HistoricFormProperty historicProperty3 = (HistoricFormProperty) props.get(2);
assertEquals("formProp3", historicProperty3.getPropertyId());
assertEquals("Activiti still rocks!!!", historicProperty3.getPropertyValue());
assertEquals(startedDate, historicProperty3.getTime());
assertEquals(processInstance.getId(), historicProperty3.getProcessInstanceId());
String activityInstanceId = historicProperty3.getActivityInstanceId();
historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(activityInstanceId).singleResult();
assertNotNull(historicActivityInstance);
assertEquals(taskActivityId, historicActivityInstance.getActivityId());
assertNotNull(historicProperty3.getTaskId());
HistoricFormProperty historicProperty4 = (HistoricFormProperty) props.get(3);
assertEquals("formProp4", historicProperty4.getPropertyId());
assertEquals("54321", historicProperty4.getPropertyValue());
assertEquals(startedDate, historicProperty4.getTime());
assertEquals(processInstance.getId(), historicProperty4.getProcessInstanceId());
activityInstanceId = historicProperty4.getActivityInstanceId();
historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityInstanceId(activityInstanceId).singleResult();
assertNotNull(historicActivityInstance);
assertEquals(taskActivityId, historicActivityInstance.getActivityId());
assertNotNull(historicProperty4.getTaskId());
assertEquals(4, props.size());
}