use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class TaskRestServiceInteractionTest method verifyTaskAttachmentValues.
private void verifyTaskAttachmentValues(Attachment mockTaskAttachment, String responseContent, boolean urlExist) {
JsonPath path = from(responseContent);
String returnedId = path.get("id");
String returnedTaskId = path.get("taskId");
String returnedName = path.get("name");
String returnedType = path.get("type");
String returnedDescription = path.get("description");
String returnedUrl = path.get("url");
Attachment mockAttachment = mockTaskAttachments.get(0);
assertEquals(mockAttachment.getId(), returnedId);
assertEquals(mockAttachment.getTaskId(), returnedTaskId);
assertEquals(mockAttachment.getName(), returnedName);
assertEquals(mockAttachment.getType(), returnedType);
assertEquals(mockAttachment.getDescription(), returnedDescription);
if (urlExist) {
assertEquals(mockAttachment.getUrl(), returnedUrl);
}
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class TaskRestServiceInteractionTest method verifyTaskAttachments.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void verifyTaskAttachments(List<Attachment> mockTaskAttachments, Response response) {
List list = response.as(List.class);
assertEquals(1, list.size());
LinkedHashMap<String, String> resourceHashMap = (LinkedHashMap<String, String>) list.get(0);
String returnedId = resourceHashMap.get("id");
String returnedTaskId = resourceHashMap.get("taskId");
String returnedName = resourceHashMap.get("name");
String returnedType = resourceHashMap.get("type");
String returnedDescription = resourceHashMap.get("description");
String returnedUrl = resourceHashMap.get("url");
Attachment mockAttachment = mockTaskAttachments.get(0);
assertEquals(mockAttachment.getId(), returnedId);
assertEquals(mockAttachment.getTaskId(), returnedTaskId);
assertEquals(mockAttachment.getName(), returnedName);
assertEquals(mockAttachment.getType(), returnedType);
assertEquals(mockAttachment.getDescription(), returnedDescription);
assertEquals(mockAttachment.getUrl(), returnedUrl);
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class MockProvider method createMockTaskAttachment.
// task attachment
public static Attachment createMockTaskAttachment() {
Attachment mockAttachment = mock(Attachment.class);
when(mockAttachment.getId()).thenReturn(EXAMPLE_TASK_ATTACHMENT_ID);
when(mockAttachment.getName()).thenReturn(EXAMPLE_TASK_ATTACHMENT_NAME);
when(mockAttachment.getDescription()).thenReturn(EXAMPLE_TASK_ATTACHMENT_DESCRIPTION);
when(mockAttachment.getType()).thenReturn(EXAMPLE_TASK_ATTACHMENT_TYPE);
when(mockAttachment.getUrl()).thenReturn(EXAMPLE_TASK_ATTACHMENT_URL);
when(mockAttachment.getTaskId()).thenReturn(EXAMPLE_TASK_ID);
when(mockAttachment.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID);
return mockAttachment;
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class TaskAttachmentResourceImpl method getAttachment.
@Override
public AttachmentDto getAttachment(String attachmentId) {
ensureHistoryEnabled(Status.NOT_FOUND);
Attachment attachment = engine.getTaskService().getTaskAttachment(taskId, attachmentId);
if (attachment == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Task attachment with id " + attachmentId + " does not exist for task id '" + taskId + "'.");
}
return AttachmentDto.fromAttachment(attachment);
}
use of org.camunda.bpm.engine.task.Attachment in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteTest method createTaskAttachmentWithContent.
private void createTaskAttachmentWithContent(String taskId) {
taskService.createAttachment("web page", taskId, null, "weatherforcast", "temperatures and more", new ByteArrayInputStream("someContent".getBytes()));
List<Attachment> taskAttachments = taskService.getTaskAttachments(taskId);
assertEquals(1, taskAttachments.size());
assertNotNull(taskService.getAttachmentContent(taskAttachments.get(0).getId()));
}
Aggregations