public class AssertOperations extends Object
Operations to perform assertions
| Modifier and Type | Field and Description |
|---|---|
org.mule.runtime.core.api.el.ExpressionManager |
expressionManager |
| Constructor and Description |
|---|
AssertOperations() |
| Modifier and Type | Method and Description |
|---|---|
void |
assertEquals(org.mule.runtime.api.metadata.TypedValue<Object> actual,
org.mule.runtime.api.metadata.TypedValue<Object> expected,
String message,
org.mule.runtime.api.component.location.ComponentLocation location)
Checks if the given
actual value is equal to the expected value. |
void |
assertExpression(org.mule.runtime.extension.api.runtime.parameter.ParameterResolver<org.mule.munit.assertion.api.expression.MatcherResult> that,
String message,
org.mule.runtime.api.component.location.ComponentLocation location)
Evaluates if the given
that assertion expression is successful. |
void |
assertThat(org.mule.runtime.api.metadata.TypedValue<Object> expression,
org.mule.munit.assertion.api.matchers.Matcher is,
String message,
org.mule.runtime.api.component.location.ComponentLocation location)
Checks if the
expression matches the given is Matcher. |
void |
fail(String message)
Fails with a
AssertionError with the given message |
void |
runCustom(String assertion,
org.mule.runtime.api.metadata.TypedValue<Object> expression,
Object params)
Runs a custom
assertion over the given expression with the parameters params |
protected void |
setAssertModule(org.mule.munit.assertion.internal.AssertModule assertModule) |
@Inject public org.mule.runtime.core.api.el.ExpressionManager expressionManager
@Summary(value="Perform an assertion over an expression")
public void assertThat(@Example(value="#[payload]")
org.mule.runtime.api.metadata.TypedValue<Object> expression,
@Expression(value=REQUIRED) @Example(value="#[MunitTools::notNullValue()]")
org.mule.munit.assertion.api.matchers.Matcher is,
@Optional(defaultValue="")
String message,
org.mule.runtime.api.component.location.ComponentLocation location)
expression matches the given is Matcher. If the assertion fails, it throws an
AssertionErrorexpression - value to be assertedis - matcher to validate against the expressionmessage - message in case the assertion fails@Summary(value="Asserts that an expression is successful") @DisplayName(value="Assert expression") @Alias(value="assert") @Throws(value=AssertionErrorProvider.class) public void assertExpression(@DisplayName(value="Expression") @Optional(defaultValue="#[import * from dw::test::Asserts \n ---\npayload must notBeNull()]") @Content org.mule.runtime.extension.api.runtime.parameter.ParameterResolver<org.mule.munit.assertion.api.expression.MatcherResult> that, @Optional(defaultValue="Assertion failed") String message, org.mule.runtime.api.component.location.ComponentLocation location)
that assertion expression is successful. If the assertion fails, it throws an
AssertionErrorthat - result of the assertion expressionmessage - message in case the assertion fails@Summary(value="Check if an expression is equal to a value")
public void assertEquals(@Example(value="#[payload]")
org.mule.runtime.api.metadata.TypedValue<Object> actual,
@ParameterDsl(allowReferences=false) @Example(value="#[\'EXAMPLE\']")
org.mule.runtime.api.metadata.TypedValue<Object> expected,
@Optional(defaultValue="")
String message,
org.mule.runtime.api.component.location.ComponentLocation location)
actual value is equal to the expected value. If they differ, an AssertionError is
thrown.actual - actual value to be assertedexpected - expected value of the assertionmessage - message in case the assertion fails@Summary(value="Fail with an assertion")
public void fail(@Optional(defaultValue="")
String message)
AssertionError with the given messagemessage - message for the assertion failure@Summary(value="Run a custom assertion")
public void runCustom(@Example(value="com.example.CustomAssertion") @ClassValue(extendsOrImplements="org.mule.munit.assertion.api.MunitAssertion")
String assertion,
@Example(value="#[payload]")
org.mule.runtime.api.metadata.TypedValue<Object> expression,
@Optional
Object params)
assertion over the given expression with the parameters params
The assertion must implement MunitAssertion
assertion - full qualified name of the custom assertion classexpression - value to be assertedparams - parameters of the custom assertionprotected void setAssertModule(org.mule.munit.assertion.internal.AssertModule assertModule)
Copyright © 2023 MuleSoft, Inc.. All rights reserved.