...
The JSON Assertor can be chained against any tool that communicates a JSON Message, . It is most commonly connected with the Messaging Client and REST Client tools.
...
The JSON Assertor consists of three main tabs:
- Summary: This tab contains a table showing the details of the JSON Assertions that have been configured.
- Configuration: This tab is used to create and configure new and existing JSON Assertions.
- Expected JSON: Specifies the expected JSON message that all assertions will be compared against. If the JSON Assertor receives valid JSON message (i.e. that is, attached to the REST Client), this panel will automatically populate the JSON message in both a Tree and Literal view. Once populated, the expected JSON message can be saved for future uses.
...
- Select a project tree node and click Add Output from the shortcut menu. The Add Output wizard displaysopens.
- In the Add Output wizard, select Request / Response> Response > Traffic from from the left GUI pane, select JSON Assertor from the right GUI pane, and then click the Finish button. A JSON Assertor node is added underneath the selected node.
- Click the Add button in the JSON Assertor’s Configuration tab. The Select Assertion wizard displaysopens.
- Select an assertion type. The following is a brief summary of the available types of Assertions.
- Value Assertions: The following value assertions are available:
- Value Assertion: Enforce the value of a particular element.
- Numeric Assertion: Enforce the numeric value of an element.
- String Comparison Assertion: Enforce the value of the text content of a given element.
- Regular Expression Assertion: Enforce that an element matches a regular expression.
- Custom Assertion: Enforce the value of an element by scripting custom logic.
- Structure Assertions: The following structure assertions are available:
- Has Content Assertion: Enforce that an element has text content (i.e.that is, length of text > 0).
- Has Children Assertion: Enforce that an element has one or more child elements.
- Compound Assertions: The following compound assertions are available:
- AND Assertion: Group multiple assertions that all must succeed.
- OR Assertion: Group multiple assertions where at least one must succeed.
- Conditional Assertion: Enforce an assertion only if a condition is met (where the condition is a combination of previously - defined assertions).
- Difference Assertions: The following difference assertions are available:
- Numeric Difference Assertion: Enforce a numeric difference on a value of a particular element. Assert that the numeric value of an element differs from a user-specified base value by a user-specified value. For example, in order to assert that a value in degrees Fahrenheit is 3 degrees below freezing, you would set the Base Value to 32 and the Difference Value to -3.
- Range Assertions: The following difference assertions are available:
- Numeric Range Assertion: Enforce that the numeric value of an element is within the inclusive bounds of a numeric range.
- Value Assertions: The following value assertions are available:
- Click the Next button. A tree view displays.
- Select the element that you want this assertion to check , then and click the Finish button.
You may add additional assertions to apply to the message by clicking the Add button in the Configuration tab.
If you later want to modify the element referenced by an assertion, click Change Element, which is at at the bottom right of the Configuration tab. This opens a dialog that lets you graphically or manually edit the given element.