Search in sources :

Example 46 with DecisionResource

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

the class ExpressionEvaluationTest method testOverrideInputVariableName.

@Test
@DecisionResource(resource = DMN_OVERRIDE_INPUT_VARIABLE)
public void testOverrideInputVariableName() {
    DmnDecisionResult decisionResult = dmnEngine.evaluateDecision(decision, Variables.createVariables().putValue("in", 2));
    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 47 with DecisionResource

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

the class ExpressionLanguageTest method testGlobalExpressionLanguageDecisionLiteralExpression.

@Test
@DecisionResource(resource = GROOVY_DECISION_LITERAL_EXPRESSION_DMN)
public void testGlobalExpressionLanguageDecisionLiteralExpression() {
    DmnDecisionLiteralExpressionImpl decisionLiteralExpression = (DmnDecisionLiteralExpressionImpl) decision.getDecisionLogic();
    assertThat(decisionLiteralExpression.getExpression().getExpressionLanguage()).isEqualTo("groovy");
    dmnEngine.evaluateDecision(decision, Variables.createVariables().putValue("a", 2).putValue("b", 3));
    verify(scriptEngineResolver, atLeastOnce()).getScriptEngineForLanguage("groovy");
    verify(scriptEngineResolver, never()).getScriptEngineForLanguage(JUEL);
}
Also used : DmnDecisionLiteralExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 48 with DecisionResource

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

the class ExpressionLanguageTest method testExecuteLiteralExpressionWithGroovyDmnEngineConfiguration.

@Test
@DecisionResource(resource = DECISION_WITH_LITERAL_EXPRESSION_DMN)
public void testExecuteLiteralExpressionWithGroovyDmnEngineConfiguration() {
    DmnEngine juelEngine = createEngineWithDefaultExpressionLanguage("groovy");
    juelEngine.evaluateDecision(decision, Variables.createVariables().putValue("a", 1).putValue("b", 2));
    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 49 with DecisionResource

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

the class ExpressionLanguageTest method testExecuteJuelDmnEngineConfiguration.

@Test
@DecisionResource(resource = SCRIPT_DMN)
public void testExecuteJuelDmnEngineConfiguration() {
    DmnEngine juelEngine = createEngineWithDefaultExpressionLanguage(JUEL);
    assertExample(juelEngine, decision);
    verify(elProvider, atLeastOnce()).createExpression(anyString());
}
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 50 with DecisionResource

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

the class FeelIntegrationTest method testFeelOutputEntryWithCustomEngine.

@Test
@DecisionResource(resource = DMN)
public void testFeelOutputEntryWithCustomEngine() {
    DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
    configuration.setDefaultOutputEntryExpressionLanguage(DefaultDmnEngineConfiguration.FEEL_EXPRESSION_LANGUAGE);
    DmnEngine engine = configuration.buildEngine();
    // stubbing the default FEEL engine behavior
    doReturn("a").when(feelEngineSpy).evaluateSimpleExpression(eq("\"a\""), 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)

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