Search in sources :

Example 6 with DmnDecisionRuleResult

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

the class DmnDecisionTableResultImpl method getResultList.

@Override
public List<Map<String, Object>> getResultList() {
    List<Map<String, Object>> entryMapList = new ArrayList<Map<String, Object>>();
    for (DmnDecisionRuleResult ruleResult : ruleResults) {
        Map<String, Object> entryMap = ruleResult.getEntryMap();
        entryMapList.add(entryMap);
    }
    return entryMapList;
}
Also used : DmnDecisionRuleResult(org.camunda.bpm.dmn.engine.DmnDecisionRuleResult) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 7 with DmnDecisionRuleResult

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

the class DecisionServiceDelegate method evaluate.

public boolean evaluate(DelegateCaseExecution caseExecution) {
    DecisionService decisionService = caseExecution.getProcessEngineServices().getDecisionService();
    DmnDecisionTableResult result = evaluateDecision(decisionService, caseExecution);
    DmnDecisionRuleResult singleResult = result.getSingleResult();
    return (Boolean) singleResult.getSingleEntry();
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) DmnDecisionRuleResult(org.camunda.bpm.dmn.engine.DmnDecisionRuleResult) DecisionService(org.camunda.bpm.engine.DecisionService)

Example 8 with DmnDecisionRuleResult

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

the class DmnDecisionTableResultTest method testMultipleResults.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testMultipleResults() {
    DmnDecisionTableResult decisionResult = evaluateWithMatchingRules(NO_OUTPUT_VALUE, SINGLE_OUTPUT_VALUE, MULTIPLE_OUTPUT_VALUES);
    assertThat(decisionResult).hasSize(3);
    DmnDecisionRuleResult ruleResult = decisionResult.get(0);
    assertNoOutputValue(ruleResult);
    ruleResult = decisionResult.get(1);
    assertSingleOutputValue(ruleResult);
    ruleResult = decisionResult.get(2);
    assertMultipleOutputValues(ruleResult);
    ruleResult = decisionResult.getFirstResult();
    assertNoOutputValue(ruleResult);
    try {
        decisionResult.getSingleResult();
        failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
    } catch (DmnDecisionResultException e) {
        assertThat(e).hasMessageStartingWith("DMN-01008").hasMessageContaining("singleValue").hasMessageContaining("multipleValues1").hasMessageContaining("multipleValues2");
    }
    try {
        decisionResult.getSingleEntry();
        failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
    } catch (DmnDecisionResultException e) {
        assertThat(e).hasMessageStartingWith("DMN-01008").hasMessageContaining("singleValue").hasMessageContaining("multipleValues1").hasMessageContaining("multipleValues2");
    }
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) DmnDecisionRuleResult(org.camunda.bpm.dmn.engine.DmnDecisionRuleResult) DmnDecisionResultException(org.camunda.bpm.dmn.engine.impl.DmnDecisionResultException) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 9 with DmnDecisionRuleResult

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

the class DmnDecisionTableResultImpl method wrap.

public static DmnDecisionTableResultImpl wrap(DmnDecisionResult decisionResult) {
    List<DmnDecisionRuleResult> ruleResults = new ArrayList<DmnDecisionRuleResult>();
    for (DmnDecisionResultEntries result : decisionResult) {
        DmnDecisionRuleResultImpl ruleResult = new DmnDecisionRuleResultImpl();
        ruleResult.putAllValues(result.getEntryMapTyped());
        ruleResults.add(ruleResult);
    }
    return new DmnDecisionTableResultImpl(ruleResults);
}
Also used : DmnDecisionRuleResult(org.camunda.bpm.dmn.engine.DmnDecisionRuleResult) DmnDecisionResultEntries(org.camunda.bpm.dmn.engine.DmnDecisionResultEntries) ArrayList(java.util.ArrayList)

Aggregations

DmnDecisionRuleResult (org.camunda.bpm.dmn.engine.DmnDecisionRuleResult)9 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)5 DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)4 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)2 Map (java.util.Map)1 DmnDecisionResultEntries (org.camunda.bpm.dmn.engine.DmnDecisionResultEntries)1 DmnDecisionResultException (org.camunda.bpm.dmn.engine.impl.DmnDecisionResultException)1 DecisionService (org.camunda.bpm.engine.DecisionService)1