Search in sources :

Example 1 with TaskServiceImpl

use of org.activiti.engine.impl.TaskServiceImpl in project Activiti by Activiti.

the class TaskServiceTest method testTaskAttachmentWithProcessInstanceId.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskAttachmentWithProcessInstanceId() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
        String processInstanceId = processInstance.getId();
        taskService.createAttachment("web page", null, processInstanceId, "weatherforcast", "temperatures and more", "http://weather.com");
        Attachment attachment = taskService.getProcessInstanceAttachments(processInstanceId).get(0);
        assertEquals("weatherforcast", attachment.getName());
        assertEquals("temperatures and more", attachment.getDescription());
        assertEquals("web page", attachment.getType());
        assertEquals(processInstanceId, attachment.getProcessInstanceId());
        assertNull(attachment.getTaskId());
        assertEquals("http://weather.com", attachment.getUrl());
        assertNull(taskService.getAttachmentContent(attachment.getId()));
        // Finally, clean up
        taskService.deleteAttachment(attachment.getId());
        // TODO: Bad API design. Need to fix attachment/comment properly
        ((TaskServiceImpl) taskService).deleteComments(null, processInstanceId);
    }
}
Also used : TaskServiceImpl(org.activiti.engine.impl.TaskServiceImpl) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Attachment(org.activiti.engine.task.Attachment) Deployment(org.activiti.engine.test.Deployment)

Aggregations

TaskServiceImpl (org.activiti.engine.impl.TaskServiceImpl)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Attachment (org.activiti.engine.task.Attachment)1 Deployment (org.activiti.engine.test.Deployment)1