Package org.activiti.engine.history

Examples of org.activiti.engine.history.HistoricProcessInstance


    // Deleting without a reason should be possible
    runtimeService.deleteProcessInstance(processInstance.getId(), null);
    assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
   
  if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery()
            .processInstanceId(processInstance.getId())
            .singleResult();
       
        assertNotNull(historicInstance);
        assertEquals("ACTIVITI_DELETED", historicInstance.getDeleteReason());
      }   
  }
View Full Code Here


   
    // Complete task to end process
    taskService.complete(task.getId());
   
    // Query task, including processVariables
    HistoricProcessInstance historicProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).includeProcessVariables().singleResult();
    assertNotNull(historicProcess);
    assertNotNull(historicProcess.getProcessVariables());
    byte[] bytes = (byte[]) historicProcess.getProcessVariables().get("binaryVariable");
    assertEquals("It is I, le binary", new String(bytes));
   
   }
View Full Code Here

    CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_CREATED);
   
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
    assertNotNull(processInstance);
   
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(historicProcessInstance);
    assertEquals("kermit", historicProcessInstance.getStartUserId());
   
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertNotNull(responseNode);
    assertEquals(processInstance.getId(), responseNode.get("id").textValue());
View Full Code Here

    closeResponse(executeRequest(httpPost, HttpStatus.SC_CREATED));
   
    List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
    assertEquals(2, processInstances.size());
    for (ProcessInstance processInstance :  processInstances) {
      HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
      assertNotNull(historicProcessInstance);
      assertEquals("kermit", historicProcessInstance.getStartUserId());
    }
   
  }
View Full Code Here

    HistoricActivityInstance historicActivityInstance = historyService
      .createHistoricActivityInstanceQuery()
      .activityId("callSubProcess")
      .singleResult();
   
    HistoricProcessInstance oldInstance = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("calledProcess").singleResult();
   
    assertEquals(oldInstance.getId(), historicActivityInstance.getCalledProcessInstanceId());
  }
View Full Code Here

    processEngineConfiguration.getClock().setCurrentTime(noon);
    final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "myBusinessKey");

    assertEquals(1, historyService.createHistoricProcessInstanceQuery().unfinished().count());
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().finished().count());
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();

    assertNotNull(historicProcessInstance);
    assertEquals(processInstance.getId(), historicProcessInstance.getId());
    assertEquals(processInstance.getBusinessKey(), historicProcessInstance.getBusinessKey());
    assertEquals(processInstance.getProcessDefinitionId(), historicProcessInstance.getProcessDefinitionId());
    assertEquals(noon, historicProcessInstance.getStartTime());
    assertNull(historicProcessInstance.getEndTime());
    assertNull(historicProcessInstance.getDurationInMillis());

    List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();

    assertEquals(1, tasks.size());

    // in this test scenario we assume that 25 seconds after the process start, the
    // user completes the task (yes! he must be almost as fast as me)
    Date twentyFiveSecsAfterNoon = new Date(noon.getTime() + 25*1000);
    processEngineConfiguration.getClock().setCurrentTime(twentyFiveSecsAfterNoon);
    taskService.complete(tasks.get(0).getId());

    historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();

    assertNotNull(historicProcessInstance);
    assertEquals(processInstance.getId(), historicProcessInstance.getId());
    assertEquals(processInstance.getProcessDefinitionId(), historicProcessInstance.getProcessDefinitionId());
    assertEquals(noon, historicProcessInstance.getStartTime());
    assertEquals(twentyFiveSecsAfterNoon, historicProcessInstance.getEndTime());
    assertEquals(new Long(25*1000), historicProcessInstance.getDurationInMillis());
   
    assertEquals(0, historyService.createHistoricProcessInstanceQuery().unfinished().count());
    assertEquals(1, historyService.createHistoricProcessInstanceQuery().finished().count());
  }
