Search in sources :

Example 16 with DefaultDmnEngineConfiguration

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

the class DmnDataTypeTransformerTest method initRegistry.

@Before
public void initRegistry() {
    DmnEngineConfiguration configuration = dmnEngine.getConfiguration();
    registry = ((DefaultDmnEngineConfiguration) configuration).getTransformer().getDataTypeTransformerRegistry();
}
Also used : DmnEngineConfiguration(org.camunda.bpm.dmn.engine.DmnEngineConfiguration) DefaultDmnEngineConfiguration(org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration) DefaultDmnEngineConfiguration(org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration) Before(org.junit.Before)

Example 17 with DefaultDmnEngineConfiguration

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

the class ExpressionCachingTest method setup.

@Before
public void setup() {
    ScriptEngineManager scriptEngineManager = spy(new ScriptEngineManager());
    when(scriptEngineManager.getEngineByName(anyString())).then(new Answer<ScriptEngine>() {

        public ScriptEngine answer(InvocationOnMock invocation) throws Throwable {
            scriptEngineSpy = spy((ScriptEngine) invocation.callRealMethod());
            compilableSpy = (Compilable) scriptEngineSpy;
            return scriptEngineSpy;
        }
    });
    DefaultDmnEngineConfiguration configuration = new DefaultDmnEngineConfiguration();
    configuration.setScriptEngineResolver(new DefaultScriptEngineResolver(scriptEngineManager));
    configuration.init();
    elProviderSpy = spy(configuration.getElProvider());
    configuration.setElProvider(elProviderSpy);
    expressionEvaluationHandler = new ExpressionEvaluationHandler(configuration);
}
Also used : ExpressionEvaluationHandler(org.camunda.bpm.dmn.engine.impl.evaluation.ExpressionEvaluationHandler) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Compilable(javax.script.Compilable) ScriptEngineManager(javax.script.ScriptEngineManager) DefaultScriptEngineResolver(org.camunda.bpm.dmn.engine.impl.el.DefaultScriptEngineResolver) DefaultDmnEngineConfiguration(org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration) ScriptEngine(javax.script.ScriptEngine) Before(org.junit.Before)

Example 18 with DefaultDmnEngineConfiguration

use of org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration 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)

Example 19 with DefaultDmnEngineConfiguration

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

the class FeelIntegrationTest method testFeelInputExpression.

@Test
@DecisionResource(resource = DMN)
public void testFeelInputExpression() {
    DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
    configuration.setDefaultInputExpressionExpressionLanguage(DefaultDmnEngineConfiguration.FEEL_EXPRESSION_LANGUAGE);
    DmnEngine engine = configuration.buildEngine();
    try {
        engine.evaluateDecision(decision, Variables.createVariables().putValue("score", 3));
        failBecauseExceptionWasNotThrown(UnsupportedOperationException.class);
    } catch (UnsupportedOperationException e) {
        assertThat(e).hasMessageStartingWith("FEEL-01016");
        verify(feelEngineSpy).evaluateSimpleExpression(anyString(), any(VariableContext.class));
    }
}
Also used : DmnEngine(org.camunda.bpm.dmn.engine.DmnEngine) 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

DefaultDmnEngineConfiguration (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration)19 Test (org.junit.Test)11 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)7 DmnEngine (org.camunda.bpm.dmn.engine.DmnEngine)6 DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)5 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)5 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)3 VariableContext (org.camunda.bpm.engine.variable.context.VariableContext)3 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 Compilable (javax.script.Compilable)1 ScriptEngine (javax.script.ScriptEngine)1 ScriptEngineManager (javax.script.ScriptEngineManager)1 DmnEngineConfiguration (org.camunda.bpm.dmn.engine.DmnEngineConfiguration)1 DmnDecisionTableEvaluationListener (org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener)1 DefaultScriptEngineResolver (org.camunda.bpm.dmn.engine.impl.el.DefaultScriptEngineResolver)1 ExpressionEvaluationHandler (org.camunda.bpm.dmn.engine.impl.evaluation.ExpressionEvaluationHandler)1 DmnScriptEngineResolver (org.camunda.bpm.dmn.engine.impl.spi.el.DmnScriptEngineResolver)1 ElProvider (org.camunda.bpm.dmn.engine.impl.spi.el.ElProvider)1 DmnDataTypeTransformer (org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer)1