Object
ContentVerifier
Verification operations that compare metadata or CRS properties against the expected values.
The metadata or CRS to verify (typically read from a dataset) is specified by a call to one
of the
addMetadataToVerify(…) methods. The expected metadata values are specified by
calls to addExpectedValues(…) methods. After the expected and actual values have been
specified, they can be compared by a call to assertMetadataEquals().- Since:
- 3.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExpectedValue(String path, Object expectedValue) Adds the expected metadata value for the given path.voidaddExpectedValues(String path, Object expectedValue, Object... others) Adds the expected metadata values for the given paths.voidaddExpectedValues(Map<String, ?> expected) Adds the expected metadata values for the given paths.voidaddMetadataToVerify(Metadata actual) Stores all properties of the given metadata, for later comparison against expected values.voidStores all properties of the given CRS, for later comparison against expected values.voidaddPropertyToIgnore(Class<?> type, String property) Adds a metadata property to ignore.voidAsserts that actual metadata properties are equal to the expected values.voidclear()Resets this verifier to the same state as after construction.booleanCompares actual metadata properties against the expected values given in a map.toString()Returns a string representation of the comparison results.
-
Constructor Details
-
ContentVerifier
public ContentVerifier()Creates a new dataset content verifier.
-
-
Method Details
-
clear
Resets this verifier to the same state as after construction. This method can be invoked for reusing the same verifier with different metadata objects. -
addPropertyToIgnore
Adds a metadata property to ignore. The property is identified by a GeoAPI interface and theUMLidentifier of a property in that interface. Properties to ignore must be declared before to invokeaddMetadataToVerify(…).- Parameters:
type- GeoAPI interface containing the property to ignore.property- UML identifier of a property in the given interface.
-
addMetadataToVerify
Stores all properties of the given metadata, for later comparison against expected values. If this method is invoked more than once, then the given metadata objects shall not provide values for the same properties (unless the values are equal, or unlessclear()has been invoked).- Parameters:
actual- the metadata read from a dataset, ornullif none.- Throws:
IllegalStateException- if the given metadata contains a property already found in a previous call to this method, and the values found in those two invocations are not equal.
-
addMetadataToVerify
Stores all properties of the given CRS, for later comparison against expected values. In this class, a Coordinate Reference System is considered as a kind of metadata. If this method is invoked more than once, then the given CRS objects shall not provide values for the same properties (unless the values are equal, or unlessclear()has been invoked).- Parameters:
actual- the CRS read from a dataset, ornullif none.- Throws:
IllegalStateException- if the given CRS contains a property already found in a previous call to this method, and the values found in those two invocations are not equal.
-
addExpectedValue
Adds the expected metadata value for the given path. The path is a string like the following examples ([0]is the index of an element in lists or collections):"identificationInfo[0].citation.identifier[0].code""spatialRepresentationInfo[0].axisDimensionProperties[0].dimensionSize"
expectedValueargument is the expected values for the properties identified by the path.- Parameters:
path- path to the property to verify.expectedValue- the expected values of property identified by the path.- Throws:
IllegalArgumentException- if a different value is already declared for the given path.
-
addExpectedValues
Adds the expected metadata values for the given paths. Thepathargument identifies a metadata element like the following examples ([0]is the index of an element in lists or collections):"identificationInfo[0].citation.identifier[0].code""spatialRepresentationInfo[0].axisDimensionProperties[0].dimensionSize"
valueargument is the expected value for the property identified by the path.- Parameters:
path- path of the property to compare.expectedValue- expected value for the property at the given path.others- other (path,expectedValue) pairs.- Throws:
ClassCastException- if anotherselement for a path is not aStringinstance.IllegalArgumentException- if a path is already associated to a different value.
-
addExpectedValues
Adds the expected metadata values for the given paths. For each entry in the map, the key is a path to a metadata element like the following examples ([0]is the index of an element in lists or collections):"identificationInfo[0].citation.identifier[0].code""spatialRepresentationInfo[0].axisDimensionProperties[0].dimensionSize"
- Parameters:
expected- the expected values of properties identified by the keys.- Throws:
IllegalArgumentException- if a path is already associated to a different value.
-
compareMetadata
Compares actual metadata properties against the expected values given in a map. TheaddMetadataToVerify(…)andaddExpectedValues(…)methods must be invoked before this method. Comparison result can be viewed after this method call withtoString().- Returns:
trueif all properties match, with no missing property and no unexpected property.
-
assertMetadataEquals
Asserts that actual metadata properties are equal to the expected values. TheaddMetadataToVerify(…)andaddExpectedValues(…)methods must be invoked before this method. If there is any mismatched, missing or unexpected value, then the assertion fails with an error message listing all differences found. -
toString
Returns a string representation of the comparison results. This method formats up to three blocks in a JSON-like format:- List of actual values that do no match the expected values.
- List of expected values that are missing in the actual values.
- List of actual values that were unexpected.
-