public class Operations extends Object
| Constructor and Description |
|---|
Operations() |
| Modifier and Type | Method and Description |
|---|---|
void |
compareObjects(Object expected,
Object actual,
boolean containsOnlyOnMaps,
boolean checkMapOrder,
List<String> pathOptions)
Compare two objects.
|
void |
compareXml(Object expected,
Object actual,
String xmlCompareOption)
Compare two XML documents.
|
public void compareObjects(@DisplayName(value="Expected value") @Example(value="#[MunitTools::getResourceAsStream()]")
Object expected,
@DisplayName(value="Actual value") @Example(value="#[payload]")
Object actual,
@DisplayName(value="Contains only on maps") @Optional(defaultValue="false")
boolean containsOnlyOnMaps,
@DisplayName(value="Check map order") @Optional(defaultValue="false")
boolean checkMapOrder,
@DisplayName(value="Path patterns+options")
List<String> pathOptions)
throws Exception
expected - The expected value. Automatic conversions are provided:
trim()actual - The actual value. Automatic conversions are provided:
trim()containsOnlyOnMaps - The actual value entry set of maps can contain more values than the expected set. So you tests do not fail
when there are more elements than expected in the result.checkMapOrder - The order of map entries is checked. The default is to ignore order of map entries.pathOptions - Options for path patterns to control the comparison. Syntax of one List entry: Zero to n path
parts. The parts can have the following syntax:
?: Wildcard one, matches one element in a path*: Wildcard any, matches zero to n elements in a path[#]: List wildcard, matches a list entry with any index[0]: Matches a list entry with the given number. 0 or positive numbers: Count from
beginning, negative number: Cound from end (-1 is last element)['.*']: Matches a map entry where the key must match the given regular expression. If you
need a ' in the expression, just write ''. The example '.*' matches all keys.Exception - When comparison fails or on technical problems (e.g. parsing)public void compareXml(@DisplayName(value="Expected value") @Example(value="#[MunitTools::getResourceAsStream()]")
Object expected,
@DisplayName(value="Actual value") @Example(value="#[payload]")
Object actual,
@DisplayName(value="XML compare option") @OfValues(value=XmlCompareOption.class)
String xmlCompareOption)
throws Exception
expected - The expected value, XML as String, InputStream, byte[] or DOM tree.actual - The actual value, XML as String, InputStream, byte[] or DOM tree.xmlCompareOption - How to compare the XML documents.
IGNORE_COMMENTS: Will remove all comment-Tags "" from test- and control-XML before
comparing.
IGNORE_WHITESPACE: Ignore whitespace by removing all empty text nodes and trimming the non-empty ones.
NORMALIZE_WHITESPACE: Normalize Text-Elements by removing all empty text nodes and normalizing the
non-empty ones.Exception - When comparison fails or on technical problems (e.g. parsing)Copyright © 2019 MuleSoft, Inc.. All rights reserved.