Class ContentVerifier


  • public class ContentVerifier
    extends Object
    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. After the actual values have been specified, they can be compared against the expected value by a call to assertMetadataEquals(…).
    Since:
    3.1
    • Constructor Detail

      • ContentVerifier

        public ContentVerifier()
        Creates a new dataset content verifier.
    • Method Detail

      • clear

        public void clear()
        Resets this verifier to the same state than after construction. This method can be invoked for reusing the same verifier with different metadata objects.
      • addPropertyToIgnore

        public void addPropertyToIgnore​(Class<?> type,
                                        String property)
        Adds a metadata property to ignore. The property is identified by a GeoAPI interface and the UML identifier of a property in that interface. Properties to ignore must be declared before to invoke addMetadataToVerify(…).
        Parameters:
        type - GeoAPI interface containing the property to ignore.
        property - UML identifier of a property in the given interface.
      • addMetadataToVerify

        public void addMetadataToVerify​(Metadata actual)
        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 unless clear() has been invoked).
        Parameters:
        actual - the metadata read from a dataset, or null if 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

        public void addMetadataToVerify​(CoordinateReferenceSystem actual)
        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 unless clear() has been invoked).
        Parameters:
        actual - the CRS read from a dataset, or null if 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.
      • compareMetadata

        public boolean compareMetadata​(Map<String,​Object> expected)
        Compares actual metadata properties against the expected values given in a map. 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"
        Values in the map are the expected values for the properties identified by the keys. Comparison result can be viewed after this method call with toString().
        Parameters:
        expected - the expected values of properties identified by the keys.
        Returns:
        true if all properties match, with no missing property and no unexpected property.
      • compareMetadata

        public boolean compareMetadata​(String path,
                                       Object expectedValue,
                                       Object... others)
        Compares actual metadata properties against the expected values. The path argument 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"
        The value argument is the expected value for the property identified by the path. Comparison result can be viewed after this method call with toString().
        Parameters:
        path - path of the property to compare.
        expectedValue - expected value for the property at the given path.
        others - other (path, expectedValue) pairs.
        Returns:
        true if all properties match, with no missing property and no unexpected property.
      • assertMetadataEquals

        public void assertMetadataEquals​(String path,
                                         Object expectedValue,
                                         Object... others)
        Asserts that actual metadata properties are equal to the expected values. The path argument 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"
        The value argument is the expected value for the property identified by the path. If there is any mismatched, missing or unexpected value, then the assertion fails with an error message listing all differences found.
        Parameters:
        path - path of the property to compare.
        expectedValue - expected value for the property at the given path.
        others - other (path, expectedValue) pairs, in any order.
      • toString

        public String 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.
        Overrides:
        toString in class Object
        Returns:
        a string representation of the comparison results.