Search in sources :

Example 1 with DmnDecisionResult

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

the class DmnDecisionResultTest method testMultipleOutputValues.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testMultipleOutputValues() {
    DmnDecisionResult decisionResult = evaluateWithMatchingRules(MULTIPLE_OUTPUT_VALUES);
    assertThat(decisionResult).hasSize(1);
    assertMultipleOutputValues(decisionResult.getFirstResult());
    try {
        decisionResult.getSingleEntry();
        failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
    } catch (DmnDecisionResultException e) {
        assertThat(e).hasMessageStartingWith("DMN-01010").hasMessageContaining("multipleValues1").hasMessageContaining("multipleValues2");
    }
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) 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 2 with DmnDecisionResult

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

the class DmnDecisionResultTest method testMultipleResults.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testMultipleResults() {
    DmnDecisionResult decisionResult = evaluateWithMatchingRules(NO_OUTPUT_VALUE, SINGLE_OUTPUT_VALUE, MULTIPLE_OUTPUT_VALUES);
    assertThat(decisionResult).hasSize(3);
    DmnDecisionResultEntries 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-01011").hasMessageContaining("singleValue").hasMessageContaining("multipleValues1").hasMessageContaining("multipleValues2");
    }
    try {
        decisionResult.getSingleEntry();
        failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
    } catch (DmnDecisionResultException e) {
        assertThat(e).hasMessageStartingWith("DMN-01011").hasMessageContaining("singleValue").hasMessageContaining("multipleValues1").hasMessageContaining("multipleValues2");
    }
}
Also used : DmnDecisionResultEntries(org.camunda.bpm.dmn.engine.DmnDecisionResultEntries) DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) 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 3 with DmnDecisionResult

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

the class DmnDecisionResultTest method testSingleResult.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testSingleResult() {
    DmnDecisionResult results = evaluateWithMatchingRules(SINGLE_OUTPUT_VALUE);
    assertThat(results).hasSize(1);
    assertSingleOutputValue(results.get(0));
    assertSingleOutputValue(results.getFirstResult());
    assertSingleOutputValue(results.getSingleResult());
    assertThat(results.getSingleEntry()).isEqualTo("singleValue");
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Example 4 with DmnDecisionResult

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

the class DmnDecisionResultTest method testSingleOutputUntypedValue.

@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testSingleOutputUntypedValue() {
    DmnDecisionResult decisionResult = evaluateWithMatchingRules(SINGLE_OUTPUT_VALUE);
    assertThat(decisionResult).hasSize(1);
    DmnDecisionResultEntries ruleResult = decisionResult.getFirstResult();
    TypedValue typedEntry = ruleResult.getEntryTyped("firstOutput");
    assertThat(typedEntry).isEqualTo(Variables.untypedValue("singleValue"));
    typedEntry = ruleResult.getEntryTyped("secondOutput");
    assertThat(typedEntry).isNull();
    typedEntry = ruleResult.getFirstEntryTyped();
    assertThat(typedEntry).isEqualTo(Variables.untypedValue("singleValue"));
    typedEntry = ruleResult.getSingleEntryTyped();
    assertThat(typedEntry).isEqualTo(Variables.untypedValue("singleValue"));
}
Also used : DmnDecisionResultEntries(org.camunda.bpm.dmn.engine.DmnDecisionResultEntries) DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) 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 5 with DmnDecisionResult

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

the class DmnEngineApiTest method shouldEvaluateDecisionWithVariableContext.

@Test
@DecisionResource(resource = ONE_RULE_DMN)
public void shouldEvaluateDecisionWithVariableContext() {
    DmnDecisionResult results = dmnEngine.evaluateDecision(decision, createVariables().putValue("input", INPUT_VALUE).asVariableContext());
    assertThat(results.getSingleEntry()).isNotNull().isEqualTo(EXPECTED_OUTPUT_VALUE);
}
Also used : DmnDecisionResult(org.camunda.bpm.dmn.engine.DmnDecisionResult) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest) DecisionResource(org.camunda.bpm.dmn.engine.test.DecisionResource)

Aggregations

DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)54 Test (org.junit.Test)40 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)29 DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)25 HashMap (java.util.HashMap)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 Matchers.anyString (org.mockito.Matchers.anyString)6 Deployment (org.camunda.bpm.engine.test.Deployment)5 DmnDecisionResultEntries (org.camunda.bpm.dmn.engine.DmnDecisionResultEntries)4 DecisionDefinition (org.camunda.bpm.engine.repository.DecisionDefinition)4 VariableContext (org.camunda.bpm.engine.variable.context.VariableContext)4 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)4 DmnEngine (org.camunda.bpm.dmn.engine.DmnEngine)3 DefaultDmnEngineConfiguration (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration)3 MockDecisionResultBuilder (org.camunda.bpm.engine.rest.helper.MockDecisionResultBuilder)3 DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)2 DmnDecisionResultException (org.camunda.bpm.dmn.engine.impl.DmnDecisionResultException)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)1