Skip to content

Commit

Permalink
refactor: Adjust assertion failure message
Browse files Browse the repository at this point in the history
  • Loading branch information
saig0 committed Sep 8, 2023
1 parent 93a3b23 commit 3e11c42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/org/camunda/feel/FeelEngine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class FeelEngine(
case _ if containsAssertionError(context) => {
val failureMessage = getAssertErrorMessage(context)
FailedEvaluationResult(
failure = Failure(s"Assertion failure on evaluate the expression '${exp.text}': ${failureMessage}'"),
failure = Failure(s"Assertion failure on evaluate the expression '${exp.text}': ${failureMessage}"),
suppressedFailures = context.failureCollector.failures
)
}
Expand All @@ -182,7 +182,7 @@ class FeelEngine(
* @return true if an an {@link EvaluationFailureType.ASSERT_FAILURE} is raised, false otherwise
*/
private def containsAssertionError(context: EvalContext): Boolean = {
context.failureCollector.failures.exists(_.failureType == EvaluationFailureType.ASSERT_FAILURE);
context.failureCollector.failures.exists(_.failureType == EvaluationFailureType.ASSERT_FAILURE)
}

private def getAssertErrorMessage(context: EvalContext): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class BuiltinFunctionsTest

evaluateExpression(
expression = """list contains(assert(my_list, my_list != null), 2)"""
) should failWith("Assertion failure on evaluate the expression 'list contains(assert(my_list, my_list != null), 2)': The condition is not fulfilled'")
) should failWith("Assertion failure on evaluate the expression 'list contains(assert(my_list, my_list != null), 2)': The condition is not fulfilled")
}

"A assert(value: Any, condition: Any, cause: String) function" should "return the value if the condition evaluated to true" in {
Expand Down Expand Up @@ -237,6 +237,6 @@ class BuiltinFunctionsTest

evaluateExpression(
expression = """list contains(assert(my_list, my_list != null, "The condition is not true"), 2)"""
) should failWith("Assertion failure on evaluate the expression 'list contains(assert(my_list, my_list != null, \"The condition is not true\"), 2)': The condition is not true'")
) should failWith("Assertion failure on evaluate the expression 'list contains(assert(my_list, my_list != null, \"The condition is not true\"), 2)': The condition is not true")
}
}

0 comments on commit 3e11c42

Please sign in to comment.