Search in sources :

Example 36 with DmnDecisionTableResult

use of org.camunda.bpm.dmn.engine.DmnDecisionTableResult in project camunda-bpm-platform by camunda.

the class DecisionContextSwitchTest method shouldSwitchContextWhenUsingDecisionService.

@Test
@OperateOnDeployment("clientDeployment")
public void shouldSwitchContextWhenUsingDecisionService() {
    DmnDecisionTableResult decisionResult = decisionService.evaluateDecisionTableByKey("decision", Variables.createVariables());
    assertEquals("ok", decisionResult.getFirstResult().getFirstEntry());
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 37 with DmnDecisionTableResult

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

Example 38 with DmnDecisionTableResult

use of org.camunda.bpm.dmn.engine.DmnDecisionTableResult in project camunda-bpm-platform by camunda.

the class DecisionServiceTest method evaluateDecisionTableByKeyAndNullVersion.

@Deployment(resources = DMN_DECISION_TABLE)
@Test
public void evaluateDecisionTableByKeyAndNullVersion() {
    testRule.deploy(DMN_DECISION_TABLE_V2);
    DmnDecisionTableResult decisionResult = decisionService.evaluateDecisionTableByKeyAndVersion(DECISION_DEFINITION_KEY, null, createVariables());
    assertThatDecisionHasResult(decisionResult, RESULT_OF_SECOND_VERSION);
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 39 with DmnDecisionTableResult

use of org.camunda.bpm.dmn.engine.DmnDecisionTableResult in project camunda-bpm-platform by camunda.

the class DecisionServiceDelegate method evaluate.

public boolean evaluate(DelegateCaseExecution caseExecution) {
    DecisionService decisionService = caseExecution.getProcessEngineServices().getDecisionService();
    DmnDecisionTableResult result = evaluateDecision(decisionService, caseExecution);
    DmnDecisionRuleResult singleResult = result.getSingleResult();
    return (Boolean) singleResult.getSingleEntry();
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) DmnDecisionRuleResult(org.camunda.bpm.dmn.engine.DmnDecisionRuleResult) DecisionService(org.camunda.bpm.engine.DecisionService)

Example 40 with DmnDecisionTableResult

use of org.camunda.bpm.dmn.engine.DmnDecisionTableResult in project camunda-engine-dmn by camunda.

the class DmnExampleVerifier method assertExample.

public static void assertExample(DmnEngine engine, DmnDecision decision) {
    VariableMap variables = Variables.createVariables();
    variables.put("status", "bronze");
    variables.put("sum", 200);
    DmnDecisionTableResult results = engine.evaluateDecisionTable(decision, variables);
    assertThat(results).hasSingleResult().containsKeys("result", "reason").containsEntry("result", "notok").containsEntry("reason", "work on your status first, as bronze you're not going to get anything");
    variables.put("status", "silver");
    results = engine.evaluateDecisionTable(decision, variables);
    assertThat(results).hasSingleResult().containsKeys("result", "reason").containsEntry("result", "ok").containsEntry("reason", "you little fish will get what you want");
    variables.put("sum", 1200);
    results = engine.evaluateDecisionTable(decision, variables);
    assertThat(results).hasSingleResult().containsKeys("result", "reason").containsEntry("result", "notok").containsEntry("reason", "you took too much man, you took too much!");
    variables.put("status", "gold");
    variables.put("sum", 200);
    results = engine.evaluateDecisionTable(decision, variables);
    assertThat(results).hasSingleResult().containsKeys("result", "reason").containsEntry("result", "ok").containsEntry("reason", "you get anything you want");
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) VariableMap(org.camunda.bpm.engine.variable.VariableMap)

Aggregations

DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)56 Test (org.junit.Test)44 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)33 DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)20 Deployment (org.camunda.bpm.engine.test.Deployment)9 DmnDecisionRuleResult (org.camunda.bpm.dmn.engine.DmnDecisionRuleResult)5 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)5 Map (java.util.Map)4 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)4 DmnDecisionResultException (org.camunda.bpm.dmn.engine.impl.DmnDecisionResultException)2 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)2 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)2 DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)1 DecisionService (org.camunda.bpm.engine.DecisionService)1 VariableMap (org.camunda.bpm.engine.variable.VariableMap)1 Deployment (org.jboss.arquillian.container.test.api.Deployment)1