Search in sources :

Example 1 with ConformanceResult

use of org.opengis.metadata.quality.ConformanceResult in project sis by apache.

the class NilReasonMarshallingTest method testMissingBoolean.

/**
 * Tests a missing boolean value. The {@link Boolean}, {@link Integer}, {@link Double} and {@link String}
 * values are implemented as special cases in {@link NilReason}, because they are final classes on which
 * we have no control.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
@DependsOnMethod("testMissing")
public void testMissingBoolean() throws JAXBException {
    final String expected = "<mdq:DQ_ConformanceResult xmlns:mdq=\"" + Namespaces.MDQ + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + "  <mdq:explanation>\n" + "    <gco:CharacterString>An explanation</gco:CharacterString>\n" + "  </mdq:explanation>\n" + "  <mdq:pass gco:nilReason=\"missing\"/>\n" + "</mdq:DQ_ConformanceResult>";
    final ConformanceResult result = unmarshal(ConformanceResult.class, expected);
    assertEquals("explanation", "An explanation", result.getExplanation().toString());
    final Boolean pass = result.pass();
    assertNotNull("Expected a sentinel value.", pass);
    assertEquals("Nil value shall be false.", Boolean.FALSE, pass);
    assertNotSame("Expected a sentinel value.", Boolean.FALSE, pass);
    assertSame("nilReason", NilReason.MISSING, NilReason.forObject(pass));
    final String actual = marshal(result);
    assertXmlEquals(expected, actual, "xmlns:*");
    assertEquals(result, unmarshal(ConformanceResult.class, actual));
}
Also used : ConformanceResult(org.opengis.metadata.quality.ConformanceResult) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 2 with ConformanceResult

use of org.opengis.metadata.quality.ConformanceResult in project sis by apache.

the class SingletonAttributeTest method assertDomainConsistencyEquals.

/**
 * Verifies that the given element reports a validation failure with the given explanation.
 *
 * @param  propertyName  the name of the property that failed validation.
 * @param  explanation   the expected explanation.
 * @param  consistency   the report element to test.
 */
private static void assertDomainConsistencyEquals(final String propertyName, final String explanation, final DomainConsistency consistency) {
    assertEquals("report.measureIdentification", propertyName, consistency.getMeasureIdentification().getCode());
    final ConformanceResult result = (ConformanceResult) getSingleton(consistency.getResults());
    assertFalse("report.result.pass", result.pass());
    assertEquals("report.result.explanation", explanation, result.getExplanation().toString(Locale.US));
}
Also used : ConformanceResult(org.opengis.metadata.quality.ConformanceResult)

Example 3 with ConformanceResult

use of org.opengis.metadata.quality.ConformanceResult in project sis by apache.

the class FeatureTestCase method verifyQualityReports.

/**
 * Asserts that {@link AbstractFeature#quality()} reports no anomaly, or only anomalies for the given properties.
 *
 * @param  anomalousProperties  the property for which we expect a report.
 * @return the data quality report.
 */
private DataQuality verifyQualityReports(final String... anomalousProperties) {
    int anomalyIndex = 0;
    final DataQuality quality = feature.quality();
    for (final Element report : quality.getReports()) {
        for (final Result result : report.getResults()) {
            if (result instanceof ConformanceResult && !((ConformanceResult) result).pass()) {
                assertTrue("Too many reports", anomalyIndex < anomalousProperties.length);
                final String propertyName = anomalousProperties[anomalyIndex];
                final String identifier = report.getMeasureIdentification().toString();
                final String explanation = ((ConformanceResult) result).getExplanation().toString();
                assertEquals("quality.report.measureIdentification", propertyName, identifier);
                assertTrue("quality.report.result.explanation", explanation.contains(propertyName));
                anomalyIndex++;
            }
        }
    }
    assertEquals("Number of reports.", anomalousProperties.length, anomalyIndex);
    return quality;
}
Also used : DataQuality(org.opengis.metadata.quality.DataQuality) Element(org.opengis.metadata.quality.Element) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Result(org.opengis.metadata.quality.Result) QuantitativeResult(org.opengis.metadata.quality.QuantitativeResult) ConformanceResult(org.opengis.metadata.quality.ConformanceResult) ConformanceResult(org.opengis.metadata.quality.ConformanceResult)

Example 4 with ConformanceResult

use of org.opengis.metadata.quality.ConformanceResult in project sis by apache.

the class PositionalAccuracyConstantTest method testPositionalAccuracy.

/**
 * Tests {@link PositionalAccuracyConstant} constants.
 */
@Test
public void testPositionalAccuracy() {
    assertEquals("Identity comparison", PositionalAccuracyConstant.DATUM_SHIFT_APPLIED, PositionalAccuracyConstant.DATUM_SHIFT_APPLIED);
    assertEquals("Identity comparison", PositionalAccuracyConstant.DATUM_SHIFT_OMITTED, PositionalAccuracyConstant.DATUM_SHIFT_OMITTED);
    assertNotSame(PositionalAccuracyConstant.DATUM_SHIFT_APPLIED, PositionalAccuracyConstant.DATUM_SHIFT_OMITTED);
    final Collection<? extends Result> appliedResults = PositionalAccuracyConstant.DATUM_SHIFT_APPLIED.getResults();
    final Collection<? extends Result> omittedResults = PositionalAccuracyConstant.DATUM_SHIFT_OMITTED.getResults();
    final ConformanceResult applied = (ConformanceResult) TestUtilities.getSingleton(appliedResults);
    final ConformanceResult omitted = (ConformanceResult) TestUtilities.getSingleton(omittedResults);
    assertNotSame(applied, omitted);
    assertTrue("DATUM_SHIFT_APPLIED", applied.pass());
    assertFalse("DATUM_SHIFT_OMITTED", omitted.pass());
    assertFalse(applied.equals(omitted));
    assertFalse(appliedResults.equals(omittedResults));
    assertFalse(PositionalAccuracyConstant.DATUM_SHIFT_APPLIED.equals(PositionalAccuracyConstant.DATUM_SHIFT_OMITTED));
}
Also used : ConformanceResult(org.opengis.metadata.quality.ConformanceResult) Test(org.junit.Test)

Aggregations

ConformanceResult (org.opengis.metadata.quality.ConformanceResult)4 Test (org.junit.Test)2 DependsOnMethod (org.apache.sis.test.DependsOnMethod)1 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)1 DataQuality (org.opengis.metadata.quality.DataQuality)1 Element (org.opengis.metadata.quality.Element)1 QuantitativeResult (org.opengis.metadata.quality.QuantitativeResult)1 Result (org.opengis.metadata.quality.Result)1