/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(ConformanceResult) */ public DefaultConformanceResult(final ConformanceResult object) { super(object); if (object != null) { specification = object.getSpecification(); explanation = object.getExplanation(); pass = object.pass(); } }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(ConformanceResult) */ public DefaultConformanceResult(final ConformanceResult object) { super(object); if (object != null) { specification = object.getSpecification(); explanation = object.getExplanation(); pass = object.pass(); } }
if (result instanceof ConformanceResult) { if (Boolean.FALSE.equals(((ConformanceResult) result).pass())) { final InternationalString message = ((ConformanceResult) result).getExplanation(); if (message != null) { throw new InvalidFeatureException(message);
if (result instanceof ConformanceResult) { if (Boolean.FALSE.equals(((ConformanceResult) result).pass())) { final InternationalString message = ((ConformanceResult) result).getExplanation(); if (message != null) { throw new InvalidFeatureException(message);
/** * 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; }
/** * 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)); }
assertFalse(result.pass()); assertTrue("The error message should contains the name of the invalid parameter.", result.getExplanation().toString().contains("Test2")); assertFalse(result.pass()); assertTrue("The error message should contains the name of the missing parameter.", result.getExplanation().toString().contains("Test1")); assertFalse(result.pass()); assertTrue("The error message should contains the name of the extra parameter.", result.getExplanation().toString().contains("Test3"));
/** * 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)); }