use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testSaveAttachment.
@Test
public void testSaveAttachment() {
int historyLevel = processEngineConfiguration.getHistoryLevel().getId();
if (historyLevel > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) {
// given
Task task = taskService.newTask();
taskService.saveTask(task);
String attachmentType = "someAttachment";
String processInstanceId = "someProcessInstanceId";
String attachmentName = "attachmentName";
String attachmentDescription = "attachmentDescription";
String url = "http://camunda.org";
Attachment attachment = taskService.createAttachment(attachmentType, task.getId(), processInstanceId, attachmentName, attachmentDescription, url);
// when
attachment.setDescription("updatedDescription");
attachment.setName("updatedName");
taskService.saveAttachment(attachment);
// then
Attachment fetchedAttachment = taskService.getAttachment(attachment.getId());
assertEquals(attachment.getId(), fetchedAttachment.getId());
assertEquals(attachmentType, fetchedAttachment.getType());
assertEquals(task.getId(), fetchedAttachment.getTaskId());
assertEquals(processInstanceId, fetchedAttachment.getProcessInstanceId());
assertEquals("updatedName", fetchedAttachment.getName());
assertEquals("updatedDescription", fetchedAttachment.getDescription());
assertEquals(url, fetchedAttachment.getUrl());
taskService.deleteTask(task.getId(), true);
}
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testTaskAttachmentByTaskIdAndAttachmentId.
@Test
public void testTaskAttachmentByTaskIdAndAttachmentId() {
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", "http://weather.com");
String attachmentId = attachment.getId();
// get attachment for taskId and attachmentId
attachment = taskService.getTaskAttachment(taskId, attachmentId);
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()));
// delete attachment for taskId and attachmentId
taskService.deleteTaskAttachment(taskId, attachmentId);
// check if attachment deleted
assertNull(taskService.getTaskAttachment(taskId, attachmentId));
taskService.deleteTask(taskId, true);
}
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class UserOperationLogQueryTest method createLogEntries.
/**
* start process and operate on userTask to create some log entries for the query tests
*/
private void createLogEntries() {
ClockUtil.setCurrentTime(yesterday);
// create a process with a userTask and work with it
process = runtimeService.startProcessInstanceByKey("oneTaskProcess");
execution = processEngine.getRuntimeService().createExecutionQuery().processInstanceId(process.getId()).singleResult();
processTaskId = taskService.createTaskQuery().singleResult().getId();
// user "icke" works on the process userTask
identityService.setAuthenticatedUserId("icke");
// create and remove some links
taskService.addCandidateUser(processTaskId, "er");
taskService.deleteCandidateUser(processTaskId, "er");
taskService.addCandidateGroup(processTaskId, "wir");
taskService.deleteCandidateGroup(processTaskId, "wir");
// assign and reassign the userTask
ClockUtil.setCurrentTime(today);
taskService.setOwner(processTaskId, "icke");
taskService.claim(processTaskId, "icke");
taskService.setAssignee(processTaskId, "er");
// change priority of task
taskService.setPriority(processTaskId, 10);
// add and delete an attachment
Attachment attachment = taskService.createAttachment("image/ico", processTaskId, process.getId(), "favicon.ico", "favicon", "http://camunda.com/favicon.ico");
taskService.deleteAttachment(attachment.getId());
// complete the userTask to finish the process
taskService.complete(processTaskId);
assertProcessEnded(process.getId());
// user "er" works on the process userTask
identityService.setAuthenticatedUserId("er");
// create a standalone userTask
userTask = taskService.newTask();
userTask.setName("to do");
taskService.saveTask(userTask);
// change some properties manually to create an update event
ClockUtil.setCurrentTime(tomorrow);
userTask.setDescription("desc");
userTask.setOwner("icke");
userTask.setAssignee("er");
userTask.setDueDate(new Date());
taskService.saveTask(userTask);
// complete the userTask
taskService.complete(userTask.getId());
}
Aggregations