Package org.activiti.engine.runtime

Examples of org.activiti.engine.runtime.Execution


  /**
   * Test signalling a single execution, without signal name.
   */
  @Deployment(resources = {"org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-signal.bpmn20.xml"})
  public void testSignalExecution() throws Exception {
    Execution signalExecution = runtimeService.startProcessInstanceByKey("processOne");
    assertNotNull(signalExecution);
    assertEquals("waitState", signalExecution.getActivityId());
   
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "signal");

    // Signalling one causes process to move on to second signal and execution is not finished yet
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
        RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, signalExecution.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertEquals("anotherWaitState", responseNode.get("activityId").textValue());
    assertEquals("anotherWaitState", runtimeService.createExecutionQuery().executionId(signalExecution.getId()).singleResult().getActivityId());
   
    // Signalling again causes process to end
    response = executeRequest(httpPut, HttpStatus.SC_NO_CONTENT);
    closeResponse(response);
   
    // Check if process is actually ended
    assertNull(runtimeService.createExecutionQuery().executionId(signalExecution.getId()).singleResult());
  }
View Full Code Here


    EventSubscriptionEntity subscription = newEventSubscriptionQuery()
      .processInstanceId(processInstance.getId())
      .singleResult();
    assertNotNull(subscription);
   
    Execution executionWaitingForSignal = runtimeService.createExecutionQuery()
      .activityId("signalEvent")
      .processInstanceId(processInstance.getId())
      .singleResult();
   
    // test query by execution id
    EventSubscriptionEntity signalSubscription = newEventSubscriptionQuery()
      .executionId(executionWaitingForSignal.getId())
      .singleResult();
    assertNotNull(signalSubscription);
   
    assertEquals(signalSubscription, subscription);
   
View Full Code Here

  /**
   * Test signalling a single execution, without signal name.
   */
  @Deployment(resources = {"org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-signal-event.bpmn20.xml"})
  public void testSignalEventExecution() throws Exception {
    Execution signalExecution = runtimeService.startProcessInstanceByKey("processOne");
    assertNotNull(signalExecution);
   
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "signalEventReceived");
    requestNode.put("signalName", "unexisting");
   
    Execution waitingExecution = runtimeService.createExecutionQuery().activityId("waitState").singleResult();
    assertNotNull(waitingExecution);
   
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
        RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, waitingExecution.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_INTERNAL_SERVER_ERROR);
    closeResponse(response);
   
    requestNode.put("signalName", "alert");
   
    // Sending signal event causes the execution to end (scope-execution for the catching event)
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    response = executeRequest(httpPut, HttpStatus.SC_NO_CONTENT);
    closeResponse(response);
   
    // Check if process is moved on to the other wait-state
    waitingExecution = runtimeService.createExecutionQuery().activityId("anotherWaitState").singleResult();
    assertNotNull(waitingExecution);
    assertEquals(signalExecution.getId(), waitingExecution.getId());
   
  }
View Full Code Here

  /**
   * Test signalling a single execution, with signal event.
   */
  @Deployment(resources = {"org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-signal-event.bpmn20.xml"})
  public void testSignalEventExecutionWithvariables() throws Exception {
    Execution signalExecution = runtimeService.startProcessInstanceByKey("processOne");
    assertNotNull(signalExecution);
   
    ArrayNode variables = objectMapper.createArrayNode();
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "signalEventReceived");
    requestNode.put("signalName", "alert");
    requestNode.put("variables", variables);
   
    ObjectNode varNode = objectMapper.createObjectNode();
    variables.add(varNode);
    varNode.put("name", "myVar");
    varNode.put("value", "Variable set when signal event is receieved");
   
    Execution waitingExecution = runtimeService.createExecutionQuery().activityId("waitState").singleResult();
    assertNotNull(waitingExecution);
   
    // Sending signal event causes the execution to end (scope-execution for the catching event)
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
        RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, waitingExecution.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_NO_CONTENT);
    closeResponse(response);
   
    // Check if process is moved on to the other wait-state
    waitingExecution = runtimeService.createExecutionQuery().activityId("anotherWaitState").singleResult();
    assertNotNull(waitingExecution);
    assertEquals(signalExecution.getId(), waitingExecution.getId());
   
    Map<String, Object> vars = runtimeService.getVariables(waitingExecution.getId());
    assertEquals(1, vars.size());
   
    assertEquals("Variable set when signal event is receieved", vars.get("myVar"));
  }
View Full Code Here

  /**
   * Test signalling a single execution, without signal event and variables.
   */
  @Deployment(resources = {"org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-message-event.bpmn20.xml"})
  public void testMessageEventExecution() throws Exception {
    Execution execution = runtimeService.startProcessInstanceByKey("processOne");
    assertNotNull(execution);
   
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "messageEventReceived");
    requestNode.put("messageName", "unexisting");
    Execution waitingExecution = runtimeService.createExecutionQuery().activityId("waitState").singleResult();
    assertNotNull(waitingExecution);
   
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
        RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, waitingExecution.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_INTERNAL_SERVER_ERROR);
    closeResponse(response);
   
    requestNode.put("messageName", "paymentMessage");
   
    // Sending signal event causes the execution to end (scope-execution for the catching event)
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    response = executeRequest(httpPut, HttpStatus.SC_NO_CONTENT);
    closeResponse(response);
   
    // Check if process is moved on to the other wait-state
    waitingExecution = runtimeService.createExecutionQuery().activityId("anotherWaitState").singleResult();
    assertNotNull(waitingExecution);
    assertEquals(execution.getId(), waitingExecution.getId());
  }
