Examples of HistoricCaseInstance


Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

  @Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/emptyStageCase.cmmn"})
  public void testCaseInstanceProperties() {
    CaseInstance caseInstance = createCaseInstance();

    HistoricCaseInstance historicInstance = queryHistoricCaseInstance(caseInstance.getId());

    // assert case instance properties are set correctly
    assertEquals(caseInstance.getId(), historicInstance.getId());
    assertEquals(caseInstance.getBusinessKey(), historicInstance.getBusinessKey());
    assertEquals(caseInstance.getCaseDefinitionId(), historicInstance.getCaseDefinitionId());
  }
View Full Code Here

Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

  @Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/emptyStageCase.cmmn"})
  public void testCaseInstanceStates() {
    String caseInstanceId = createCaseInstance().getId();

    HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);

    assertTrue(historicCaseInstance.isActive());
    assertCount(1, historicQuery().active());
    assertCount(1, historicQuery().notClosed());

    // start empty stage to complete case instance
    String stageExecutionId = queryCaseExecutionByActivityId("PI_Stage_1").getId();
    manualStart(stageExecutionId);

    historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
    assertTrue(historicCaseInstance.isCompleted());
    assertCount(1, historicQuery().completed());
    assertCount(1, historicQuery().notClosed());

    // reactive and terminate case instance
    reactivate(caseInstanceId);
    terminate(caseInstanceId);

    historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
    assertTrue(historicCaseInstance.isTerminated());
    assertCount(1, historicQuery().terminated());
    assertCount(1, historicQuery().notClosed());

    // reactive and suspend case instance
    reactivate(caseInstanceId);
    suspend(caseInstanceId);

    historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
    // not public API
    assertTrue(((HistoricCaseInstanceEntity) historicCaseInstance).isSuspended());
//    assertCount(1, historicQuery().suspended());
    assertCount(1, historicQuery().notClosed());

    // close case instance
    close(caseInstanceId);

    historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
    assertTrue(historicCaseInstance.isClosed());
    assertCount(1, historicQuery().closed());
    assertCount(0, historicQuery().notClosed());
  }
View Full Code Here

Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

    // close instance
    ClockUtil.setCurrentTime(closed);
    close(caseInstanceId);

    HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);

    // read historic dates ignoring milliseconds
    Date createTime = historicCaseInstance.getCreateTime();
    Date closeTime = historicCaseInstance.getCloseTime();
    Long durationInMillis = historicCaseInstance.getDurationInMillis();

    assertDateSimilar(created, createTime);
    assertDateSimilar(closed, closeTime);

    // test that duration is as expected with a maximal difference of one second
View Full Code Here

Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

    String userId = "test";
    identityService.setAuthenticatedUserId(userId);

    String caseInstanceId = createCaseInstance().getId();

    HistoricCaseInstance historicCaseInstance = queryHistoricCaseInstance(caseInstanceId);
    assertEquals(userId, historicCaseInstance.getCreateUserId());
    assertCount(1, historicQuery().createdBy(userId));

    identityService.setAuthenticatedUserId(null);
  }
View Full Code Here

Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

    String caseInstanceId  = createCaseInstanceByKey("oneCaseTaskCase").getId();
    String caseTaskId = queryCaseExecutionByActivityId("PI_CaseTask_1").getId();

    manualStart(caseTaskId);

    HistoricCaseInstance historicCaseInstance = historicQuery()
      .superCaseInstanceId(caseInstanceId)
      .singleResult();

    assertNotNull(historicCaseInstance);
    assertEquals(caseInstanceId, historicCaseInstance.getSuperCaseInstanceId());

    String superCaseInstanceId = historicQuery()
      .subCaseInstanceId(historicCaseInstance.getId())
      .singleResult()
      .getId();

    assertEquals(caseInstanceId, superCaseInstanceId);
  }
