JUnit with DmnEngineRule

Hi there,
I have managed to create a decision table with composer. Now I want to create a Unit test to make sure it works but I’m getting the following exception

java.lang.NoClassDefFoundError: de/odysseus/el/util/SimpleContext

at org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration.initElProvider(DefaultDmnEngineConfiguration.java:131)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration.init(DefaultDmnEngineConfiguration.java:81)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration.buildEngine(DefaultDmnEngineConfiguration.java:72)
at org.camunda.bpm.dmn.engine.test.DmnEngineRule.starting(DmnEngineRule.java:83)
at org.junit.rules.TestWatcher.startingQuietly(TestWatcher.java:108)
at org.junit.rules.TestWatcher.access$000(TestWatcher.java:46)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:53)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by: java.lang.ClassNotFoundException: de.odysseus.el.util.SimpleContext
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
… 22 more

This is my test in Java
import org.camunda.bpm.dmn.engine.DmnDecision;
import org.camunda.bpm.dmn.engine.DmnDecisionTableResult;
import org.camunda.bpm.dmn.engine.DmnEngine;
import org.camunda.bpm.dmn.engine.test.DmnEngineRule;
import org.camunda.bpm.engine.variable.VariableMap;
import org.camunda.bpm.engine.variable.Variables;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.io.InputStream;

public class DecisionTest {
@Rule
public DmnEngineRule dmnEngineRule = new DmnEngineRule();

public DmnEngine dmnEngine;
public DmnDecision decision;

@Before
public void parseDecision() {
    InputStream inputStream = DecisionTest.class
            .getResourceAsStream("decision_product_purchase.dmn");
    dmnEngine = dmnEngineRule.getDmnEngine();
    decision = dmnEngine.parseDecision("decision_product_purchase", inputStream);
}

@Test
public void test() {
    //create and add variables
    VariableMap variables = Variables.createVariables();
    variables.putValue("product", "starter kit");
    DmnDecisionTableResult result = dmnEngine.evaluateDecisionTable(decision, variables);
    System.out.println(result);
}

}

And this is my pom

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
    <relativePath/>
</parent>

<properties>
    <java.version>11</java.version>
</properties>

<groupId>com.livingdna.rules</groupId>
<artifactId>decision-service</artifactId>
<version>1.0.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>org.camunda.bpm.springboot</groupId>
        <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
        <version>3.3.3</version>
    </dependency>

    <dependency>
        <groupId>org.camunda.bpm.springboot</groupId>
        <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
        <version>3.3.3</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>1.7.1</version>
        <scope>test</scope>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Any idea what’s wrong with this?

Fixed by adding the following dependencies

<dependency>
        <groupId>de.odysseus.juel</groupId>
        <artifactId>juel-api</artifactId>
        <version>2.2.7</version>
    </dependency>

    <dependency>
        <groupId>de.odysseus.juel</groupId>
        <artifactId>juel-impl</artifactId>
        <version>2.2.7</version>
    </dependency>

    <dependency>
        <groupId>de.odysseus.juel</groupId>
        <artifactId>juel-spi</artifactId>
        <version>2.2.7</version>
    </dependency>
1 Like