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));
}
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));
}
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;
}
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));
}
Aggregations