Search in sources :

Example 16 with DecisionResource

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

the class DmnEngineApiTest method shouldEvaluateDecisionWithVariableContext.

@Test
@DecisionResource(resource = ONE_RULE_DMN)
public void shouldEvaluateDecisionWithVariableContext() {
    DmnDecisionResult results = dmnEngine.evaluateDecision(decision, createVariables().putValue("input", INPUT_VALUE).asVariableContext());
    assertThat(results.getSingleEntry()).isNotNull().isEqualTo(EXPECTED_OUTPUT_VALUE);
}
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 17 with DecisionResource

use of org.camunda.bpm.dmn.engine.test.DecisionResource 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 18 with DecisionResource

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

the class ExpressionLanguageTest method testExecuteGroovyDmnEngineConfiguration.

@Test
@DecisionResource(resource = SCRIPT_DMN)
public void testExecuteGroovyDmnEngineConfiguration() {
    DmnEngine groovyEngine = createEngineWithDefaultExpressionLanguage("groovy");
    assertExample(groovyEngine, decision);
    verify(scriptEngineResolver, atLeastOnce()).getScriptEngineForLanguage("groovy");
    verify(scriptEngineResolver, never()).getScriptEngineForLanguage(JUEL);
}
Also used : DmnEngine(org.camunda.bpm.dmn.engine.DmnEngine) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 19 with DecisionResource

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

the class ExpressionLanguageTest method testGlobalExpressionLanguageDecisionTable.

@Test
@DecisionResource(resource = GROOVY_DECISION_TABLE_DMN)
public void testGlobalExpressionLanguageDecisionTable() {
    DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) decision.getDecisionLogic();
    for (DmnDecisionTableInputImpl dmnInput : decisionTable.getInputs()) {
        assertThat(dmnInput.getExpression().getExpressionLanguage()).isEqualTo("groovy");
    }
    for (DmnDecisionTableRuleImpl dmnRule : decisionTable.getRules()) {
        for (DmnExpressionImpl condition : dmnRule.getConditions()) {
            assertThat(condition.getExpressionLanguage()).isEqualTo("groovy");
        }
        for (DmnExpressionImpl conclusion : dmnRule.getConclusions()) {
            assertThat(conclusion.getExpressionLanguage()).isEqualTo("groovy");
        }
    }
    assertExample(dmnEngine, decision);
    verify(scriptEngineResolver, atLeastOnce()).getScriptEngineForLanguage("groovy");
    verify(scriptEngineResolver, never()).getScriptEngineForLanguage(JUEL);
}
Also used : DmnDecisionTableInputImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableInputImpl) DmnDecisionTableImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl) DmnExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl) DmnDecisionTableRuleImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableRuleImpl) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 20 with DecisionResource

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

the class ExpressionLanguageTest method testElResolution.

@Test
@DecisionResource(resource = CAPITAL_JUEL_DMN)
public void testElResolution() throws Exception {
    DmnEngine juelEngine = createEngineWithDefaultExpressionLanguage(JUEL);
    assertExample(juelEngine, decision);
    verify(elProvider, atLeastOnce()).createExpression(anyString());
    verify(scriptEngineResolver, never()).getScriptEngineForLanguage(JUEL.toUpperCase());
}
Also used : DmnEngine(org.camunda.bpm.dmn.engine.DmnEngine) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Aggregations

DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)56 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)56 Test (org.junit.Test)56 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)25 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)20 DmnEngine (org.camunda.bpm.dmn.engine.DmnEngine)10 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)8 DefaultDmnEngineConfiguration (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration)5 DmnDecisionResultEntries (org.camunda.bpm.dmn.engine.DmnDecisionResultEntries)4 DmnDecisionRuleResult (org.camunda.bpm.dmn.engine.DmnDecisionRuleResult)4 DmnDecisionResultException (org.camunda.bpm.dmn.engine.impl.DmnDecisionResultException)4 VariableContext (org.camunda.bpm.engine.variable.context.VariableContext)4 Map (java.util.Map)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 DmnDecisionLiteralExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl)1 DmnDecisionTableImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl)1 DmnDecisionTableInputImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableInputImpl)1 DmnDecisionTableRuleImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableRuleImpl)1 DmnExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl)1