View Full Code Here

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    assertNotNull(processInstance);
   
    // delete process instance should not delete the history
    runtimeService.deleteProcessInstance(processInstance.getId(), "cancel");
    HistoricProcessInstance historicProcessInstance =
      historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(historicProcessInstance.getEndTime());
  }
View Full Code Here

  public void testDeleteReason() {
    if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
      final String deleteReason = "some delete reason";
      ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess");
      runtimeService.deleteProcessInstance(pi.getId(), deleteReason);
      HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(pi.getId()).singleResult();
      assertEquals(deleteReason, hpi.getDeleteReason());
    }
  }
View Full Code Here

    //Delete the process instance.
    runtimeService.deleteProcessInstance(instanceUser.getId(), null);
   
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
      //Retrieve the HistoricProcessInstance and assert that there is an end time.
      HistoricProcessInstance hInstanceUser = historyService.createHistoricProcessInstanceQuery().processInstanceId(instanceUser.getId()).singleResult();
      assertNotNull(hInstanceUser.getEndTime());
      log.info("End time for the deleted instance of \"Demo Partial Deletion\" that was started with a Task Type of \"user\": " + hInstanceUser.getEndTime() + ".");
      log.info("Successfully deleted the instance of \"Demo Partial Deletion\" that was started with a Task Type of \"user\".");
    }
   
    //Note that the instance with a Task Type of "java" is being started.
    log.info("Starting an instance of \"Demo Partial Deletion\" with a Task Type of \"java\".");
       
    //Set the inputs for the second process instance, which we will NOT be able to completely delete.
    Map<String,Object> inputParamsJava = new HashMap<String,Object>();
    inputParamsJava.put("taskType", "java");
       
    //Start the process instance & ensure it's started.
    ProcessInstance instanceJava = runtimeService.startProcessInstanceByKey("DemoPartialDeletion", inputParamsJava);
    assertNotNull(instanceJava);
    log.info("Process instance (of process model " + instanceJava.getProcessDefinitionId() + ") started with id: " + instanceJava.getId() + ".");
       
    //Assert that the process instance is active.
    Execution executionJava = runtimeService.createExecutionQuery().processInstanceId(instanceJava.getProcessInstanceId()).singleResult();
    assertFalse(executionJava.isEnded());
   
    // Try to execute job 3 times
    Job jobJava = managementService.createJobQuery().processInstanceId(instanceJava.getId()).singleResult();
    assertNotNull(jobJava);
   
    try {
      managementService.executeJob(jobJava.getId());
      fail("Expected exception");
    } catch (Exception e) {
      // expected
    }
   
    try {
      managementService.executeJob(jobJava.getId());
      fail("Expected exception");
    } catch (Exception e) {
      // expected
    }
   
    try {
      managementService.executeJob(jobJava.getId());
      fail("Expected exception");
    } catch (Exception e) {
      // expected
    }
       
    //Assert that there is a failed job.
    jobJava = managementService.createJobQuery().processInstanceId(instanceJava.getId()).singleResult();
    assertNotNull(jobJava);
    assertEquals(0, jobJava.getRetries());
   
    //Delete the process instance.
    runtimeService.deleteProcessInstance(instanceJava.getId(), null);
   
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
      //Retrieve the HistoricProcessInstance and assert that there is no end time.
      HistoricProcessInstance hInstanceJava = historyService.createHistoricProcessInstanceQuery().processInstanceId(instanceJava.getId()).singleResult();
      assertNotNull(hInstanceJava.getEndTime());
    }
  }
View Full Code Here

      .singleResult();
    assertEquals(newProcessDefinition.getId(), pi.getProcessDefinitionId());
   
    // check history
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
      HistoricProcessInstance historicPI = historyService
        .createHistoricProcessInstanceQuery()
        .processInstanceId(pi.getId())
        .singleResult();
      assertEquals(newProcessDefinition.getId(), historicPI.getProcessDefinitionId());
    }

    // undeploy "manually" deployed process definition
    repositoryService.deleteDeployment(deployment.getId(), true);
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.history.HistoricProcessInstance

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.