use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache in project camunda-bpm-platform by camunda.
the class DeploymentCacheCfgTest method testEnableQueryOfProcessDefinitionAddModelInstancesToDeploymentCache.
@Test
public void testEnableQueryOfProcessDefinitionAddModelInstancesToDeploymentCache() {
// given
deploy(ProcessModels.ONE_TASK_PROCESS_WITH_DOCUMENTATION);
processEngineConfiguration.setEnableFetchProcessDefinitionDescription(true);
ProcessInstance pi = runtimeService.startProcessInstanceByKey(ProcessModels.PROCESS_KEY);
// when
repositoryService.createProcessDefinitionQuery().processDefinitionKey(ProcessModels.PROCESS_KEY).singleResult().getId();
// then
DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
BpmnModelInstance modelInstance = deploymentCache.getBpmnModelInstanceCache().get(pi.getProcessDefinitionId());
assertNotNull(modelInstance);
}
use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache in project camunda-bpm-platform by camunda.
the class DeploymentCacheCfgTest method testDefaultCacheRemovesElementWhenMaxSizeIsExceeded.
@Test
public void testDefaultCacheRemovesElementWhenMaxSizeIsExceeded() {
// The engine rule sets the maximum number of elements of the to 2.
// Accordingly, one process should not be contained in the cache anymore at the end.
// given
List<BpmnModelInstance> modelInstances = createProcesses(3);
deploy(modelInstances);
String processDefinitionIdZero = repositoryService.createProcessDefinitionQuery().processDefinitionKey("Process0").singleResult().getId();
String processDefinitionIdOne = repositoryService.createProcessDefinitionQuery().processDefinitionKey("Process1").singleResult().getId();
String processDefinitionIdTwo = repositoryService.createProcessDefinitionQuery().processDefinitionKey("Process2").singleResult().getId();
// when
DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
// then
int numberOfProcessesInCache = 0;
numberOfProcessesInCache += deploymentCache.getProcessDefinitionCache().get(processDefinitionIdZero) == null ? 0 : 1;
numberOfProcessesInCache += deploymentCache.getProcessDefinitionCache().get(processDefinitionIdOne) == null ? 0 : 1;
numberOfProcessesInCache += deploymentCache.getProcessDefinitionCache().get(processDefinitionIdTwo) == null ? 0 : 1;
assertEquals(2, numberOfProcessesInCache);
}
use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache in project camunda-bpm-platform by camunda.
the class DeploymentCacheCfgTest method testDisableQueryOfProcessDefinitionAddModelInstancesToDeploymentCache.
@Test
public void testDisableQueryOfProcessDefinitionAddModelInstancesToDeploymentCache() {
// given
deploy(ProcessModels.ONE_TASK_PROCESS_WITH_DOCUMENTATION);
ProcessInstance pi = runtimeService.startProcessInstanceByKey(ProcessModels.PROCESS_KEY);
// when
repositoryService.createProcessDefinitionQuery().processDefinitionKey(ProcessModels.PROCESS_KEY).singleResult().getId();
// then
DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
BpmnModelInstance modelInstance = deploymentCache.getBpmnModelInstanceCache().get(pi.getProcessDefinitionId());
assertNull(modelInstance);
}
use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache in project camunda-bpm-platform by camunda.
the class RedeploymentRegistrationTest method decisionRequirementsDefinitionTestProvider.
protected static TestProvider decisionRequirementsDefinitionTestProvider() {
return new TestProvider() {
@Override
public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
return new Command<ProcessApplicationReference>() {
public ProcessApplicationReference execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
DeploymentCache deploymentCache = configuration.getDeploymentCache();
DecisionRequirementsDefinitionEntity definition = deploymentCache.findDeployedDecisionRequirementsDefinitionById(definitionId);
return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
}
};
}
@Override
public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
return repositoryService.createDecisionRequirementsDefinitionQuery().decisionRequirementsDefinitionKey(key).latestVersion().singleResult().getId();
}
};
}
use of org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache in project camunda-bpm-platform by camunda.
the class RedeploymentRegistrationTest method processDefinitionTestProvider.
protected static TestProvider processDefinitionTestProvider() {
return new TestProvider() {
@Override
public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
return new Command<ProcessApplicationReference>() {
public ProcessApplicationReference execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
DeploymentCache deploymentCache = configuration.getDeploymentCache();
ProcessDefinitionEntity definition = deploymentCache.findDeployedProcessDefinitionById(definitionId);
return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
}
};
}
@Override
public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).latestVersion().singleResult().getId();
}
};
}
Aggregations