nullValue()
About MUnit Matchers
MUnit matchers are a set of DataWeave functions to define mocks, verifications, and assertions conditions in terms of general values rather than specific hardcoded values.
When defining matchers you need to add the MuniTools::
prefix to the expression.
A matcher does not receive parameters; rather, it’s a parameter itself that you can use to validate the result of an expression.
Matcher Name | Description | Example |
---|---|---|
Checks that the expression is null |
#[MunitTools::nullValue()] |
|
notNullValue() |
Checks that the expression is null |
#[MunitTools::notNullValue()] |
equalTo(Object) |
Checks that the expression is equal to a specific value |
#[MunitTools::equalTo(0)] |
not(Matcher) |
Checks if the provided matcher is not successful |
#[MunitTools::not(MunitTools::equalTo(0))] |
withMediaType(String) |
Checks that the expression’s media type is the one specified |
#[MunitTools::withMediaType('text/xml')] |
withEncoding(String) |
Checks that the expression’s encoding is the one specified |
#[MunitTools::withEncoding('UTF-8')] |
both(Matcher, Matcher) |
Checks that both provided matchers are successful |
#[MunitTools::both(MunitTools::notNullValue(),MunitTools::equalTo('example'))] |
either(Matcher,Matcher) |
Checks that at least one of the matchers is successful |
#[MunitTools::either(MunitTools::nullValue(),MunitTools::equalTo(0))] |