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));
}
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));
}
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);
}
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);
}
}
}
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);
}
Aggregations