View Full Code Here

Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

    // set time ahead to get different durations
    ClockUtil.setCurrentTime(DateTimeUtil.now().plusHours(1).toDate());
    terminate(twoCaseInstanceId);
    close(twoCaseInstanceId);

    HistoricCaseInstance oneCaseInstance = queryHistoricCaseInstance(oneCaseInstanceId);
    HistoricCaseInstance twoCaseInstance = queryHistoricCaseInstance(twoCaseInstanceId);

    // sort by case instance ids
    String property = "id";
    List<? extends Comparable> sortedList = Arrays.asList(oneCaseInstance.getId(), twoCaseInstance.getId());
    Collections.sort(sortedList);

    List<HistoricCaseInstance> instances = historicQuery().orderByCaseInstanceId().asc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(0))),
      hasProperty(property, equalTo(sortedList.get(1)))
    ));

    instances = historicQuery().orderByCaseInstanceId().desc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(1))),
      hasProperty(property, equalTo(sortedList.get(0)))
    ));

    // sort by case definition ids
    property = "caseDefinitionId";
    sortedList = Arrays.asList(oneCaseInstance.getCaseDefinitionId(), twoCaseInstance.getCaseDefinitionId());
    Collections.sort(sortedList);

    instances = historicQuery().orderByCaseDefinitionId().asc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(0))),
      hasProperty(property, equalTo(sortedList.get(1)))
    ));

    instances = historicQuery().orderByCaseDefinitionId().desc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(1))),
      hasProperty(property, equalTo(sortedList.get(0)))
    ));

    // sort by business keys
    property = "businessKey";
    sortedList = Arrays.asList(oneCaseInstance.getBusinessKey(), twoCaseInstance.getBusinessKey());
    Collections.sort(sortedList);

    instances = historicQuery().orderByCaseInstanceBusinessKey().asc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(0))),
      hasProperty(property, equalTo(sortedList.get(1)))
    ));

    instances = historicQuery().orderByCaseInstanceBusinessKey().desc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(1))),
      hasProperty(property, equalTo(sortedList.get(0)))
    ));

    // sort by create time
    property = "createTime";
    sortedList = Arrays.asList(oneCaseInstance.getCreateTime(), twoCaseInstance.getCreateTime());
    Collections.sort(sortedList);

    instances = historicQuery().orderByCaseInstanceCreateTime().asc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(0))),
      hasProperty(property, equalTo(sortedList.get(1)))
    ));

    instances = historicQuery().orderByCaseInstanceCreateTime().desc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(1))),
      hasProperty(property, equalTo(sortedList.get(0)))
    ));

    // sort by close time
    property = "closeTime";
    sortedList = Arrays.asList(oneCaseInstance.getCloseTime(), twoCaseInstance.getCloseTime());
    Collections.sort(sortedList);

    instances = historicQuery().orderByCaseInstanceCloseTime().asc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(0))),
      hasProperty(property, equalTo(sortedList.get(1)))
    ));

    instances = historicQuery().orderByCaseInstanceCloseTime().desc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
      hasProperty(property, equalTo(sortedList.get(1))),
      hasProperty(property, equalTo(sortedList.get(0)))
    ));

    // sort by duration
    property = "durationInMillis";
    sortedList = Arrays.asList(oneCaseInstance.getDurationInMillis(), twoCaseInstance.getDurationInMillis());
    Collections.sort(sortedList);

    instances = historicQuery().orderByCaseInstanceDuration().asc().list();
    assertEquals(2, instances.size());
    assertThat(instances, contains(
View Full Code Here

Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

  @Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/emptyStageCase.cmmn"})
  public void testDeleteHistoricCaseInstance() {
    CaseInstance caseInstance = createCaseInstance();

    HistoricCaseInstance historicInstance = queryHistoricCaseInstance(caseInstance.getId());
    assertNotNull(historicInstance);

    try {
      // should not be able to delete historic case instance cause the case instance is still running
      historyService.deleteHistoricCaseInstance(historicInstance.getId());
      fail("Exception expected");
    }
    catch (NullValueException e) {
      // expected
    }

    terminate(caseInstance.getId());
    close(caseInstance.getId());

    historyService.deleteHistoricCaseInstance(historicInstance.getId());

    assertCount(0, historicQuery());
  }
View Full Code Here

Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

    assertCount(0, historicQuery());
  }

  protected HistoricCaseInstance queryHistoricCaseInstance(String caseInstanceId) {
    HistoricCaseInstance historicCaseInstance = historicQuery()
      .caseInstanceId(caseInstanceId)
      .singleResult();
    assertNotNull(historicCaseInstance);
    return historicCaseInstance;
  }
View Full Code Here

Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

  }

  public Object execute(CommandContext commandContext) {
    ensureNotNull("caseInstanceId", caseInstanceId);
    // Check if case instance is still running
    HistoricCaseInstance instance = commandContext
      .getHistoricCaseInstanceManager()
      .findHistoricCaseInstance(caseInstanceId);

    ensureNotNull("No historic case instance found with id: " + caseInstanceId, "instance", instance);
    ensureNotNull("Case instance is still running, cannot delete historic case instance: " + caseInstanceId, "instance.getCloseTime()", instance.getCloseTime());

    commandContext
      .getHistoricCaseInstanceManager()
      .deleteHistoricCaseInstanceById(caseInstanceId);
View Full Code Here

Examples of org.camunda.bpm.engine.history.HistoricCaseInstance

    this.caseInstanceId = caseInstanceId;
  }

  public HistoricCaseInstanceDto getHistoricCaseInstance() {
    HistoryService historyService = engine.getHistoryService();
    HistoricCaseInstance instance = historyService.createHistoricCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();

    if (instance == null) {
      throw new InvalidRequestException(Status.NOT_FOUND, "Historic case instance with id '" + caseInstanceId + "' does not exist");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.