Search in sources :

Example 6 with DmnDecisionResult

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

the class ExpressionEvaluationTest method testHasVariableContext.

@Test
@DecisionResource(resource = DMN_VARIABLE_CONTEXT)
public void testHasVariableContext() {
    DmnDecisionResult decisionResult = dmnEngine.evaluateDecision(decision, Variables.createVariables().putValue("in", 3));
    assertThat(decisionResult.getSingleEntry()).isEqualTo(true);
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 7 with DmnDecisionResult

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

the class FeelIntegrationTest method testFeelInputExpressionWithCustomEngine.

@Test
@DecisionResource(resource = DMN)
public void testFeelInputExpressionWithCustomEngine() {
    DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
    configuration.setDefaultInputExpressionExpressionLanguage(DefaultDmnEngineConfiguration.FEEL_EXPRESSION_LANGUAGE);
    DmnEngine engine = configuration.buildEngine();
    // stubbing the default FEEL engine behavior
    doReturn(3).when(feelEngineSpy).evaluateSimpleExpression(eq("score"), any(VariableContext.class));
    DmnDecisionResult decisionResult = engine.evaluateDecision(decision, Variables.createVariables().putValue("score", 3));
    assertThat(decisionResult.getSingleEntry()).isEqualTo("a");
    verify(feelEngineSpy).evaluateSimpleExpression(anyString(), any(VariableContext.class));
}
Also used : DmnEngine(org.camunda.bpm.dmn.engine.DmnEngine) DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) VariableContext(org.camunda.bpm.engine.variable.context.VariableContext) DefaultDmnEngineConfiguration(org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 8 with DmnDecisionResult

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

the class FeelIntegrationTest method testFeelInputEntry.

@Test
@DecisionResource(resource = DMN)
public void testFeelInputEntry() {
    DmnDecisionResult decisionResult = dmnEngine.evaluateDecision(decision, Variables.createVariables().putValue("score", 3));
    assertThat(decisionResult.getSingleEntry()).isEqualTo("a");
    verify(feelEngineSpy, atLeastOnce()).evaluateSimpleUnaryTests(anyString(), anyString(), any(VariableContext.class));
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) VariableContext(org.camunda.bpm.engine.variable.context.VariableContext) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 9 with DmnDecisionResult

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

the class FeelIntegrationTest method testFeelInputEntryWithAlternativeName.

@Test
@DecisionResource(resource = DMN)
public void testFeelInputEntryWithAlternativeName() {
    DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
    configuration.setDefaultInputEntryExpressionLanguage("feel");
    DmnEngine dmnEngine = configuration.buildEngine();
    DmnDecisionResult decisionResult = dmnEngine.evaluateDecision(decision, Variables.createVariables().putValue("score", 3));
    assertThat(decisionResult.getSingleEntry()).isEqualTo("a");
    verify(feelEngineSpy, atLeastOnce()).evaluateSimpleUnaryTests(anyString(), anyString(), any(VariableContext.class));
}
Also used : DmnEngine(org.camunda.bpm.dmn.engine.DmnEngine) DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) VariableContext(org.camunda.bpm.engine.variable.context.VariableContext) DefaultDmnEngineConfiguration(org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 10 with DmnDecisionResult

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

the class DmnDecisionEvaluationTest method shouldEvaluateDecisionWithCollectHitPolicyReturningAList.

@Test
public void shouldEvaluateDecisionWithCollectHitPolicyReturningAList() {
    DmnDecisionRequirementsGraph graph = dmnEngine.parseDecisionRequirementsGraph(IoUtil.fileAsStream(DRG_COLLECT_DMN));
    initVariables();
    variables.putValue("dayType", "WeekDay");
    DmnDecisionResult result = dmnEngine.evaluateDecision(graph.getDecision("dish-decision"), variables);
    assertThat(result.getSingleEntry()).isNotNull().isEqualTo("Steak");
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) DmnDecisionRequirementsGraph(org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Aggregations

DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)54 Test (org.junit.Test)40 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)29 DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)25 HashMap (java.util.HashMap)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 Matchers.anyString (org.mockito.Matchers.anyString)6 Deployment (org.camunda.bpm.engine.test.Deployment)5 DmnDecisionResultEntries (org.camunda.bpm.dmn.engine.DmnDecisionResultEntries)4 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)4 VariableContext (org.camunda.bpm.engine.variable.context.VariableContext)4 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)4 DmnEngine (org.camunda.bpm.dmn.engine.DmnEngine)3 DefaultDmnEngineConfiguration (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration)3 MockDecisionResultBuilder (org.camunda.bpm.engine.rest.helper.MockDecisionResultBuilder)3 DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)2 DmnDecisionResultException (org.camunda.bpm.dmn.engine.impl.DmnDecisionResultException)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)1