Package org.activiti.engine.delegate.event

Examples of org.activiti.engine.delegate.event.ActivitiEntityEvent


        assertNotNull(task);
       
        // Create link-comment
        Comment comment = taskService.addComment(task.getId(), null, "comment");
        assertEquals(2, listener.getEventsReceived().size());
        ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
        assertNull(event.getProcessInstanceId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessDefinitionId());
        Comment commentFromEvent = (Comment) event.getEntity();
        assertEquals(comment.getId(), commentFromEvent.getId());
       
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
        assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
        listener.clearEventsReceived();
       
        // Finally, delete comment
        taskService.deleteComment(comment.getId());
        assertEquals(1, listener.getEventsReceived().size());
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
        assertNull(event.getProcessInstanceId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessDefinitionId());
        commentFromEvent = (Comment) event.getEntity();
        assertEquals(comment.getId(), commentFromEvent.getId());
       
      } finally {
        if(task != null && task.getId() != null) {
          taskService.deleteTask(task.getId());
View Full Code Here


      group.setName("name");
      group.setType("type");
      identityService.saveGroup(group);

      assertEquals(2, listener.getEventsReceived().size());
      ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
      assertTrue(event.getEntity() instanceof Group);
      Group groupFromEvent = (Group) event.getEntity();
      assertEquals("fred", groupFromEvent.getId());
      assertNull(event.getProcessDefinitionId());
      assertNull(event.getExecutionId());
      assertNull(event.getProcessInstanceId());
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
      listener.clearEventsReceived();

      // Update Group
      group.setName("Another name");
      identityService.saveGroup(group);
      assertEquals(1, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
      assertTrue(event.getEntity() instanceof Group);
      groupFromEvent = (Group) event.getEntity();
      assertEquals("fred", groupFromEvent.getId());
      assertEquals("Another name", groupFromEvent.getName());
      assertNull(event.getProcessDefinitionId());
      assertNull(event.getExecutionId());
      assertNull(event.getProcessInstanceId());
      listener.clearEventsReceived();

      // Delete Group
      identityService.deleteGroup(group.getId());
     
      assertEquals(1, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
      assertTrue(event.getEntity() instanceof Group);
      groupFromEvent = (Group) event.getEntity();
      assertEquals("fred", groupFromEvent.getId());
      assertNull(event.getProcessDefinitionId());
      assertNull(event.getExecutionId());
      assertNull(event.getProcessInstanceId());
      listener.clearEventsReceived();

    } finally {
      if (group != null && group.getId() != null) {
        identityService.deleteGroup(group.getId());
View Full Code Here

     
      // Check create-event
      assertEquals(2, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
      assertEquals(deployment.getId(), ((Deployment) event.getEntity()).getId());
     
      assertTrue(listener.getEventsReceived().get(1) instanceof ActivitiEntityEvent);
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
      assertEquals(deployment.getId(), ((Deployment) event.getEntity()).getId());
     
      listener.clearEventsReceived();
     
      // Check update event when category is updated
      repositoryService.setDeploymentCategory(deployment.getId(), "test");
      assertEquals(1, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
      assertEquals(deployment.getId(), ((Deployment) event.getEntity()).getId());
      assertEquals("test", ((Deployment) event.getEntity()).getCategory());
      listener.clearEventsReceived();
     
      // Check delete event when category is updated
      repositoryService.deleteDeployment(deployment.getId(), true);
      assertEquals(1, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
      assertEquals(deployment.getId(), ((Deployment) event.getEntity()).getId());
      listener.clearEventsReceived();
     
    } finally {
      if(deployment != null && repositoryService.createDeploymentQuery().deploymentId(deployment.getId()).count() > 0) {
        repositoryService.deleteDeployment(deployment.getId(), true);
View Full Code Here

     
      // Check create-event
      assertEquals(2, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
      assertEquals(processInstance.getId(), ((Execution) event.getEntity()).getId());
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
            assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
            assertEquals(processInstance.getId(), ((Execution) event.getEntity()).getId());
            listener.clearEventsReceived();
     
      // Check update event when suspended/activated
      runtimeService.suspendProcessInstanceById(processInstance.getId());
      runtimeService.activateProcessInstanceById(processInstance.getId());
     
      assertEquals(2, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(processInstance.getId(), ((Execution) event.getEntity()).getId());
      assertEquals(ActivitiEventType.ENTITY_SUSPENDED, event.getType());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_ACTIVATED, event.getType());
      assertEquals(processInstance.getId(), ((Execution) event.getEntity()).getId());
      listener.clearEventsReceived();
     
      // Check update event when process-definition is supended (should cascade suspend/activate all process instances)
      repositoryService.suspendProcessDefinitionById(processInstance.getProcessDefinitionId(), true, null);
      repositoryService.activateProcessDefinitionById(processInstance.getProcessDefinitionId(), true, null);
     
      assertEquals(2, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(processInstance.getId(), ((ProcessInstance) event.getEntity()).getId());
      assertEquals(ActivitiEventType.ENTITY_SUSPENDED, event.getType());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_ACTIVATED, event.getType());
      assertEquals(processInstance.getId(), ((Execution) event.getEntity()).getId());
      listener.clearEventsReceived();
     
      // Check update-event when business-key is updated
      runtimeService.updateBusinessKey(processInstance.getId(), "thekey");
      assertEquals(1, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(processInstance.getId(), ((Execution) event.getEntity()).getId());
      assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
      listener.clearEventsReceived();
     
      runtimeService.deleteProcessInstance(processInstance.getId(), "Testing events");
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
      assertEquals(processInstance.getId(), ((Execution) event.getEntity()).getId());
      listener.clearEventsReceived();
  }
View Full Code Here

    // Add identity link
    runtimeService.addUserIdentityLink(processInstance.getId(), "kermit", "test");
    assertEquals(2, listener.getEventsReceived().size());

    ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
    assertTrue(event.getEntity() instanceof IdentityLink);
    assertEquals(processInstance.getId(), event.getProcessInstanceId());
    assertEquals(processInstance.getId(), event.getExecutionId());
    assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
    IdentityLink link = (IdentityLink) event.getEntity();
    assertEquals("kermit", link.getUserId());
    assertEquals("test", link.getType());
   
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
    assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
   
    listener.clearEventsReceived();

    // Deleting process should delete identity link
    runtimeService.deleteProcessInstance(processInstance.getId(), "test");
    assertEquals(1, listener.getEventsReceived().size());

    event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
    assertTrue(event.getEntity() instanceof IdentityLink);
    link = (IdentityLink) event.getEntity();
    assertEquals("kermit", link.getUserId());
    assertEquals("test", link.getType());
  }
View Full Code Here

    taskService.addCandidateGroup(task.getId(), "sales");
   
    // Three events are received, since the user link on the task also creates an involvment in the process
    assertEquals(6, listener.getEventsReceived().size());

    ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
    assertTrue(event.getEntity() instanceof IdentityLink);
    IdentityLink link = (IdentityLink) event.getEntity();
    assertEquals("kermit", link.getUserId());
    assertEquals("candidate", link.getType());
    assertEquals(task.getId(), link.getTaskId());
    assertEquals(task.getExecutionId(), event.getExecutionId());
    assertEquals(task.getProcessDefinitionId(), event.getProcessDefinitionId());
    assertEquals(task.getProcessInstanceId(), event.getProcessInstanceId());
   
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
    assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
    assertEquals("kermit", link.getUserId());
    assertEquals("candidate", link.getType());
   
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(4);
    assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
    assertTrue(event.getEntity() instanceof IdentityLink);
    link = (IdentityLink) event.getEntity();
    assertEquals("sales", link.getGroupId());
    assertEquals("candidate", link.getType());
    assertEquals(task.getId(), link.getTaskId());
    assertEquals(task.getExecutionId(), event.getExecutionId());
    assertEquals(task.getProcessDefinitionId(), event.getProcessDefinitionId());
    assertEquals(task.getProcessInstanceId(), event.getProcessInstanceId());
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(5);
    assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
    assertEquals("sales", link.getGroupId());
    assertEquals("candidate", link.getType());
   
    listener.clearEventsReceived();

    // Deleting process should delete identity link
    runtimeService.deleteProcessInstance(processInstance.getId(), "test");
    assertEquals(3, listener.getEventsReceived().size());

    event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
    assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
    event = (ActivitiEntityEvent) listener.getEventsReceived().get(2);
    assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
  }
View Full Code Here

    } else {
      assertEquals(entity.getProcessInstanceId(), event.getExecutionId());
    }
   
    assertTrue(event instanceof ActivitiEntityEvent);
    ActivitiEntityEvent entityEvent = (ActivitiEntityEvent) event;
    assertTrue(entityEvent.getEntity() instanceof Job);
    assertEquals(entity.getId(), ((Job) entityEvent.getEntity()).getId());
  }
View Full Code Here

     
      // Check create-event
      assertEquals(2, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
      assertEquals(processDefinition.getId(), ((ProcessDefinition) event.getEntity()).getId());
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
      assertEquals(processDefinition.getId(), ((ProcessDefinition) event.getEntity()).getId());
      listener.clearEventsReceived();
     
      // Check update event when category is updated
      repositoryService.setProcessDefinitionCategory(processDefinition.getId(), "test");
      assertEquals(1, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
      assertEquals(processDefinition.getId(), ((ProcessDefinition) event.getEntity()).getId());
      assertEquals("test", ((ProcessDefinition) event.getEntity()).getCategory());
      listener.clearEventsReceived();
     
      // Check update event when suspended/activated
      repositoryService.suspendProcessDefinitionById(processDefinition.getId());
      repositoryService.activateProcessDefinitionById(processDefinition.getId());
     
      assertEquals(2, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(processDefinition.getId(), ((ProcessDefinition) event.getEntity()).getId());
      assertEquals(ActivitiEventType.ENTITY_SUSPENDED, event.getType());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_ACTIVATED, event.getType());
      assertEquals(processDefinition.getId(), ((ProcessDefinition) event.getEntity()).getId());
      listener.clearEventsReceived();
     
      // Check delete event when category is updated
      repositoryService.deleteDeployment(processDefinition.getDeploymentId(), true);
      deploymentIdFromDeploymentAnnotation = null;
     
      assertEquals(1, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
      assertEquals(processDefinition.getId(), ((ProcessDefinition) event.getEntity()).getId());
      listener.clearEventsReceived();
  }
View Full Code Here

   */
  @Deployment(resources= {"org/activiti/engine/test/bpmn/event/timer/StartTimerEventTest.testDurationStartTimerEvent.bpmn20.xml"})
  public void testTimerStartEventDeployment() {
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.
      createProcessDefinitionQuery().processDefinitionKey("startTimerEventExample").singleResult();
    ActivitiEntityEvent processDefinitionCreated = ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, processDefinition);

    TimerEntity timer = (TimerEntity) managementService.createJobQuery().singleResult();
    ActivitiEntityEvent timerCreated = ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, timer);
    assertSequence(processDefinitionCreated, timerCreated);
    listener.clearEventsReceived();
  }
View Full Code Here

  /**
   * equals is not implemented.
   */
  private boolean isEqual(ActivitiEntityEvent event1, ActivitiEvent activitiEvent) {
    if (activitiEvent instanceof ActivitiEntityEvent && event1.getType().equals(activitiEvent.getType())) {
      ActivitiEntityEvent activitiEntityEvent = (ActivitiEntityEvent) activitiEvent;
      if (activitiEntityEvent.getEntity().getClass().equals(event1.getEntity().getClass())) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.delegate.event.ActivitiEntityEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.