use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionTableEvaluationTest method testFailToEvaluateDecisionByIdNoAuthenticatedTenants.
public void testFailToEvaluateDecisionByIdNoAuthenticatedTenants() {
deploymentForTenant(TENANT_ONE, DMN_FILE);
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
identityService.setAuthentication("user", null, null);
try {
decisionService.evaluateDecisionTableById(decisionDefinition.getId()).variables(createVariables()).evaluate();
fail("expected exception");
} catch (ProcessEngineException e) {
assertThat(e.getMessage(), containsString("Cannot evaluate the decision"));
}
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionTableEvaluationTest method testEvaluateDecisionByIdAuthenticatedTenant.
public void testEvaluateDecisionByIdAuthenticatedTenant() {
deploymentForTenant(TENANT_ONE, DMN_FILE);
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
DmnDecisionTableResult decisionResult = decisionService.evaluateDecisionTableById(decisionDefinition.getId()).variables(createVariables()).evaluate();
assertThatDecisionHasResult(decisionResult, RESULT_OF_FIRST_VERSION);
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyCleanableHistoricDecisionInstanceReportCmdTenantCheckTest method prepareDecisionInstances.
protected void prepareDecisionInstances(String key, int daysInThePast, Integer historyTimeToLive, int instanceCount, String tenantId) {
List<DecisionDefinition> decisionDefinitions = null;
if (tenantId != null) {
decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).tenantIdIn(tenantId).list();
} else {
decisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).withoutTenantId().list();
}
assertEquals(1, decisionDefinitions.size());
repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinitions.get(0).getId(), historyTimeToLive);
Date oldCurrentTime = ClockUtil.getCurrentTime();
ClockUtil.setCurrentTime(DateUtils.addDays(oldCurrentTime, daysInThePast));
Map<String, Object> variables = Variables.createVariables().putValue("status", "silver").putValue("sum", 723);
for (int i = 0; i < instanceCount; i++) {
if (tenantId != null) {
engineRule.getDecisionService().evaluateDecisionByKey(key).decisionDefinitionTenantId(tenantId).variables(variables).evaluate();
} else {
engineRule.getDecisionService().evaluateDecisionByKey(key).decisionDefinitionWithoutTenantId().variables(variables).evaluate();
}
}
ClockUtil.setCurrentTime(oldCurrentTime);
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionDefinitionQueryTest method testQueryByLatestWithTenantIdsIncludeDefinitionsWithoutTenantId.
public void testQueryByLatestWithTenantIdsIncludeDefinitionsWithoutTenantId() {
// deploy a second version without tenant id
deployment(DMN);
// deploy a third version for tenant one
deploymentForTenant(TENANT_ONE, DMN);
deploymentForTenant(TENANT_ONE, DMN);
DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).latestVersion().tenantIdIn(TENANT_ONE, TENANT_TWO).includeDecisionDefinitionsWithoutTenantId();
assertThat(query.count(), is(3L));
Map<String, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list());
assertThat(decisionDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(3));
assertThat(decisionDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1));
assertThat(decisionDefinitionsForTenant.get(null).getVersion(), is(2));
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionDefinitionQueryTest method testQueryByLatestNoTenantIdSet.
public void testQueryByLatestNoTenantIdSet() {
// deploy a second version for tenant one
deploymentForTenant(TENANT_ONE, DMN);
DecisionDefinitionQuery query = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(DECISION_DEFINITION_KEY).latestVersion();
// one definition for each tenant
assertThat(query.count(), is(3L));
Map<String, DecisionDefinition> decisionDefinitionsForTenant = getDecisionDefinitionsForTenant(query.list());
assertThat(decisionDefinitionsForTenant.get(TENANT_ONE).getVersion(), is(2));
assertThat(decisionDefinitionsForTenant.get(TENANT_TWO).getVersion(), is(1));
assertThat(decisionDefinitionsForTenant.get(null).getVersion(), is(1));
}
Aggregations