use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionDefinitionQueryTest method testQueryByLatestWithTenantIds.
public void testQueryByLatestWithTenantIds() {
// deploy a second version for tenant one
deploymentForTenant(TENANT_ONE, DMN);
DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).latestVersion().tenantIdIn(TENANT_ONE, TENANT_TWO).orderByTenantId().asc();
// one definition for each tenant
assertThat(query.count(), is(2L));
Map<String, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list());
assertThat(decisionDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2));
assertThat(decisionDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1));
}
use of org.camunda.bpm.engine.repository.DecisionDefinition 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();
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class DecisionDefinitionAuthorizationTest method testQueryWithReadPermissionOnOneDecisionDefinition.
public void testQueryWithReadPermissionOnOneDecisionDefinition() {
// given user gets read permission on the decision definition
createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ);
// when
DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery();
// then
verifyQueryResults(query, 1);
DecisionDefinition definition = query.singleResult();
assertNotNull(definition);
assertEquals(DECISION_DEFINITION_KEY, definition.getKey());
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class DecisionDefinitionAuthorizationTest method testGetDecisionDefinition.
public void testGetDecisionDefinition() {
// given
String decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).getId();
createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ);
// when
DecisionDefinition decisionDefinition = repositoryService.getDecisionDefinition(decisionDefinitionId);
// then
assertNotNull(decisionDefinition);
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class EvaluateDecisionAuthorizationTest method evaluateDecisionById.
@Test
@Deployment(resources = DMN_FILE)
public void evaluateDecisionById() {
// given
DecisionDefinition decisionDefinition = engineRule.getRepositoryService().createDecisionDefinitionQuery().singleResult();
// when
authRule.init(scenario).withUser("userId").bindResource("decisionDefinitionKey", DECISION_DEFINITION_KEY).start();
DmnDecisionTableResult decisionResult = engineRule.getDecisionService().evaluateDecisionTableById(decisionDefinition.getId(), createVariables());
// then
if (authRule.assertScenario(scenario)) {
assertThatDecisionHasExpectedResult(decisionResult);
}
}
Aggregations