use of io.camunda.zeebe.dmn.impl.VariablesContext in project zeebe by camunda.
the class DmnEvaluationTest method shouldResultInFailureWhenDrgInvalid.
@Test
@DisplayName("Should result in failure when invalid drg used")
void shouldResultInFailureWhenDrgInvalid() {
// given
final var parsedDrg = new ParseFailureMessage("Example Parse Failure");
// when
final var result = decisionEngine.evaluateDecisionById(parsedDrg, "jedi_or_sith", new VariablesContext(Map.of("lightsaberColor", asMsgPack("\"blue\""))));
// then
assertThat(result.isFailure()).describedAs("Expect that the result is not evaluated successfully").isTrue();
assertThat(result.getFailureMessage()).isNotNull().describedAs("Expect that the evaluation failed because the DRG is invalid").contains("the decision requirements graph is invalid");
assertThat(result.getFailedDecisionId()).describedAs("Expect that the failed decision id is 'null' if the DRG is invalid").isNull();
assertThat(result.getOutput()).describedAs("Expect that a successful result has no output").isNull();
}
use of io.camunda.zeebe.dmn.impl.VariablesContext in project zeebe by camunda.
the class DmnEvaluationTest method shouldResultInDecisionOutputWhenSuccessful.
@Test
@DisplayName("Should result in decision with output when successful")
void shouldResultInDecisionOutputWhenSuccessful() {
// given
final var inputStream = getClass().getResourceAsStream(VALID_DRG);
final var parsedDrg = decisionEngine.parse(inputStream);
// when
final var result = decisionEngine.evaluateDecisionById(parsedDrg, "jedi_or_sith", new VariablesContext(Map.of("lightsaberColor", asMsgPack("\"blue\""))));
// then
assertThat(result.isFailure()).describedAs("Expect that the result is evaluated successfully").isFalse();
assertThat(result.getFailureMessage()).describedAs("Expect that a successful result has no failure message").isNull();
assertThat(result.getFailedDecisionId()).describedAs("Expect that a successful result has no failed decision").isNull();
assertThat(result.getOutput()).describedAs("Expect that a successful result has some output").isNotNull();
}
use of io.camunda.zeebe.dmn.impl.VariablesContext in project zeebe by zeebe-io.
the class DmnEvaluationTest method shouldResultInDecisionOutputWhenSuccessful.
@Test
@DisplayName("Should result in decision with output when successful")
void shouldResultInDecisionOutputWhenSuccessful() {
// given
final var inputStream = getClass().getResourceAsStream(VALID_DRG);
final var parsedDrg = decisionEngine.parse(inputStream);
// when
final var result = decisionEngine.evaluateDecisionById(parsedDrg, "jedi_or_sith", new VariablesContext(Map.of("lightsaberColor", asMsgPack("\"blue\""))));
// then
assertThat(result.isFailure()).describedAs("Expect that the result is evaluated successfully").isFalse();
assertThat(result.getFailureMessage()).describedAs("Expect that a successful result has no failure message").isNull();
assertThat(result.getFailedDecisionId()).describedAs("Expect that a successful result has no failed decision").isNull();
assertThat(result.getOutput()).describedAs("Expect that a successful result has some output").isNotNull();
}
use of io.camunda.zeebe.dmn.impl.VariablesContext in project zeebe by camunda-cloud.
the class DmnEvaluationTest method shouldResultInFailureWhenDrgInvalid.
@Test
@DisplayName("Should result in failure when invalid drg used")
void shouldResultInFailureWhenDrgInvalid() {
// given
final var parsedDrg = new ParseFailureMessage("Example Parse Failure");
// when
final var result = decisionEngine.evaluateDecisionById(parsedDrg, "jedi_or_sith", new VariablesContext(Map.of("lightsaberColor", asMsgPack("\"blue\""))));
// then
assertThat(result.isFailure()).describedAs("Expect that the result is not evaluated successfully").isTrue();
assertThat(result.getFailureMessage()).isNotNull().describedAs("Expect that the evaluation failed because the DRG is invalid").contains("the decision requirements graph is invalid");
assertThat(result.getFailedDecisionId()).describedAs("Expect that the failed decision id is the target decision id if the DRG is invalid").isEqualTo("jedi_or_sith");
assertThat(result.getOutput()).describedAs("Expect that a successful result has no output").isNull();
}
use of io.camunda.zeebe.dmn.impl.VariablesContext in project zeebe by camunda-cloud.
the class DmnEvaluationTest method shouldResultInDecisionOutputWhenSuccessful.
@Test
@DisplayName("Should result in decision with output when successful")
void shouldResultInDecisionOutputWhenSuccessful() {
// given
final var inputStream = getClass().getResourceAsStream(VALID_DRG);
final var parsedDrg = decisionEngine.parse(inputStream);
// when
final var result = decisionEngine.evaluateDecisionById(parsedDrg, "jedi_or_sith", new VariablesContext(Map.of("lightsaberColor", asMsgPack("\"blue\""))));
// then
assertThat(result.isFailure()).describedAs("Expect that the result is evaluated successfully").isFalse();
assertThat(result.getFailureMessage()).describedAs("Expect that a successful result has no failure message").isNull();
assertThat(result.getFailedDecisionId()).describedAs("Expect that a successful result has no failed decision").isNull();
assertThat(result.getOutput()).describedAs("Expect that a successful result has some output").isNotNull();
}
Aggregations