Search in sources :

Example 36 with DecisionResource

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

the class DmnDecisionTableResultTest method testSingleOutputNoName.

@Test
@DecisionResource(resource = RESULT_TEST_WITH_SINGLE_UNNAMED_OUTPUT_DMN)
public void testSingleOutputNoName() {
    DmnDecisionTableResult decisionResult = evaluateDecisionTable();
    assertThat(decisionResult).hasSize(1);
    assertThat(decisionResult.getFirstResult()).hasSize(1);
    assertThat(decisionResult.getFirstResult().getSingleEntry()).isEqualTo("outputValue");
    assertThat(decisionResult.getFirstResult().get(null)).isEqualTo("outputValue");
    assertThat(decisionResult.getSingleEntry()).isEqualTo("outputValue");
}
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 37 with DecisionResource

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

the class DmnDecisionTableResultTest method testSingleEntryUntypedValue.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testSingleEntryUntypedValue() {
    DmnDecisionTableResult decisionResult = evaluateWithMatchingRules(SINGLE_OUTPUT_VALUE);
    TypedValue typedValue = decisionResult.getSingleEntryTyped();
    assertThat(typedValue).isEqualTo(Variables.untypedValue("singleValue"));
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) 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 38 with DecisionResource

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

the class DmnDecisionTableResultTest method testSingleEntryTypedValue.

@Test
@DecisionResource(resource = RESULT_TEST_WITH_TYPES_DMN)
public void testSingleEntryTypedValue() {
    DmnDecisionTableResult decisionResult = evaluateWithMatchingRules(SINGLE_OUTPUT_VALUE);
    TypedValue typedValue = decisionResult.getSingleEntryTyped();
    assertThat(typedValue).isEqualTo(Variables.stringValue("singleValue"));
}
Also used : DmnDecisionTableResult(org.camunda.bpm.dmn.engine.DmnDecisionTableResult) 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 39 with DecisionResource

use of org.camunda.bpm.dmn.engine.test.DecisionResource 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 40 with DecisionResource

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

the class DmnDecisionTableResultTest method testNoOutputValue.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testNoOutputValue() {
    DmnDecisionTableResult decisionResult = evaluateWithMatchingRules(NO_OUTPUT_VALUE);
    assertThat(decisionResult).hasSize(1);
    assertNoOutputValue(decisionResult.getFirstResult());
    assertThat(decisionResult.getSingleEntry()).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)

Aggregations

DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)56 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)56 Test (org.junit.Test)56 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)25 DmnDecisionTableResult (org.camunda.bpm.dmn.engine.DmnDecisionTableResult)20 DmnEngine (org.camunda.bpm.dmn.engine.DmnEngine)10 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)8 DefaultDmnEngineConfiguration (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration)5 DmnDecisionResultEntries (org.camunda.bpm.dmn.engine.DmnDecisionResultEntries)4 DmnDecisionRuleResult (org.camunda.bpm.dmn.engine.DmnDecisionRuleResult)4 DmnDecisionResultException (org.camunda.bpm.dmn.engine.impl.DmnDecisionResultException)4 VariableContext (org.camunda.bpm.engine.variable.context.VariableContext)4 Map (java.util.Map)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 DmnDecisionLiteralExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl)1 DmnDecisionTableImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl)1 DmnDecisionTableInputImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableInputImpl)1 DmnDecisionTableRuleImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableRuleImpl)1 DmnExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl)1