Search in sources :

Example 11 with DecisionDefinition

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"));
    }
}
Also used : DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 12 with DecisionDefinition

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);
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 13 with DecisionDefinition

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);
}
Also used : DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition) Date(java.util.Date)

Example 14 with DecisionDefinition

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));
}
Also used : DecisionDefinitionQuery(org.camunda.bpm.engine.repository.DecisionDefinitionQuery) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Example 15 with DecisionDefinition

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));
}
Also used : DecisionDefinitionQuery(org.camunda.bpm.engine.repository.DecisionDefinitionQuery) DecisionDefinition(org.camunda.bpm.engine.repository.DecisionDefinition)

Aggregations

DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)68 Test (org.junit.Test)21 Deployment (org.camunda.bpm.engine.test.Deployment)18 DecisionDefinitionQuery (org.camunda.bpm.engine.repository.DecisionDefinitionQuery)10 Date (java.util.Date)6 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)5 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricDecisionInstanceEntity (org.camunda.bpm.engine.impl.history.event.HistoricDecisionInstanceEntity)3 Response (com.jayway.restassured.response.Response)2 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)2 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)2 HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)2 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)2 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)2 GetDeploymentResourceCmd (org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd)2 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)2