Search in sources :

Example 1 with Attachment

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);
    }
}
Also used : Attachment(org.camunda.bpm.engine.task.Attachment) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) JsonPath(com.jayway.restassured.path.json.JsonPath)

Example 2 with Attachment

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);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Attachment(org.camunda.bpm.engine.task.Attachment) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with Attachment

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;
}
Also used : Attachment(org.camunda.bpm.engine.task.Attachment)

Example 4 with Attachment

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);
}
Also used : Attachment(org.camunda.bpm.engine.task.Attachment) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 5 with 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()));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Attachment(org.camunda.bpm.engine.task.Attachment)

Aggregations

Attachment (org.camunda.bpm.engine.task.Attachment)18 Test (org.junit.Test)8 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Task (org.camunda.bpm.engine.task.Task)6 Deployment (org.camunda.bpm.engine.test.Deployment)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)2 AttachmentDto (org.camunda.bpm.engine.rest.dto.task.AttachmentDto)2 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Matchers.anyString (org.mockito.Matchers.anyString)2 JsonPath (com.jayway.restassured.path.json.JsonPath)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)1 FormPart (org.camunda.bpm.engine.rest.mapper.MultipartFormData.FormPart)1