Package org.mule.munit.tools.assertion
Class AssertOperations
java.lang.Object
org.mule.munit.tools.assertion.AssertOperations
Operations to perform assertions
- Since:
- 2.0.0
- Author:
- Mulesoft Inc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionorg.mule.runtime.core.api.el.ExpressionManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassertEquals(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 givenactualvalue is equal to theexpectedvalue.voidassertExpression(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 giventhatassertion expression is successful.voidassertThat(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 theexpressionmatches the givenisMatcher.voidFails with aAssertionErrorwith the givenmessagevoidrunCustom(String assertion, org.mule.runtime.api.metadata.TypedValue<Object> expression, Object params)Runs a customassertionover the givenexpressionwith the parametersparamsprotected voidsetAssertModule(org.mule.munit.assertion.internal.AssertModule assertModule)
-
Field Details
-
expressionManager
@Inject public org.mule.runtime.core.api.el.ExpressionManager expressionManager
-
-
Constructor Details
-
AssertOperations
public AssertOperations()
-
-
Method Details
-
assertThat
@Summary("Perform an assertion over an expression") public void assertThat(@Example("#[payload]") org.mule.runtime.api.metadata.TypedValue<Object> expression, @Expression(REQUIRED) @Example("#[MunitTools::notNullValue()]") org.mule.munit.assertion.api.matchers.Matcher is, @Optional(defaultValue="") String message, org.mule.runtime.api.component.location.ComponentLocation location)Checks if theexpressionmatches the givenisMatcher. If the assertion fails, it throws anAssertionError- Parameters:
expression- value to be assertedis- matcher to validate against the expressionmessage- message in case the assertion fails
-
assertExpression
@Summary("Asserts that an expression is successful") @DisplayName("Assert expression") @Alias("assert") @Throws(AssertionErrorProvider.class) public void assertExpression(@DisplayName("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)Evaluates if the giventhatassertion expression is successful. If the assertion fails, it throws anAssertionError- Parameters:
that- result of the assertion expressionmessage- message in case the assertion fails
-
assertEquals
@Summary("Check if an expression is equal to a value") public void assertEquals(@Example("#[payload]") org.mule.runtime.api.metadata.TypedValue<Object> actual, @ParameterDsl(allowReferences=false) @Example("#[\'EXAMPLE\']") org.mule.runtime.api.metadata.TypedValue<Object> expected, @Optional(defaultValue="") String message, org.mule.runtime.api.component.location.ComponentLocation location)Checks if the givenactualvalue is equal to theexpectedvalue. If they differ, anAssertionErroris thrown.- Parameters:
actual- actual value to be assertedexpected- expected value of the assertionmessage- message in case the assertion fails
-
fail
Fails with aAssertionErrorwith the givenmessage- Parameters:
message- message for the assertion failure
-
runCustom
@Summary("Run a custom assertion") public void runCustom(@Example("com.example.CustomAssertion") @ClassValue(extendsOrImplements="org.mule.munit.assertion.api.MunitAssertion") String assertion, @Example("#[payload]") org.mule.runtime.api.metadata.TypedValue<Object> expression, @Optional Object params)Runs a customassertionover the givenexpressionwith the parametersparamsThe assertion must implement
MunitAssertion- Parameters:
assertion- full qualified name of the custom assertion classexpression- value to be assertedparams- parameters of the custom assertion
-
setAssertModule
protected void setAssertModule(org.mule.munit.assertion.internal.AssertModule assertModule)
-