use of org.camunda.bpm.dmn.engine.DmnDecisionTableResult in project camunda-engine-dmn by camunda.
the class DmnExampleVerifier method assertExample.
public static void assertExample(DmnEngine engine, DmnDecision decision) {
VariableMap variables = Variables.createVariables();
variables.put("status", "bronze");
variables.put("sum", 200);
DmnDecisionTableResult results = engine.evaluateDecisionTable(decision, variables);
assertThat(results).hasSingleResult().containsKeys("result", "reason").containsEntry("result", "notok").containsEntry("reason", "work on your status first, as bronze you're not going to get anything");
variables.put("status", "silver");
results = engine.evaluateDecisionTable(decision, variables);
assertThat(results).hasSingleResult().containsKeys("result", "reason").containsEntry("result", "ok").containsEntry("reason", "you little fish will get what you want");
variables.put("sum", 1200);
results = engine.evaluateDecisionTable(decision, variables);
assertThat(results).hasSingleResult().containsKeys("result", "reason").containsEntry("result", "notok").containsEntry("reason", "you took too much man, you took too much!");
variables.put("status", "gold");
variables.put("sum", 200);
results = engine.evaluateDecisionTable(decision, variables);
assertThat(results).hasSingleResult().containsKeys("result", "reason").containsEntry("result", "ok").containsEntry("reason", "you get anything you want");
}
use of org.camunda.bpm.dmn.engine.DmnDecisionTableResult 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"));
}
use of org.camunda.bpm.dmn.engine.DmnDecisionTableResult 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");
}
}
use of org.camunda.bpm.dmn.engine.DmnDecisionTableResult 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();
}
use of org.camunda.bpm.dmn.engine.DmnDecisionTableResult 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");
}
Aggregations