Examples of CaseInstance


Examples of org.camunda.bpm.engine.runtime.CaseInstance

*/
public class HistoricCaseInstanceTest extends CmmnProcessEngineTestCase {

  @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.runtime.CaseInstance

  @Deployment(resources = {
    "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn",
    "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn"
  })
  public void testHistoricCaseInstanceQuery() {
    CaseInstance oneTaskCase = createCaseInstanceByKey("oneTaskCase", "oneBusiness");
    CaseInstance twoTaskCase = createCaseInstanceByKey("twoTaskCase", "twoBusiness");

    assertCount(1, historicQuery().caseInstanceId(oneTaskCase.getId()));
    assertCount(1, historicQuery().caseInstanceId(twoTaskCase.getId()));

    Set<String> caseInstanceIds = new HashSet<String>();
    caseInstanceIds.add(oneTaskCase.getId());
    caseInstanceIds.add("unknown1");
    caseInstanceIds.add(twoTaskCase.getId());
    caseInstanceIds.add("unknown2");

    assertCount(2, historicQuery().caseInstanceIds(caseInstanceIds));

    assertCount(1, historicQuery().caseDefinitionId(oneTaskCase.getCaseDefinitionId()));
View Full Code Here

Examples of org.camunda.bpm.engine.runtime.CaseInstance

    assertEquals(2, historyService.createNativeHistoricCaseInstanceQuery().sql("SELECT * FROM " + tableName).listPage(2, 2).size());
  }

  @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.runtime.CaseInstance

  }

  public CaseInstanceDto createCaseInstance(UriInfo context, CreateCaseInstanceDto parameters) {
    CaseService caseService = engine.getCaseService();

    CaseInstance instance = null;
    try {

      String businessKey = parameters.getBusinessKey();
      VariableMap variables = VariableValueDto.toMap(parameters.getVariables(), engine, objectMapper);

      instance = caseService
          .withCaseDefinition(caseDefinitionId)
          .businessKey(businessKey)
          .setVariables(variables)
          .create();

    } catch (RestException e) {
      String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
      throw new InvalidRequestException(e.getStatus(), e, errorMessage);

    } catch (NotFoundException e) {
      String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
      throw new InvalidRequestException(Status.NOT_FOUND, e, errorMessage);

    } catch (NotValidException e) {
      String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
      throw new InvalidRequestException(Status.BAD_REQUEST, e, errorMessage);

    } catch (NotAllowedException e) {
      String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
      throw new InvalidRequestException(Status.FORBIDDEN, e, errorMessage);

    } catch (ProcessEngineException e) {
      String errorMessage = String.format("Cannot instantiate case definition %s: %s", caseDefinitionId, e.getMessage());
      throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);

    }

    CaseInstanceDto result = CaseInstanceDto.fromCaseInstance(instance);

    URI uri = context.getBaseUriBuilder()
      .path(rootResourcePath)
      .path(CaseInstanceRestService.PATH)
      .path(instance.getId())
      .build();

    result.addReflexiveLink(uri, HttpMethod.GET, "self");

    return result;
View Full Code Here

Examples of org.camunda.bpm.engine.runtime.CaseInstance

  }

  public CaseInstanceDto getCaseInstance() {
    CaseService caseService = engine.getCaseService();

    CaseInstance instance = caseService
        .createCaseInstanceQuery()
        .caseInstanceId(caseInstanceId)
        .singleResult();

    if (instance == null) {
View Full Code Here

Examples of org.camunda.bpm.engine.runtime.CaseInstance

    // start case task manually to create case instance
    CaseExecution caseTask = queryCaseExecutionByActivityId(taskId);
    manualStart(caseTask.getId());

    // there should exist a new case instance
    CaseInstance calledCaseInstance = caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId).singleResult();
    assertNotNull(calledCaseInstance);

    // check that the called case instance id was correctly set
    historicInstance = queryHistoricActivityCaseInstance(taskId);
    assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());

    // disable task to complete called case instance and close it
    CaseExecution calledTask = queryCaseExecutionByActivityId(calledTaskId);
    disable(calledTask.getId());
    close(calledCaseInstance.getId());

    // check that the called case instance id is still set
    assertCount(0, caseService.createCaseInstanceQuery().caseDefinitionKey(calledCaseId));
    historicInstance = queryHistoricActivityCaseInstance(taskId);
    assertEquals(calledCaseInstance.getId(), historicInstance.getCalledCaseInstanceId());
  }
View Full Code Here

Examples of org.camunda.bpm.engine.runtime.CaseInstance

    assertEquals(2, historyService.createNativeHistoricCaseActivityInstanceQuery().sql("SELECT * FROM " + tableName).listPage(2, 2).size());
  }

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

    HistoricCaseActivityInstance historicInstance = historicQuery().singleResult();
    assertNotNull(historicInstance);

    // disable human task to complete case
    disable(historicInstance.getId());
    // close case to be able to delete historic case instance
    close(caseInstance.getId());
    // delete historic case instance
    historyService.deleteHistoricCaseInstance(caseInstance.getId());

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

Examples of org.camunda.bpm.engine.runtime.CaseInstance

    assertCount(0, historicQuery());
  }

  @Deployment
  public void testNonBlockingHumanTask() {
    CaseInstance caseInstance = createCaseInstance();
    assertNotNull(caseInstance);
  }
View Full Code Here

Examples of org.camunda.bpm.engine.runtime.CaseInstance

        .withCaseDefinitionByKey("case")
        .create()
        .getId();

    // then
    CaseInstance caseInstance = caseService
        .createCaseInstanceQuery()
        .caseInstanceId(caseInstanceId)
        .singleResult();

    assertTrue(caseInstance.isCompleted());

    Object occurVariable = caseService.getVariable(caseInstanceId, "occur");
    assertNotNull(occurVariable);
    assertTrue((Boolean) occurVariable);
  }
View Full Code Here

Examples of org.camunda.bpm.engine.runtime.CaseInstance

        .available()
        .singleResult();

    assertNull(milestone);

    CaseInstance caseInstance = caseService
        .createCaseInstanceQuery()
        .caseInstanceId(caseInstanceId)
        .singleResult();

    assertTrue(caseInstance.isCompleted());

  }
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.