Search in sources :

Example 1 with VariablesContext

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();
}
Also used : ParseFailureMessage(io.camunda.zeebe.dmn.impl.ParseFailureMessage) VariablesContext(io.camunda.zeebe.dmn.impl.VariablesContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with VariablesContext

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();
}
Also used : VariablesContext(io.camunda.zeebe.dmn.impl.VariablesContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with VariablesContext

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();
}
Also used : VariablesContext(io.camunda.zeebe.dmn.impl.VariablesContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with VariablesContext

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();
}
Also used : ParseFailureMessage(io.camunda.zeebe.dmn.impl.ParseFailureMessage) VariablesContext(io.camunda.zeebe.dmn.impl.VariablesContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with VariablesContext

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();
}
Also used : VariablesContext(io.camunda.zeebe.dmn.impl.VariablesContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

VariablesContext (io.camunda.zeebe.dmn.impl.VariablesContext)6 DisplayName (org.junit.jupiter.api.DisplayName)6 Test (org.junit.jupiter.api.Test)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 ParseFailureMessage (io.camunda.zeebe.dmn.impl.ParseFailureMessage)3