public ActivitiRule activitiRule = new ActivitiRule();
@Test
@Deployment(resources = { "diagrams/Attachment.bpmn" })
public void startProcess() throws Exception {
TaskService taskService = activitiRule.getTaskService();
RuntimeService runtimeService = activitiRule.getRuntimeService();
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("name", "Activiti");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
assertNotNull(processInstance.getId());
System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
Task singleResult = taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult();
String url = "http://labs.mop.com/apache-mirror//ant/binaries/apache-ant-1.8.3-bin.zip";
String attachmentDescription = "ant bin package";
taskService.createAttachment("zip", singleResult.getId(), processInstance.getId(), "apache-ant-1.8.3-bin.zip", attachmentDescription, url);
taskService.complete(singleResult.getId());
List<Attachment> taskAttachments = taskService.getTaskAttachments(singleResult.getId());
assertEquals(1, taskAttachments.size());
HistoryService historyService = activitiRule.getHistoryService();
List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().finished().list();
assertEquals(false, list.isEmpty());