Search in sources :

Example 16 with CaseDefinition

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

the class MultiTenancyDelegateCaseExecutionTest method createCaseInstance.

protected void createCaseInstance(String caseDefinitionKey) {
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(caseDefinitionKey).latestVersion().singleResult();
    caseService.createCaseInstanceById(caseDefinition.getId());
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition)

Example 17 with CaseDefinition

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

the class MultiTenancyCaseTaskTest method testStartCaseInstanceWithLatestBindingDifferentVersion.

public void testStartCaseInstanceWithLatestBindingDifferentVersion() {
    deploymentForTenant(TENANT_ONE, CMMN_LATEST_WITH_MANUAL_ACTIVATION, CMMN_CASE);
    deploymentForTenant(TENANT_TWO, CMMN_LATEST_WITH_MANUAL_ACTIVATION, CMMN_CASE);
    deploymentForTenant(TENANT_TWO, CMMN_CASE);
    createCaseInstance("caseTaskCase", TENANT_ONE);
    createCaseInstance("caseTaskCase", TENANT_TWO);
    CaseInstanceQuery query = caseService.createCaseInstanceQuery().caseDefinitionKey("oneTaskCase");
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
    CaseDefinition latestCaseDefinitionTenantTwo = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("oneTaskCase").tenantIdIn(TENANT_TWO).latestVersion().singleResult();
    query = caseService.createCaseInstanceQuery().caseDefinitionId(latestCaseDefinitionTenantTwo.getId());
    assertThat(query.count(), is(1L));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery)

Example 18 with CaseDefinition

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

the class HistoryCleanupAuthorizationTest method prepareInstances.

protected void prepareInstances(Integer processInstanceTimeToLive, Integer decisionTimeToLive, Integer caseTimeToLive) {
    // update time to live
    disableAuthorization();
    List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().processDefinitionKey("testProcess").list();
    assertEquals(1, processDefinitions.size());
    repositoryService.updateProcessDefinitionHistoryTimeToLive(processDefinitions.get(0).getId(), processInstanceTimeToLive);
    final List<DecisionDefinition> decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey("testDecision").list();
    assertEquals(1, decisionDefinitions.size());
    repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitions.get(0).getId(), decisionTimeToLive);
    List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery().caseDefinitionKey("oneTaskCase").list();
    assertEquals(1, caseDefinitions.size());
    repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinitions.get(0).getId(), caseTimeToLive);
    Date oldCurrentTime = ClockUtil.getCurrentTime();
    ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, -6));
    // create 3 process instances
    List<String> processInstanceIds = new ArrayList<String>();
    Map<String, Object> variables = Variables.createVariables().putValue("pojo", new TestPojo("okay", 13.37));
    for (int i = 0; i < 3; i++) {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess", variables);
        processInstanceIds.add(processInstance.getId());
    }
    runtimeService.deleteProcessInstances(processInstanceIds, null, true, true);
    // +10 standalone decisions
    for (int i = 0; i < 10; i++) {
        decisionService.evaluateDecisionByKey("testDecision").variables(variables).evaluate();
    }
    // create 4 case instances
    for (int i = 0; i < 4; i++) {
        CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase", Variables.createVariables().putValue("pojo", new TestPojo("okay", 13.37 + i)));
        caseService.terminateCaseExecution(caseInstance.getId());
        caseService.closeCaseInstance(caseInstance.getId());
    }
    ClockUtil.setCurrentTime(oldCurrentTime);
    enableAuthorization();
}
Also used : ArrayList(java.util.ArrayList) TestPojo(org.camunda.bpm.engine.test.dmn.businessruletask.TestPojo) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Date(java.util.Date) CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 19 with CaseDefinition

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

the class MultiTenancyCallActivityTest method testStartCaseInstanceWithLatestBindingDifferentVersion.

public void testStartCaseInstanceWithLatestBindingDifferentVersion() {
    BpmnModelInstance callingProcess = Bpmn.createExecutableProcess("callingProcess").startEvent().callActivity().camundaCaseRef("Case_1").camundaCaseBinding("latest").endEvent().done();
    deploymentForTenant(TENANT_ONE, CMMN, callingProcess);
    deploymentForTenant(TENANT_TWO, CMMN, callingProcess);
    deploymentForTenant(TENANT_TWO, CMMN);
    runtimeService.createProcessInstanceByKey("callingProcess").processDefinitionTenantId(TENANT_ONE).execute();
    runtimeService.createProcessInstanceByKey("callingProcess").processDefinitionTenantId(TENANT_TWO).execute();
    CaseInstanceQuery query = caseService.createCaseInstanceQuery().caseDefinitionKey("Case_1");
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
    CaseDefinition latestCaseDefinitionTenantTwo = repositoryService.createCaseDefinitionQuery().tenantIdIn(TENANT_TWO).latestVersion().singleResult();
    query = caseService.createCaseInstanceQuery().caseDefinitionId(latestCaseDefinitionTenantTwo.getId());
    assertThat(query.count(), is(1L));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) CaseInstanceQuery(org.camunda.bpm.engine.runtime.CaseInstanceQuery)

Example 20 with CaseDefinition

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

the class RepositoryServiceTest method testGetCaseDefinition.

@Deployment(resources = { "org/camunda/bpm/engine/test/repository/one.cmmn" })
public void testGetCaseDefinition() {
    CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery();
    CaseDefinition caseDefinition = query.singleResult();
    String caseDefinitionId = caseDefinition.getId();
    CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);
    assertNotNull(definition);
    assertEquals(caseDefinitionId, definition.getId());
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery) 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