Class ModelVerifier<N>
java.lang.Object
ca.marcusdunn.jsonlens.testkit.ModelVerifier<N>
- Type Parameters:
N- the node type of the model
Checks the rules of a JsonModel on a document, and returns each Violation.
The verifier visits each value of the document. For each value, it calls the methods of the model for the kind of the value, and it compares the results with each other:
- the members of the cursor with
JsonModel.memberCount(Object),JsonModel.member(Object, JsonString),JsonModel.members(Object), andJsonModel.hasDuplicate(Object, JsonString); - two reads of each value, which must give equal nodes;
JsonModel.compareNumbers(JsonNumber, JsonNumber)with the exact values;JsonModel.equal(Object, Object)with the default method ofJsonModel.
Thus an override of a default method must give the result of the default method. The verifier
calls a method for a kind only for a node of that kind, as jsonlens does. It does not throw:
an exception or a null result of the model is a violation.
JsonModel<Object> model = new CollectionsModel();
List<Violation> violations = ModelVerifier.of(model).verify(Map.of("a", List.of(1, "x")));
// Each violation names a rule, the location of a value, and what the model did.
-
Method Summary
-
Method Details
-
of
Returns a verifier for a model.- Type Parameters:
N- the node type of the model- Parameters:
model- the model to check- Returns:
- the verifier
-
verify
-