use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionTableEvaluationTest method testFailToEvaluateDecisionByIdWithTenantId.
public void testFailToEvaluateDecisionByIdWithTenantId() {
deploymentForTenant(TENANT_ONE, DMN_FILE);
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
try {
decisionService.evaluateDecisionTableById(decisionDefinition.getId()).variables(createVariables()).decisionDefinitionTenantId(TENANT_ONE).evaluate();
fail("BadUserRequestException exception");
} catch (BadUserRequestException e) {
assertThat(e.getMessage(), containsString("Cannot specify a tenant-id"));
}
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyRepositoryServiceTest method getPreviousDecisionDefinitionWithTenantId.
@Test
public void getPreviousDecisionDefinitionWithTenantId() {
testRule.deployForTenant(TENANT_ONE, DMN);
testRule.deployForTenant(TENANT_ONE, DMN);
testRule.deployForTenant(TENANT_ONE, DMN);
testRule.deployForTenant(TENANT_TWO, DMN);
testRule.deployForTenant(TENANT_TWO, DMN);
List<DecisionDefinition> latestDefinitions = repositoryService.createDecisionDefinitionQuery().latestVersion().orderByTenantId().asc().list();
DecisionDefinitionEntity previousDefinitionTenantOne = getPreviousDefinition((DecisionDefinitionEntity) latestDefinitions.get(0));
DecisionDefinitionEntity previousDefinitionTenantTwo = getPreviousDefinition((DecisionDefinitionEntity) latestDefinitions.get(1));
assertThat(previousDefinitionTenantOne.getVersion(), is(2));
assertThat(previousDefinitionTenantOne.getTenantId(), is(TENANT_ONE));
assertThat(previousDefinitionTenantTwo.getVersion(), is(1));
assertThat(previousDefinitionTenantTwo.getTenantId(), is(TENANT_TWO));
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method providerCalledWithDecisionDefinition.
@Test
public void providerCalledWithDecisionDefinition() {
ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(DMN_FILE);
DecisionDefinition deployedDecisionDefinition = engineRule.getRepositoryService().createDecisionDefinitionQuery().singleResult();
// if a decision definition is evaluated
engineRule.getDecisionService().evaluateDecisionTableByKey(DECISION_DEFINITION_KEY).variables(createVariables()).evaluate();
// then the tenant id provider is passed in the decision definition
DecisionDefinition passedDecisionDefinition = tenantIdProvider.dmnParameters.get(0).getDecisionDefinition();
assertThat(passedDecisionDefinition, is(notNullValue()));
assertThat(passedDecisionDefinition.getId(), is(deployedDecisionDefinition.getId()));
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class MultiTenancyDecisionEvaluationTest method testEvaluateDecisionByIdAuthenticatedTenant.
public void testEvaluateDecisionByIdAuthenticatedTenant() {
deploymentForTenant(TENANT_ONE, DMN_FILE);
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE));
DmnDecisionResult decisionResult = decisionService.evaluateDecisionById(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 MultiTenancyDecisionEvaluationTest method testFailToEvaluateDecisionByIdNoAuthenticatedTenants.
public void testFailToEvaluateDecisionByIdNoAuthenticatedTenants() {
deploymentForTenant(TENANT_ONE, DMN_FILE);
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
identityService.setAuthentication("user", null, null);
try {
decisionService.evaluateDecisionById(decisionDefinition.getId()).variables(createVariables()).evaluate();
fail("expected exception");
} catch (ProcessEngineException e) {
assertThat(e.getMessage(), containsString("Cannot evaluate the decision"));
}
}
Aggregations