Search in sources :

Example 51 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class CaseServiceTest method testCaseInstanceQuery.

@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/loan-application.cmmn")
public void testCaseInstanceQuery() {
    // given
    // there exists a deployment containing a case definition with key "loanApplication"
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("loanApplication").singleResult();
    assertNotNull(caseDefinition);
    // when
    // create a new case instance by key
    CaseInstance caseInstance = caseService.withCaseDefinitionByKey(caseDefinition.getKey()).create();
    // then
    // the returned caseInstance is not null
    assertNotNull(caseInstance);
    // verify that there is one caseInstance
    // only select ACTIVE case instances
    List<CaseInstance> caseInstances = caseService.createCaseInstanceQuery().active().list();
    assertEquals(1, caseInstances.size());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 52 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class CaseServiceTest method testCreateCaseInstanceByKey.

@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/loan-application.cmmn")
public void testCreateCaseInstanceByKey() {
    // given
    // there exists a deployment containing a case definition with key "loanApplication"
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("loanApplication").singleResult();
    assertNotNull(caseDefinition);
    // when
    // create a new case instance by key
    CaseInstance caseInstance = caseService.withCaseDefinitionByKey(caseDefinition.getKey()).create();
    // then
    // the returned caseInstance is not null
    assertNotNull(caseInstance);
    // verify that the case instance is persisted using the API
    CaseInstance instance = caseService.createCaseInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult();
    assertNotNull(instance);
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 53 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class CaseServiceTest method testCreateCaseInstanceById.

@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/loan-application.cmmn")
public void testCreateCaseInstanceById() {
    // given
    // there exists a deployment containing a case definition with key "loanApplication"
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("loanApplication").singleResult();
    assertNotNull(caseDefinition);
    // when
    // create a new case instance by id
    CaseInstance caseInstance = caseService.withCaseDefinition(caseDefinition.getId()).create();
    // then
    // the returned caseInstance is not null
    assertNotNull(caseInstance);
    // verify that the case instance is persisted using the API
    CaseInstance instance = caseService.createCaseInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult();
    assertNotNull(instance);
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 54 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class TaskQueryTest method getCaseDefinitionIds.

/**
 * @return the case definition ids
 */
protected List<String> getCaseDefinitionIds() {
    List<String> caseDefinitionIds = new ArrayList<String>();
    List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery().list();
    for (CaseDefinition caseDefinition : caseDefinitions) {
        caseDefinitionIds.add(caseDefinition.getId());
    }
    return caseDefinitionIds;
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 55 with CaseDefinition

use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.

the class TaskQueryTest method testQueryByCaseDefinitionName.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseDefinitionName() {
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    String caseDefinitionId = caseDefinition.getId();
    String caseDefinitionName = caseDefinition.getName();
    caseService.withCaseDefinition(caseDefinitionId).create();
    TaskQuery query = taskService.createTaskQuery();
    query.caseDefinitionName(caseDefinitionName);
    verifyQueryResults(query, 1);
}
Also used : TaskQuery(org.camunda.bpm.engine.task.TaskQuery) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)65 Deployment (org.camunda.bpm.engine.test.Deployment)17 Test (org.junit.Test)14 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)13 CaseDefinitionQuery (org.camunda.bpm.engine.repository.CaseDefinitionQuery)12 ArrayList (java.util.ArrayList)8 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)5 Response (com.jayway.restassured.response.Response)4 Date (java.util.Date)4 HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)3 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 User (org.camunda.bpm.engine.identity.User)2