Package org.activiti.engine.runtime

Examples of org.activiti.engine.runtime.Execution


        .singleResult();
    assertNotNull(task);
    taskService.complete(task.getId());
   
    // Subprocess execution is created
    Execution execution = runtimeService.createExecutionQuery().parentId(processInstance.getId()).singleResult();
    assertNotNull(execution);
    assertEquals(5, listener.getEventsReceived().size());
    activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ACTIVITY_COMPLETED, activityEvent.getType());
    assertEquals("shipOrder", activityEvent.getActivityId());
    assertEquals(processInstance.getId(), activityEvent.getExecutionId());
    assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
   
    activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(1);
    assertEquals(ActivitiEventType.ACTIVITY_STARTED, activityEvent.getType());
    assertEquals("subProcess", activityEvent.getActivityId());
    assertEquals(execution.getId(), activityEvent.getExecutionId());
    assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
   
    activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(2);
    assertEquals(ActivitiEventType.ACTIVITY_STARTED, activityEvent.getType());
    assertEquals("subProcessStart", activityEvent.getActivityId());
    assertEquals(execution.getId(), activityEvent.getExecutionId());
    assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
   
    activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(3);
    assertEquals(ActivitiEventType.ACTIVITY_COMPLETED, activityEvent.getType());
    assertEquals("subProcessStart", activityEvent.getActivityId());
    assertEquals(execution.getId(), activityEvent.getExecutionId());
    assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
   
    activityEvent = (ActivitiActivityEvent) listener.getEventsReceived().get(4);
    assertEquals(ActivitiEventType.ACTIVITY_STARTED, activityEvent.getType());
    assertEquals("subTask", activityEvent.getActivityId());
    assertEquals(execution.getId(), activityEvent.getExecutionId());
    assertEquals(processInstance.getProcessInstanceId(), activityEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), activityEvent.getProcessDefinitionId());
    listener.clearEventsReceived();
   
    // Check gateway and intermediate throw event
    Task subTask = taskService.createTaskQuery().executionId(execution.getId()).singleResult();
    assertNotNull(subTask);
   
    taskService.complete(subTask.getId());
   
    assertEquals(10, listener.getEventsReceived().size());
View Full Code Here


    // intermediate catching signal-event
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalProcess");
    assertNotNull(processInstance);

    // Check regular signal through API
    Execution executionWithSignal = runtimeService.createExecutionQuery().activityId("receivePayment").singleResult();
    assertNotNull(executionWithSignal);

    runtimeService.signal(executionWithSignal.getId());
    assertEquals(1, listener.getEventsReceived().size());
    assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiSignalEvent);
    ActivitiSignalEvent signalEvent = (ActivitiSignalEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ACTIVITY_SIGNALED, signalEvent.getType());
    assertEquals("receivePayment", signalEvent.getActivityId());
    assertEquals(executionWithSignal.getId(), signalEvent.getExecutionId());
    assertEquals(executionWithSignal.getProcessInstanceId(), signalEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
    assertNull(signalEvent.getSignalName());
    assertNull(signalEvent.getSignalData());
    listener.clearEventsReceived();

    // Check signal using event, and pass in additional payload
    Execution executionWithSignalEvent = runtimeService.createExecutionQuery().activityId("shipOrder").singleResult();
    runtimeService.signalEventReceived("alert", executionWithSignalEvent.getId(),
        Collections.singletonMap("test", (Object) "test"));
    assertEquals(1, listener.getEventsReceived().size());
    assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiSignalEvent);
    signalEvent = (ActivitiSignalEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ACTIVITY_SIGNALED, signalEvent.getType());
    assertEquals("shipOrder", signalEvent.getActivityId());
    assertEquals(executionWithSignalEvent.getId(), signalEvent.getExecutionId());
    assertEquals(executionWithSignalEvent.getProcessInstanceId(), signalEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
    assertEquals("alert", signalEvent.getSignalName());
    assertNotNull(signalEvent.getSignalData());
    listener.clearEventsReceived();
   
View Full Code Here

    assertNotNull(processInstance);

    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task);

    Execution executionWithSignalEvent = runtimeService.createExecutionQuery().activityId("shipOrder").singleResult();

    taskService.complete(task.getId());
    assertEquals(1L, listener.getEventsReceived().size());

    assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiSignalEvent);
    ActivitiSignalEvent signalEvent = (ActivitiSignalEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ACTIVITY_SIGNALED, signalEvent.getType());
    assertEquals("shipOrder", signalEvent.getActivityId());
    assertEquals(executionWithSignalEvent.getId(), signalEvent.getExecutionId());
    assertEquals(executionWithSignalEvent.getProcessInstanceId(), signalEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
    assertEquals("alert", signalEvent.getSignalName());
    assertNull(signalEvent.getSignalData());
  }
View Full Code Here

  @RequestMapping(value="/runtime/executions/{executionId}/variables", method = RequestMethod.GET, produces="application/json")
  public List<RestVariable> getVariables(@PathVariable String executionId,
      @RequestParam(value="scope", required=false) String scope, HttpServletRequest request) {
   
    Execution execution = getExecutionFromRequest(executionId);
    return processVariables(execution, scope, RestResponseFactory.VARIABLE_EXECUTION, getServerRootUrl(request));
  }
View Full Code Here

  @Deployment
  public void testActivityMessageEvents() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageProcess");
    assertNotNull(processInstance);

    Execution executionWithMessage = runtimeService.createExecutionQuery().activityId("shipOrder").singleResult();
    assertNotNull(executionWithMessage);

    runtimeService.messageEventReceived("messageName", executionWithMessage.getId());
    assertEquals(2, listener.getEventsReceived().size());

    // First, a message-event is expected
    assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiMessageEvent);
    ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED, messageEvent.getType());
    assertEquals("shipOrder", messageEvent.getActivityId());
    assertEquals(executionWithMessage.getId(), messageEvent.getExecutionId());
    assertEquals(executionWithMessage.getProcessInstanceId(), messageEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), messageEvent.getProcessDefinitionId());
    assertEquals("messageName", messageEvent.getMessageName());
    assertNull(messageEvent.getMessageData());

    // Next, an signal-event is expected, as a result of the message
    assertTrue(listener.getEventsReceived().get(1) instanceof ActivitiSignalEvent);
    ActivitiSignalEvent signalEvent = (ActivitiSignalEvent) listener.getEventsReceived().get(1);
    assertEquals(ActivitiEventType.ACTIVITY_SIGNALED, signalEvent.getType());
    assertEquals("shipOrder", signalEvent.getActivityId());
    assertEquals(executionWithMessage.getId(), signalEvent.getExecutionId());
    assertEquals(executionWithMessage.getProcessInstanceId(), signalEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
    assertEquals("messageName", signalEvent.getSignalName());
    assertNull(signalEvent.getSignalData());
   
    assertDatabaseEventPresent(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
View Full Code Here

 
  @RequestMapping(value="/runtime/executions/{executionId}/variables", method = RequestMethod.PUT, produces="application/json")
  public Object createOrUpdateExecutionVariable(@PathVariable String executionId,
      HttpServletRequest request, HttpServletResponse response) {
   
    Execution execution = getExecutionFromRequest(executionId);
    return createExecutionVariable(execution, true, RestResponseFactory.VARIABLE_EXECUTION,
        getServerRootUrl(request), request, response);
  }
View Full Code Here

 
  @RequestMapping(value="/runtime/executions/{executionId}/variables", method = RequestMethod.POST, produces="application/json")
  public Object createExecutionVariable(@PathVariable String executionId,
      HttpServletRequest request, HttpServletResponse response) {
   
    Execution execution = getExecutionFromRequest(executionId);
    return createExecutionVariable(execution, false, RestResponseFactory.VARIABLE_EXECUTION,
        getServerRootUrl(request), request, response);
  }
View Full Code Here

        getServerRootUrl(request), request, response);
  }
 
  @RequestMapping(value="/runtime/executions/{executionId}/variables", method = RequestMethod.DELETE)
  public void deleteLocalVariables(@PathVariable String executionId, HttpServletResponse response) {
    Execution execution = getExecutionFromRequest(executionId);
    deleteAllLocalVariables(execution, response);
  }
View Full Code Here

  @Deployment
  public void testActivityMessageEventsInEventSubprocess() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageProcess");
    assertNotNull(processInstance);

    Execution executionWithMessage = runtimeService.createExecutionQuery().activityId("shipOrder").singleResult();
    assertNotNull(executionWithMessage);

    runtimeService.messageEventReceived("messageName", executionWithMessage.getId());

    // Only a message-event should be present, no signal-event, since the
    // event-subprocess is
    // not signaled, but executed instead
    assertEquals(1, listener.getEventsReceived().size());

    // A message-event is expected
    assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiMessageEvent);
    ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED, messageEvent.getType());
    assertEquals("catchMessage", messageEvent.getActivityId());
    assertEquals(executionWithMessage.getId(), messageEvent.getExecutionId());
    assertEquals(executionWithMessage.getProcessInstanceId(), messageEvent.getProcessInstanceId());
    assertEquals(processInstance.getProcessDefinitionId(), messageEvent.getProcessDefinitionId());
    assertEquals("messageName", messageEvent.getMessageName());
    assertNull(messageEvent.getMessageData());
  }
View Full Code Here

  }
 
  @Deployment
  public void testCompetingJoins() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("CompetingJoinsProcess");
    Execution execution1 = runtimeService
      .createExecutionQuery()
      .processInstanceId(processInstance.getId())
      .activityId("wait1")
      .singleResult();

    Execution execution2 = runtimeService
      .createExecutionQuery()
      .processInstanceId(processInstance.getId())
      .activityId("wait2")
      .singleResult();

    log.debug("test thread starts thread one");
    SignalThread threadOne = new SignalThread(execution1.getId());
    threadOne.startAndWaitUntilControlIsReturned();
   
    log.debug("test thread continues to start thread two");
    SignalThread threadTwo = new SignalThread(execution2.getId());
    threadTwo.startAndWaitUntilControlIsReturned();

    log.debug("test thread notifies thread 1");
    threadOne.proceedAndWaitTillDone();
    assertNull(threadOne.exception);
View Full Code Here

TOP

Related Classes of org.activiti.engine.runtime.Execution

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.