Search in sources :

Example 46 with CaseDefinition

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

the class MultiTenancyCaseDefinitionCmdsTenantCheckTest method getCaseDefinitionWithAuthenticatedTenant.

@Test
public void getCaseDefinitionWithAuthenticatedTenant() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);
    assertThat(definition.getTenantId(), is(TENANT_ONE));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Test(org.junit.Test)

Example 47 with CaseDefinition

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

the class MultiTenancyCaseDefinitionCmdsTenantCheckTest method updateHistoryTimeToLiveWithAuthenticatedTenant.

@Test
public void updateHistoryTimeToLiveWithAuthenticatedTenant() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
    repositoryService.updateCaseDefinitionHistoryTimeToLive(caseDefinitionId, 6);
    CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId);
    assertThat(definition.getTenantId(), is(TENANT_ONE));
    assertThat(definition.getHistoryTimeToLive(), is(6));
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Test(org.junit.Test)

Example 48 with CaseDefinition

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

the class VariableListenerTest method testInvokeBuiltinListenersOnly.

@Deployment
public void testInvokeBuiltinListenersOnly() {
    // disable custom variable listener invocation
    processEngineConfiguration.setInvokeCustomVariableListeners(false);
    // add a builtin variable listener the hard way
    CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult();
    processEngineConfiguration.getDeploymentCache().getCaseDefinitionById(caseDefinition.getId()).findActivity("PI_HumanTask_1").addBuiltInVariableListener(CaseVariableListener.CREATE, new LogVariableListener());
    caseService.withCaseDefinitionByKey("case").create();
    CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNotNull(taskExecution);
    // when i set a variable
    caseService.withCaseExecution(taskExecution.getId()).setVariableLocal("testVariable", "value1").execute();
    // then the builtin listener is invoked
    assertEquals(1, LogVariableListener.getInvocations().size());
    // but the custom listener is not invoked
    assertEquals(0, LogExecutionContextListener.getCaseExecutionContexts().size());
    LogVariableListener.reset();
    LogExecutionContextListener.reset();
    // restore configuration
    processEngineConfiguration.setInvokeCustomVariableListeners(true);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 49 with CaseDefinition

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

the class DeploymentManager method deleteCaseDeployment.

protected void deleteCaseDeployment(String deploymentId, boolean cascade) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    if (processEngineConfiguration.isCmmnEnabled()) {
        List<CaseDefinition> caseDefinitions = getCaseDefinitionManager().findCaseDefinitionByDeploymentId(deploymentId);
        if (cascade) {
            // delete case instances
            for (CaseDefinition caseDefinition : caseDefinitions) {
                String caseDefinitionId = caseDefinition.getId();
                getCaseInstanceManager().deleteCaseInstancesByCaseDefinition(caseDefinitionId, "deleted deployment", true);
            }
        }
        // delete case definitions from db
        getCaseDefinitionManager().deleteCaseDefinitionsByDeploymentId(deploymentId);
        for (CaseDefinition caseDefinition : caseDefinitions) {
            String processDefinitionId = caseDefinition.getId();
            // remove case definitions from cache:
            Context.getProcessEngineConfiguration().getDeploymentCache().removeCaseDefinition(processDefinitionId);
        }
    }
}
Also used : CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 50 with CaseDefinition

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

the class HistoryCleanupTest method prepareInstances.

private void prepareInstances(Integer processInstanceTimeToLive, Integer decisionTimeToLive, Integer caseTimeToLive) {
    // update time to live
    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(new Date(), DAYS_IN_THE_PAST));
    // 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 < PROCESS_INSTANCES_COUNT; 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 < DECISION_INSTANCES_COUNT; i++) {
        engineRule.getDecisionService().evaluateDecisionByKey("testDecision").variables(variables).evaluate();
    }
    // create 4 case instances
    for (int i = 0; i < CASE_INSTANCES_COUNT; 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);
}
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) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

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