use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class EvaluateDecisionCmd method execute.
@Override
public DmnDecisionResult execute(CommandContext commandContext) {
ensureOnlyOneNotNull("either decision definition id or key must be set", decisionDefinitionId, decisionDefinitionKey);
DecisionDefinition decisionDefinition = getDecisionDefinition(commandContext);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkEvaluateDecision(decisionDefinition);
}
return doEvaluateDecision(decisionDefinition, variables);
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class HistoryCleanupTest method prepareInstances.
private void prepareInstances(Integer processInstanceTimeToLive, Integer decisionTimeToLive, Integer caseTimeToLive) {
// update time to live
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(new Date(), DAYS_IN_THE_PAST));
// 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 < PROCESS_INSTANCES_COUNT; 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 < DECISION_INSTANCES_COUNT; i++) {
engineRule.getDecisionService().evaluateDecisionByKey("testDecision").variables(variables).evaluate();
}
// create 4 case instances
for (int i = 0; i < CASE_INSTANCES_COUNT; 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);
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class DecisionServiceTest method evaluateDecisionById.
@Deployment(resources = DMN_DECISION_LITERAL_EXPRESSION)
@Test
public void evaluateDecisionById() {
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
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 DecisionServiceTest method evaluateDecisionTableById.
@Deployment(resources = DMN_DECISION_TABLE)
@Test
public void evaluateDecisionTableById() {
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
DmnDecisionTableResult decisionResult = decisionService.evaluateDecisionTableById(decisionDefinition.getId(), createVariables());
assertThatDecisionHasResult(decisionResult, RESULT_OF_FIRST_VERSION);
}
use of org.camunda.bpm.engine.repository.DecisionDefinition in project camunda-bpm-platform by camunda.
the class DecisionServiceTest method evaluateDecisionByKeyWithNonExistingVersion.
@Deployment(resources = DMN_DECISION_LITERAL_EXPRESSION)
@Test
public void evaluateDecisionByKeyWithNonExistingVersion() {
DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery().singleResult();
thrown.expect(NotFoundException.class);
thrown.expectMessage("no decision definition deployed with key = 'decision' and version = '42'");
decisionService.evaluateDecisionByKey(decisionDefinition.getKey()).version(42).evaluate();
}
Aggregations