Search in sources :

Example 6 with DmnDecisionTableResult

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

the class DmnDecisionTableResultTest method testNoResult.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testNoResult() {
    DmnDecisionTableResult results = evaluateWithMatchingRules();
    assertThat(results).isEmpty();
    assertThat(results.getFirstResult()).isNull();
    assertThat(results.getSingleResult()).isNull();
    assertThat(results.getSingleEntry()).isNull();
    assertThat(results.getSingleEntryTyped()).isNull();
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 7 with DmnDecisionTableResult

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

the class DmnDecisionTableResultTest method testSingleOutputTypedValue.

@Test
@DecisionResource(resource = RESULT_TEST_WITH_TYPES_DMN)
public void testSingleOutputTypedValue() {
    DmnDecisionTableResult decisionResult = evaluateWithMatchingRules(SINGLE_OUTPUT_VALUE);
    assertThat(decisionResult).hasSize(1);
    DmnDecisionRuleResult ruleResult = decisionResult.getFirstResult();
    TypedValue typedValue = ruleResult.getEntryTyped("firstOutput");
    assertThat(typedValue).isEqualTo(Variables.stringValue("singleValue"));
    typedValue = ruleResult.getEntryTyped("secondOutput");
    assertThat(typedValue).isNull();
    typedValue = ruleResult.getFirstEntryTyped();
    assertThat(typedValue).isEqualTo(Variables.stringValue("singleValue"));
    typedValue = ruleResult.getSingleEntryTyped();
    assertThat(typedValue).isEqualTo(Variables.stringValue("singleValue"));
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) DmnDecisionRuleResult(org.camunda.bpm.dmn.engine.DmnDecisionRuleResult) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 8 with DmnDecisionTableResult

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

the class DmnDecisionTableResultTest method testOutputList.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testOutputList() {
    DmnDecisionTableResult decisionResult = evaluateWithMatchingRules(SINGLE_OUTPUT_VALUE, MULTIPLE_OUTPUT_VALUES);
    List<Map<String, Object>> entryMapList = decisionResult.getResultList();
    assertThat(entryMapList).hasSize(2);
    Map<String, Object> firstResult = entryMapList.get(0);
    assertThat(firstResult).hasSize(1);
    assertThat(firstResult).containsEntry("firstOutput", "singleValue");
    Map<String, Object> secondResult = entryMapList.get(1);
    assertThat(secondResult).hasSize(2);
    assertThat(secondResult).containsEntry("firstOutput", "multipleValues1");
    assertThat(secondResult).containsEntry("secondOutput", "multipleValues2");
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) Map(java.util.Map) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 9 with DmnDecisionTableResult

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

the class DmnDecisionTableResultTest method testValueMap.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testValueMap() {
    DmnDecisionTableResult decisionResult = evaluateWithMatchingRules(MULTIPLE_OUTPUT_VALUES);
    DmnDecisionRuleResult ruleResult = decisionResult.getSingleResult();
    assertThat(ruleResult).hasSize(2);
    Map<String, Object> entryMap = ruleResult.getEntryMap();
    assertThat(entryMap).hasSize(2);
    assertThat(entryMap).containsEntry("firstOutput", "multipleValues1");
    assertThat(entryMap).containsEntry("secondOutput", "multipleValues2");
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) DmnDecisionRuleResult(org.camunda.bpm.dmn.engine.DmnDecisionRuleResult) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 10 with DmnDecisionTableResult

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

the class DmnEngineApiTest method shouldEvaluateDecisionTableWithVariableContext.

@Test
@DecisionResource(resource = ONE_RULE_DMN)
public void shouldEvaluateDecisionTableWithVariableContext() {
    DmnDecisionTableResult results = dmnEngine.evaluateDecisionTable(decision, createVariables().putValue("input", INPUT_VALUE).asVariableContext());
    assertThat(results).hasSingleResult().hasSingleEntry(EXPECTED_OUTPUT_VALUE);
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Aggregations

DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)56 Test (org.junit.Test)44 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)33 DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)20 Deployment (org.camunda.bpm.engine.test.Deployment)9 DmnDecisionRuleResult (org.camunda.bpm.dmn.engine.DmnDecisionRuleResult)5 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)5 Map (java.util.Map)4 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)4 DmnDecisionResultException (org.camunda.bpm.dmn.engine.impl.DmnDecisionResultException)2 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)2 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)2 DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)1 DecisionService (org.camunda.bpm.engine.DecisionService)1 VariableMap (org.camunda.bpm.engine.variable.VariableMap)1 Deployment (org.jboss.arquillian.container.test.api.Deployment)1