View Full Code Here

  /**
   * Test messaging a single execution with variables.
   */
  @Deployment(resources = {"org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-message-event.bpmn20.xml"})
  public void testMessageEventExecutionWithvariables() throws Exception {
    Execution signalExecution = runtimeService.startProcessInstanceByKey("processOne");
    assertNotNull(signalExecution);
   
    ArrayNode variables = objectMapper.createArrayNode();
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "messageEventReceived");
    requestNode.put("messageName", "paymentMessage");
    requestNode.put("variables", variables);
   
    ObjectNode varNode = objectMapper.createObjectNode();
    variables.add(varNode);
    varNode.put("name", "myVar");
    varNode.put("value", "Variable set when signal event is receieved");
   
    Execution waitingExecution = runtimeService.createExecutionQuery().activityId("waitState").singleResult();
    assertNotNull(waitingExecution);
   
    // Sending signal event causes the execution to end (scope-execution for the catching event)
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
        RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, waitingExecution.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_NO_CONTENT);
    closeResponse(response);
   
    // Check if process is moved on to the other wait-state
    waitingExecution = runtimeService.createExecutionQuery().activityId("anotherWaitState").singleResult();
    assertNotNull(waitingExecution);
    assertEquals(signalExecution.getId(), waitingExecution.getId());
   
    Map<String, Object> vars = runtimeService.getVariables(waitingExecution.getId());
    assertEquals(1, vars.size());
   
    assertEquals("Variable set when signal event is receieved", vars.get("myVar"));
  }
View Full Code Here

  /**
   * Test executing an illegal action on an execution.
   */
  @Deployment(resources = {"org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-subprocess.bpmn20.xml"})
  public void testIllegalExecutionAction() throws Exception {
    Execution execution = runtimeService.startProcessInstanceByKey("processOne");
    assertNotNull(execution);
   
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "badaction");
   
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX +
        RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, execution.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_BAD_REQUEST);
    closeResponse(response);
  }
View Full Code Here

    }
    assertNotNull(parallelUserTask);

    taskService.complete(parallelUserTask.getId());
   
    Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).activityId("subprocess1WaitBeforeError").singleResult();
    runtimeService.signal(execution.getId());
   
    activeActivities = runtimeService.getActiveActivityIds(processInstance.getId());
    assertEquals(2, activeActivities.size());
   
    tasks = taskService.createTaskQuery().list();
View Full Code Here

@Deployment(resources={
         "org/activiti/engine/test/api/runtime/RuntimeServiceTest.catchAlertSignal.bpmn20.xml"
})
public void testExecutionWaitingForDifferentSignal() {
   runtimeService.startProcessInstanceByKey("catchAlertSignal");
   Execution execution = runtimeService.createExecutionQuery()
     .signalEventSubscriptionName("alert")
     .singleResult();
   try {
     runtimeService.signalEventReceived("bogusSignal", execution.getId());
     fail("exeception expected");
   }catch (ActivitiException e) {
     // this is good
   }
  }
View Full Code Here

 
  @RequestMapping(value="/runtime/executions/{executionId}", method = RequestMethod.PUT, produces="application/json")
  public ExecutionResponse performExecutionAction(@PathVariable String executionId, @RequestBody ExecutionActionRequest actionRequest,
      HttpServletRequest request, HttpServletResponse response) {
   
    Execution execution = getExecutionFromRequest(executionId);
   
    if (ExecutionActionRequest.ACTION_SIGNAL.equals(actionRequest.getAction())) {
      if (actionRequest.getVariables() != null) {
        runtimeService.signal(execution.getId(), getVariablesToSet(actionRequest));
      } else {
        runtimeService.signal(execution.getId());
      }
    } else if(ExecutionActionRequest.ACTION_SIGNAL_EVENT_RECEIVED.equals(actionRequest.getAction())) {
      if (actionRequest.getSignalName() == null) {
        throw new ActivitiIllegalArgumentException("Signal name is required");
      }
      if (actionRequest.getVariables() != null) {
        runtimeService.signalEventReceived(actionRequest.getSignalName(), execution.getId(), getVariablesToSet(actionRequest));
      } else {
        runtimeService.signalEventReceived(actionRequest.getSignalName(), execution.getId());
      }
    } else if (ExecutionActionRequest.ACTION_MESSAGE_EVENT_RECEIVED.equals(actionRequest.getAction())) {
      if (actionRequest.getMessageName() == null) {
        throw new ActivitiIllegalArgumentException("Message name is required");
      }
      if (actionRequest.getVariables() != null) {
        runtimeService.messageEventReceived(actionRequest.getMessageName(), execution.getId(), getVariablesToSet(actionRequest));
      } else {
        runtimeService.messageEventReceived(actionRequest.getMessageName(), execution.getId());
      }
    } else {
      throw new ActivitiIllegalArgumentException("Invalid action: '" + actionRequest.getAction() + "'.");
    }
   
    // Re-fetch the execution, could have changed due to action or even completed
    execution = runtimeService.createExecutionQuery().executionId(execution.getId()).singleResult();
    if (execution == null) {
      // Execution is finished, return empty body to inform user
      response.setStatus(HttpStatus.NO_CONTENT.value());
      return null;
    } else {
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.