Search in sources :

Example 1 with Event

use of org.camunda.bpm.engine.task.Event in project camunda-bpm-platform by camunda.

the class TaskEventsTest method testDeleteAttachmentEvents.

public void testDeleteAttachmentEvents() {
    // initially there are no task events
    assertTrue(taskService.getTaskEvents(task.getId()).isEmpty());
    identityService.setAuthenticatedUserId(JONNY);
    Attachment attachment = taskService.createAttachment(IMAGE_PNG, task.getId(), null, IMAGE_NAME, IMAGE_DESC, IMAGE_URL);
    ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + 5000));
    taskService.deleteAttachment(attachment.getId());
    // now there is a task event created
    List<Event> events = taskService.getTaskEvents(task.getId());
    assertEquals(2, events.size());
    Event event = events.get(0);
    assertEquals(1, event.getMessageParts().size());
    assertEquals(IMAGE_NAME, event.getMessageParts().get(0));
    assertEquals(task.getId(), event.getTaskId());
    assertEquals(ACTION_DELETE_ATTACHMENT, event.getAction());
    assertEquals(IMAGE_NAME, event.getMessage());
    assertEquals(null, event.getProcessInstanceId());
    assertNotNull(event.getTime().getTime() <= ClockUtil.getCurrentTime().getTime());
    assertNoCommentsForTask();
}
Also used : Event(org.camunda.bpm.engine.task.Event) Attachment(org.camunda.bpm.engine.task.Attachment) Date(java.util.Date)

Example 2 with Event

use of org.camunda.bpm.engine.task.Event in project camunda-bpm-platform by camunda.

the class TaskEventsTest method testAddUserLinkEvents.

public void testAddUserLinkEvents() {
    // initially there are no task events
    assertTrue(taskService.getTaskEvents(task.getId()).isEmpty());
    taskService.addCandidateUser(task.getId(), JONNY);
    // now there is a task event created
    List<Event> events = taskService.getTaskEvents(task.getId());
    assertEquals(1, events.size());
    Event event = events.get(0);
    assertEquals(JONNY, event.getMessageParts().get(0));
    assertEquals(CANDIDATE, event.getMessageParts().get(1));
    assertEquals(task.getId(), event.getTaskId());
    assertEquals(ACTION_ADD_USER_LINK, event.getAction());
    assertEquals(JONNY + CommentEntity.MESSAGE_PARTS_MARKER + CANDIDATE, event.getMessage());
    assertEquals(null, event.getProcessInstanceId());
    assertNotNull(event.getTime().getTime() <= ClockUtil.getCurrentTime().getTime());
    assertNoCommentsForTask();
}
Also used : Event(org.camunda.bpm.engine.task.Event)

Example 3 with Event

use of org.camunda.bpm.engine.task.Event in project camunda-bpm-platform by camunda.

the class TaskEventsTest method testDeleteGroupLinkEvents.

public void testDeleteGroupLinkEvents() {
    // initially there are no task events
    assertTrue(taskService.getTaskEvents(task.getId()).isEmpty());
    taskService.addCandidateGroup(task.getId(), ACCOUNTING);
    ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + 5000));
    taskService.deleteCandidateGroup(task.getId(), ACCOUNTING);
    // now there is a task event created
    List<Event> events = taskService.getTaskEvents(task.getId());
    assertEquals(2, events.size());
    Event event = events.get(0);
    assertEquals(ACCOUNTING, event.getMessageParts().get(0));
    assertEquals(CANDIDATE, event.getMessageParts().get(1));
    assertEquals(task.getId(), event.getTaskId());
    assertEquals(ACTION_DELETE_GROUP_LINK, event.getAction());
    assertEquals(ACCOUNTING + CommentEntity.MESSAGE_PARTS_MARKER + CANDIDATE, event.getMessage());
    assertEquals(null, event.getProcessInstanceId());
    assertNotNull(event.getTime().getTime() <= ClockUtil.getCurrentTime().getTime());
    assertNoCommentsForTask();
}
Also used : Event(org.camunda.bpm.engine.task.Event) Date(java.util.Date)

