Commit b014ca53 authored by cijujoseph's avatar cijujoseph

Added a DMN unit test example

parent 0a727eb8
package com.alfresco.aps.test.process;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.activiti.dmn.engine.RuleEngineExecutionResult;
import com.alfresco.aps.testutils.AbstractDmnTest;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:activiti.dmn.cfg.xml" })
public class DmnUnitTest extends AbstractDmnTest {
String decisonTableKey = "dmntest";
@Test
public void testProcessExecution() throws Exception {
Map<String, Object> processVariablesInput = new HashMap<>();
processVariablesInput.put("input", "xyz");
RuleEngineExecutionResult result = ruleService.executeDecisionByKey(decisonTableKey, processVariablesInput);
Assert.assertNotNull(result);
Assert.assertSame(result.getResultVariables().get("output").getClass(), String.class);
Assert.assertEquals(result.getResultVariables().get("output"), "abc");
}
}
\ No newline at end of file
<definitions xmlns="http://www.omg.org/spec/DMN/20151130" id="definition_63063" name="dmntest" namespace="http://www.activiti.org/dmn">
<decision id="dmntest" name="dmntest">
<decisionTable id="decisionTable_63063" hitPolicy="FIRST">
<input label="input">
<inputExpression id="inputExpression_3" typeRef="string">
<text>input</text>
</inputExpression>
</input>
<output id="outputExpression_4" label="output" name="output" typeRef="string"/>
<rule>
<inputEntry id="inputEntry_3_1">
<text>== "xyz"</text>
</inputEntry>
<outputEntry id="outputEntry_4_1">
<text>"abc"</text>
</outputEntry>
</rule>
</decisionTable>
</decision>
</definitions>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment