use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method createProcessInstanceAttachmentWithContent.
private void createProcessInstanceAttachmentWithContent(String processInstanceId) {
taskService.createAttachment("web page", null, processInstanceId, "weatherforcast", "temperatures and more", new ByteArrayInputStream("someContent".getBytes()));
List<Attachment> taskAttachments = taskService.getProcessInstanceAttachments(processInstanceId);
assertEquals(1, taskAttachments.size());
assertNotNull(taskService.getAttachmentContent(taskAttachments.get(0).getId()));
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetTaskAttachmentWithNullParameters.
@Test
public void testGetTaskAttachmentWithNullParameters() {
int historyLevel = processEngineConfiguration.getHistoryLevel().getId();
if (historyLevel > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
Attachment attachment = taskService.getTaskAttachment(null, null);
assertNull(attachment);
}
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetTaskAttachmentContentByTaskIdAndAttachmentId.
@Test
public void testGetTaskAttachmentContentByTaskIdAndAttachmentId() {
int historyLevel = processEngineConfiguration.getHistoryLevel().getId();
if (historyLevel > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
// create and save task
Task task = taskService.newTask();
taskService.saveTask(task);
String taskId = task.getId();
// Fetch the task again and update
// add attachment
Attachment attachment = taskService.createAttachment("web page", taskId, "someprocessinstanceid", "weatherforcast", "temperatures and more", new ByteArrayInputStream("someContent".getBytes()));
String attachmentId = attachment.getId();
// get attachment for taskId and attachmentId
InputStream taskAttachmentContent = taskService.getTaskAttachmentContent(taskId, attachmentId);
assertNotNull(taskAttachmentContent);
byte[] byteContent = IoUtil.readInputStream(taskAttachmentContent, "weatherforcast");
assertEquals("someContent", new String(byteContent));
taskService.deleteTask(taskId, true);
}
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testTaskAttachments.
@Test
public void testTaskAttachments() {
int historyLevel = processEngineConfiguration.getHistoryLevel().getId();
if (historyLevel > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
Task task = taskService.newTask();
task.setOwner("johndoe");
taskService.saveTask(task);
String taskId = task.getId();
identityService.setAuthenticatedUserId("johndoe");
// Fetch the task again and update
taskService.createAttachment("web page", taskId, "someprocessinstanceid", "weatherforcast", "temperatures and more", "http://weather.com");
Attachment attachment = taskService.getTaskAttachments(taskId).get(0);
assertEquals("weatherforcast", attachment.getName());
assertEquals("temperatures and more", attachment.getDescription());
assertEquals("web page", attachment.getType());
assertEquals(taskId, attachment.getTaskId());
assertEquals("someprocessinstanceid", attachment.getProcessInstanceId());
assertEquals("http://weather.com", attachment.getUrl());
assertNull(taskService.getAttachmentContent(attachment.getId()));
// Finally, clean up
taskService.deleteTask(taskId);
assertEquals(0, taskService.getTaskComments(taskId).size());
assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskId(taskId).list().size());
taskService.deleteTask(taskId, true);
}
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testCreateTaskAttachmentWithNullTaskId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
@Test
public void testCreateTaskAttachmentWithNullTaskId() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
Attachment attachment = taskService.createAttachment("web page", null, processInstance.getId(), "weatherforcast", "temperatures and more", new ByteArrayInputStream("someContent".getBytes()));
Attachment fetched = taskService.getAttachment(attachment.getId());
assertThat(fetched, is(notNullValue()));
assertThat(fetched.getTaskId(), is(nullValue()));
assertThat(fetched.getProcessInstanceId(), is(notNullValue()));
taskService.deleteAttachment(attachment.getId());
}
Aggregations