Example 4 with Event

use of org.camunda.bpm.engine.task.Event in project camunda-bpm-platform by camunda.

the class TaskIdentityLinksTest method testCandidateGroupLink.

@Deployment(resources = "org/camunda/bpm/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testCandidateGroupLink() {
    try {
        identityService.setAuthenticatedUserId("demo");
        runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
        String taskId = taskService.createTaskQuery().singleResult().getId();
        taskService.addCandidateGroup(taskId, "muppets");
        List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
        IdentityLink identityLink = identityLinks.get(0);
        assertEquals("muppets", identityLink.getGroupId());
        assertNull("kermit", identityLink.getUserId());
        assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
        assertEquals(taskId, identityLink.getTaskId());
        assertEquals(1, identityLinks.size());
        if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_FULL) {
            List<Event> taskEvents = taskService.getTaskEvents(taskId);
            assertEquals(1, taskEvents.size());
            Event taskEvent = taskEvents.get(0);
            assertEquals(Event.ACTION_ADD_GROUP_LINK, taskEvent.getAction());
            List<String> taskEventMessageParts = taskEvent.getMessageParts();
            assertEquals("muppets", taskEventMessageParts.get(0));
            assertEquals(IdentityLinkType.CANDIDATE, taskEventMessageParts.get(1));
            assertEquals(2, taskEventMessageParts.size());
        }
        taskService.deleteCandidateGroup(taskId, "muppets");
        if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_FULL) {
            List<Event> taskEvents = taskService.getTaskEvents(taskId);
            Event taskEvent = findTaskEvent(taskEvents, Event.ACTION_DELETE_GROUP_LINK);
            assertEquals(Event.ACTION_DELETE_GROUP_LINK, taskEvent.getAction());
            List<String> taskEventMessageParts = taskEvent.getMessageParts();
            assertEquals("muppets", taskEventMessageParts.get(0));
            assertEquals(IdentityLinkType.CANDIDATE, taskEventMessageParts.get(1));
            assertEquals(2, taskEventMessageParts.size());
            assertEquals(2, taskEvents.size());
        }
        assertEquals(0, taskService.getIdentityLinksForTask(taskId).size());
    } finally {
        identityService.clearAuthentication();
    }
}
Also used : Event(org.camunda.bpm.engine.task.Event) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with Event

use of org.camunda.bpm.engine.task.Event in project camunda-bpm-platform by camunda.

the class TaskEventsTest method testDeleteUserLinkEvents.

public void testDeleteUserLinkEvents() {
    // initially there are no task events
    assertTrue(taskService.getTaskEvents(task.getId()).isEmpty());
    taskService.addCandidateUser(task.getId(), JONNY);
    ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + 5000));
    taskService.deleteCandidateUser(task.getId(), JONNY);
    // now there is a task event created
    List<Event> events = taskService.getTaskEvents(task.getId());
    assertEquals(2, events.size());
    Event event = events.get(0);
    assertEquals(JONNY, event.getMessageParts().get(0));
    assertEquals(CANDIDATE, event.getMessageParts().get(1));
    assertEquals(task.getId(), event.getTaskId());
    assertEquals(ACTION_DELETE_USER_LINK, event.getAction());
    assertEquals(JONNY + CommentEntity.MESSAGE_PARTS_MARKER + CANDIDATE, event.getMessage());
    assertEquals(null, event.getProcessInstanceId());
    assertNotNull(event.getTime().getTime() <= ClockUtil.getCurrentTime().getTime());
    assertNoCommentsForTask();
}
Also used : Event(org.camunda.bpm.engine.task.Event) Date(java.util.Date)

Aggregations

Event (org.camunda.bpm.engine.task.Event)7 Date (java.util.Date)3 Attachment (org.camunda.bpm.engine.task.Attachment)1 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)1 Deployment (org.camunda.bpm.engine.test.Deployment)1