This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 67ece65ce1 Store the reason why the mandatory boolean value of a
quality conformance result is missing. This is a partial replacement for a
feature supported since SIS 0.3 but removed in SIS 1.4 because of
https://issues.apache.org/jira/browse/SIS-586
67ece65ce1 is described below
commit 67ece65ce1cc874d79fa0b5f23756e49e0697002
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Thu Nov 16 18:40:23 2023 +0100
Store the reason why the mandatory boolean value of a quality conformance
result is missing.
This is a partial replacement for a feature supported since SIS 0.3 but
removed in SIS 1.4
because of https://issues.apache.org/jira/browse/SIS-586
---
.../iso/quality/DefaultConformanceResult.java | 82 +++++++++++++--
.../sis/metadata/iso/quality/package-info.java | 3 +-
.../org/apache/sis/xml/bind/gco/GO_Boolean.java | 11 ++
.../org/apache/sis/xml/bind/gco/PropertyType.java | 33 ++++++
.../metadata/iso/quality/AbstractElementTest.java | 2 +-
.../quality/AbstractPositionalAccuracyTest.java | 5 +-
.../iso/quality/DefaultConformanceResultTest.java | 117 +++++++++++++++++++++
.../iso/quality/DefaultDomainConsistencyTest.java | 2 +-
.../iso/quality/DefaultEvaluationMethodTest.java | 12 +--
.../iso/quality/DefaultQuantitativeResultTest.java | 2 +-
.../sis/metadata/iso/quality/ScopeCodeTest.java | 4 +-
.../test/org/apache/sis/xml/test/TestCase.java | 12 +++
12 files changed, 264 insertions(+), 21 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultConformanceResult.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultConformanceResult.java
index 05f287e6dd..2c5641f5fb 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultConformanceResult.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultConformanceResult.java
@@ -23,6 +23,8 @@ import org.opengis.util.InternationalString;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.quality.ConformanceResult;
import org.apache.sis.util.iso.Types;
+import org.apache.sis.xml.NilReason;
+import org.apache.sis.xml.bind.gco.GO_Boolean;
/**
@@ -48,13 +50,13 @@ import org.apache.sis.util.iso.Types;
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Touraïvane (IRD)
* @author Guilhem Legal (Geomatys)
- * @version 1.4
+ * @version 1.5
* @since 0.3
*/
@XmlType(name = "DQ_ConformanceResult_Type", propOrder = {
"specification",
"explanation",
- "pass"
+ "result"
})
@XmlRootElement(name = "DQ_ConformanceResult")
public class DefaultConformanceResult extends AbstractResult implements
ConformanceResult {
@@ -77,13 +79,14 @@ public class DefaultConformanceResult extends
AbstractResult implements Conforma
/**
* Indication of the conformance result.
- *
- * <p>The field is directly annotated here, because the getter method is
called {@link #pass()},
- * and JAXB does not recognize it. The method should have been called
getPass() or isPass().</p>
*/
- @XmlElement(name = "pass", required = true)
private Boolean pass;
+ /**
+ * If no result is provided, the reason why.
+ */
+ private NilReason nilReason;
+
/**
* Constructs an initially empty conformance result.
*/
@@ -121,6 +124,9 @@ public class DefaultConformanceResult extends
AbstractResult implements Conforma
specification = object.getSpecification();
explanation = object.getExplanation();
pass = object.pass();
+ if (object instanceof DefaultConformanceResult) {
+ nilReason = ((DefaultConformanceResult) object).getNilReason();
+ }
}
}
@@ -193,6 +199,7 @@ public class DefaultConformanceResult extends
AbstractResult implements Conforma
/**
* Returns an indication of the conformance result.
+ * If this method returns {@code null}, then {@link #getNilReason()} gives
the reason why.
*
* @return indication of the conformance result, or {@code null}.
*/
@@ -210,4 +217,67 @@ public class DefaultConformanceResult extends
AbstractResult implements Conforma
checkWritePermission(pass);
pass = newValue;
}
+
+ /**
+ * Returns the reason why the result is missing.
+ * This value is non-null only if {@link #pass()} is null.
+ *
+ * @return the reason why the result is missing, or {@code null} if the
result is not missing.
+ *
+ * @see NilReason#forObject(Object)
+ *
+ * @since 1.5
+ */
+ public NilReason getNilReason() {
+ return (pass != null) ? null : (nilReason != null) ? nilReason :
NilReason.UNKNOWN;
+ }
+
+ /**
+ * Sets the reason why the result is missing.
+ * Invoking this method with a non-null value sets {@link #pass()} to
{@code null}.
+ *
+ * @param newValue the reason why the result is missing, or {@code null}
if the result is not missing.
+ *
+ * @since 1.5
+ */
+ public void setNilReason(final NilReason newValue) {
+ checkWritePermission(nilReason);
+ if ((nilReason = newValue) != null) {
+ pass = null;
+ }
+ }
+
+
+
+
+
//////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////
////////
+ //////// XML support with JAXB
////////
+ ////////
////////
+ //////// The following methods are invoked by JAXB using reflection
(even if ////////
+ //////// they are private) or are helpers for other methods invoked
by JAXB. ////////
+ //////// Those methods can be safely removed if Geographic Markup
Language ////////
+ //////// (GML) support is not needed.
////////
+ ////////
////////
+
//////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Invoked by JAXB for fetching the value to marshal.
+ *
+ * @return the value to marshal.
+ */
+ @XmlElement(name = "pass", required = true)
+ private GO_Boolean getResult() {
+ return new GO_Boolean(pass(), getNilReason());
+ }
+
+ /**
+ * Invoked by JAXB for setting the value.
+ *
+ * @param result the value.
+ */
+ private void setResult(final GO_Boolean result) {
+ setPass(result.getElement());
+ setNilReason(result.parseNilReason());
+ }
}
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/package-info.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/package-info.java
index c4c528276f..3a4817bb9d 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/package-info.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/package-info.java
@@ -40,7 +40,7 @@
* @author Guilhem Legal (Geomatys)
* @author Cullen Rombach (Image Matters)
* @author Alexis Gaillard (Geomatys)
- * @version 1.4
+ * @version 1.5
* @since 0.3
*/
@XmlSchema(location="https://schemas.isotc211.org/19157/-2/mdq/1.0/mdq.xsd",
@@ -68,7 +68,6 @@
@XmlJavaTypeAdapter(DQM_Parameter.class),
@XmlJavaTypeAdapter(DQM_SourceReference.class),
@XmlJavaTypeAdapter(DQM_ValueStructure.class),
- @XmlJavaTypeAdapter(GO_Boolean.class),
@XmlJavaTypeAdapter(GO_Temporal.class),
@XmlJavaTypeAdapter(GO_DateTime.class),
@XmlJavaTypeAdapter(GO_GenericName.class),
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/GO_Boolean.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/GO_Boolean.java
index f4224f806e..31bf1540e6 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/GO_Boolean.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/GO_Boolean.java
@@ -19,6 +19,7 @@ package org.apache.sis.xml.bind.gco;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlSchemaType;
import jakarta.xml.bind.annotation.XmlType;
+import org.apache.sis.xml.NilReason;
/**
@@ -38,6 +39,16 @@ public final class GO_Boolean extends
PropertyType<GO_Boolean, Boolean> {
public GO_Boolean() {
}
+ /**
+ * Builds a wrapper for the specified value, which may be nil.
+ *
+ * @param value the value to wrap.
+ * @param nilReason if the value is nil, the reason why.
+ */
+ public GO_Boolean(final Boolean value, final NilReason nilReason) {
+ super(value, nilReason);
+ }
+
/**
* Constructs a wrapper for the given value.
*
diff --git
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/PropertyType.java
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/PropertyType.java
index 5d8982ce2d..88a2888396 100644
---
a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/PropertyType.java
+++
b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gco/PropertyType.java
@@ -141,6 +141,22 @@ public abstract class PropertyType<ValueType extends
PropertyType<ValueType,Boun
protected PropertyType() {
}
+ /**
+ * Builds a {@code PropertyType} wrapper for an instance of a primitive
wrapper.
+ * Those property types are handled in a different way because final
classes
+ * cannot implement the {@link NilObject} interface.
+ *
+ * @param value the primitive type wrapper.
+ * @param nilReason if the value is nil, the reason why.
+ */
+ protected PropertyType(final BoundType value, final NilReason nilReason) {
+ if (nilReason != null) {
+ reference = nilReason.toString();
+ } else {
+ metadata = value;
+ }
+ }
+
/**
* Builds a {@code PropertyType} wrapper for an instance of a final class.
* This constructor checks for nil reasons only if {@code check} is {@code
true}.
@@ -288,6 +304,23 @@ public abstract class PropertyType<ValueType extends
PropertyType<ValueType,Boun
return xlink;
}
+ /**
+ * The reason why a mandatory attribute if left unspecified, as a parsed
object.
+ *
+ * @return the nil reason, or {@code null} if none.
+ */
+ public final NilReason parseNilReason() {
+ final String reason = getNilReason();
+ if (reason == null) {
+ return null;
+ } else try {
+ return NilReason.valueOf(reason);
+ } catch (URISyntaxException e) {
+ Context.warningOccured(Context.current(), getClass(),
"parseNilReason", e, true);
+ return NilReason.OTHER;
+ }
+ }
+
/**
* The reason why a mandatory attribute if left unspecified.
*
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/AbstractElementTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/AbstractElementTest.java
index 3aca9e65e0..b5b2e61121 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/AbstractElementTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/AbstractElementTest.java
@@ -26,7 +26,7 @@ import java.util.Collection;
import org.junit.Test;
import org.apache.sis.test.TestCase;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java
index 39e7dee852..7c15dd8824 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/AbstractPositionalAccuracyTest.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
import jakarta.xml.bind.JAXBException;
import org.opengis.metadata.quality.Result;
import org.opengis.util.InternationalString;
+import org.opengis.metadata.quality.ConformanceResult;
// Test dependencies
import org.junit.Test;
@@ -28,7 +29,7 @@ import org.apache.sis.xml.bind.lan.FreeTextMarshallingTest;
import org.apache.sis.metadata.xml.TestUsingFile;
import org.apache.sis.test.DependsOn;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import static org.opengis.test.Assert.assertInstanceOf;
import static org.apache.sis.test.TestUtilities.getSingleton;
@@ -102,7 +103,7 @@ public final class AbstractPositionalAccuracyTest extends
TestUsingFile {
*/
final Result result = getSingleton(metadata.getResults());
assertInstanceOf("Wrong value for <gmd:result>",
DefaultConformanceResult.class, result);
- assertEquals("result.pass", Boolean.TRUE, ((DefaultConformanceResult)
result).pass());
+ assertEquals(Boolean.TRUE, ((ConformanceResult) result).pass(),
"result.pass");
/*
* Marshalling: ensure that we didn't lost any information.
*/
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultConformanceResultTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultConformanceResultTest.java
new file mode 100644
index 0000000000..0b64e76994
--- /dev/null
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultConformanceResultTest.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.metadata.iso.quality;
+
+import jakarta.xml.bind.JAXBException;
+import org.apache.sis.util.SimpleInternationalString;
+import org.apache.sis.xml.Namespaces;
+import org.apache.sis.xml.NilReason;
+
+// Test dependencies
+import org.junit.Test;
+import org.apache.sis.xml.test.TestCase;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+
+/**
+ * Tests {@link DefaultConformanceResult}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ */
+public final class DefaultConformanceResultTest extends TestCase {
+ /**
+ * Creates a new test case.
+ */
+ public DefaultConformanceResultTest() {
+ }
+
+ /**
+ * Tests marshalling and unmarshalling of the given result.
+ *
+ * @param result the result to test.
+ * @param xml the expected XML
+ * @throws JAXBException if an error occurred during the during
marshalling / unmarshalling processes.
+ */
+ private void testXML(final DefaultConformanceResult result, final String
xml) throws JAXBException {
+ result.setExplanation(new SimpleInternationalString("A result"));
+ assertMarshalEquals(xml, result);
+ assertEquals(result, unmarshal(DefaultConformanceResult.class, xml));
+ }
+
+ /**
+ * Tests (un)marshalling of an XML document with a result.
+ *
+ * @throws JAXBException if an error occurred during the during
marshalling / unmarshalling processes.
+ */
+ @Test
+ public void testXML() throws JAXBException {
+ final var result = new DefaultConformanceResult();
+ result.setPass(true);
+ assertNull(result.getNilReason());
+ testXML(result,
+ "<mdq:DQ_ConformanceResult xmlns:mdq=\"" + Namespaces.MDQ + '"'
+ + " xmlns:gco=\"" + Namespaces.GCO +
"\">\n" +
+ " <mdq:explanation>\n" +
+ " <gco:CharacterString>A result</gco:CharacterString>\n" +
+ " </mdq:explanation>\n" +
+ " <mdq:pass>\n" +
+ " <gco:Boolean>true</gco:Boolean>\n" +
+ " </mdq:pass>\n" +
+ "</mdq:DQ_ConformanceResult>");
+ }
+
+ /**
+ * Tests (un)marshalling of an XML document with a result missing for an
unknown reason.
+ *
+ * @throws JAXBException if an error occurred during the during
marshalling / unmarshalling processes.
+ */
+ @Test
+ public void testUnknownReason() throws JAXBException {
+ final var result = new DefaultConformanceResult();
+ assertEquals(NilReason.UNKNOWN, result.getNilReason());
+ testXML(result,
+ "<mdq:DQ_ConformanceResult xmlns:mdq=\"" + Namespaces.MDQ + '"'
+ + " xmlns:gco=\"" + Namespaces.GCO +
"\">\n" +
+ " <mdq:explanation>\n" +
+ " <gco:CharacterString>A result</gco:CharacterString>\n" +
+ " </mdq:explanation>\n" +
+ " <mdq:pass gco:nilReason=\"unknown\"/>\n" +
+ "</mdq:DQ_ConformanceResult>");
+ }
+
+ /**
+ * Tests (un)marshalling of an XML document with a result missing because
the XML is a template.
+ *
+ * @throws JAXBException if an error occurred during the during
marshalling / unmarshalling processes.
+ */
+ @Test
+ public void testTemplateReason() throws JAXBException {
+ final var result = new DefaultConformanceResult();
+ result.setPass(true);
+ result.setNilReason(NilReason.TEMPLATE);
+ assertNull(result.pass());
+ testXML(result,
+ "<mdq:DQ_ConformanceResult xmlns:mdq=\"" + Namespaces.MDQ + '"'
+ + " xmlns:gco=\"" + Namespaces.GCO +
"\">\n" +
+ " <mdq:explanation>\n" +
+ " <gco:CharacterString>A result</gco:CharacterString>\n" +
+ " </mdq:explanation>\n" +
+ " <mdq:pass gco:nilReason=\"template\"/>\n" +
+ "</mdq:DQ_ConformanceResult>");
+ }
+}
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultDomainConsistencyTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultDomainConsistencyTest.java
index 8cd98a147a..f1dd37ee97 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultDomainConsistencyTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultDomainConsistencyTest.java
@@ -24,7 +24,7 @@ import java.util.Set;
import org.junit.Test;
import org.apache.sis.test.TestCase;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethodTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethodTest.java
index a7e2e0a50a..7a931c7a13 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethodTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethodTest.java
@@ -24,7 +24,7 @@ import java.time.temporal.Temporal;
import org.junit.Test;
import org.apache.sis.test.TestCase;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.test.Assertions.assertSerializedEquals;
@@ -52,7 +52,7 @@ public final class DefaultEvaluationMethodTest extends
TestCase {
/*
* dates = []
*/
- assertTrue("isEmpty()", dates.isEmpty());
+ assertTrue(dates.isEmpty(), "isEmpty()");
assertCanNotGet(dates, 2);
assertCanNotGet(dates, 1);
assertCanNotGet(dates, 0);
@@ -62,7 +62,7 @@ public final class DefaultEvaluationMethodTest extends
TestCase {
assertCanNotAdd(dates, 2, now);
assertCanNotAdd(dates, 1, now);
dates.add(0, now);
- assertEquals("size()", 1, dates.size());
+ assertEquals(1, dates.size(), "size()");
assertCanNotGet(dates, 2);
assertCanNotGet(dates, 1);
assertEquals(now, dates.get(0));
@@ -71,7 +71,7 @@ public final class DefaultEvaluationMethodTest extends
TestCase {
*/
assertCanNotAdd(dates, 2, later);
dates.add(1, later);
- assertEquals("size()", 2, dates.size());
+ assertEquals(2, dates.size(), "size()");
assertCanNotGet(dates, 2);
assertEquals(later, dates.get(1));
assertEquals(now, dates.get(0));
@@ -79,7 +79,7 @@ public final class DefaultEvaluationMethodTest extends
TestCase {
* dates = [later]
*/
assertEquals(now, dates.remove(0));
- assertEquals("size()", 1, dates.size());
+ assertEquals(1, dates.size(), "size()");
assertCanNotGet(dates, 2);
assertCanNotGet(dates, 1);
assertEquals(later, dates.get(0));
@@ -87,7 +87,7 @@ public final class DefaultEvaluationMethodTest extends
TestCase {
* dates = [now, later]
*/
dates.add(0, now);
- assertEquals("size()", 2, dates.size());
+ assertEquals(2, dates.size(), "size()");
assertCanNotGet(dates, 2);
assertEquals(later, dates.get(1));
assertEquals(now, dates.get(0));
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResultTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResultTest.java
index de37ed6bb6..396fdc68b2 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResultTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResultTest.java
@@ -37,7 +37,7 @@ import org.junit.Test;
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.TestCase;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/ScopeCodeTest.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/ScopeCodeTest.java
index 61f7441757..bf708118a7 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/ScopeCodeTest.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/iso/quality/ScopeCodeTest.java
@@ -23,7 +23,7 @@ import org.opengis.metadata.maintenance.ScopeCode;
import org.junit.Test;
import org.apache.sis.xml.test.TestCase;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import static org.apache.sis.metadata.Assertions.assertXmlEquals;
// Specific to the geoapi-3.1 and geoapi-4.0 branches:
@@ -80,7 +80,7 @@ public final class ScopeCodeTest extends TestCase {
public void testUnmarshallingLegacy() throws JAXBException {
final DefaultDataQuality metadata =
unmarshal(DefaultDataQuality.class, XML);
final Scope scope = metadata.getScope();
- assertNotNull("scope", scope);
+ assertNotNull(scope, "scope");
assertEquals(ScopeCode.DATASET, scope.getLevel());
}
}
diff --git
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/TestCase.java
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/TestCase.java
index 7b86ff7f1b..3f9c9afa5d 100644
---
a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/TestCase.java
+++
b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/test/TestCase.java
@@ -175,6 +175,18 @@ public abstract class TestCase extends
org.apache.sis.test.TestCase {
}
}
+ /**
+ * Marshals the given object and ensures that the result is equal to the
given string.
+ * This convenience method uses a default set of attributes to ignore.
+ *
+ * @param expected the expected XML.
+ * @param object the object to marshal.
+ * @throws JAXBException if an error occurred during marshalling.
+ */
+ protected final void assertMarshalEquals(final String expected, final
Object object) throws JAXBException {
+ assertXmlEquals(expected, marshal(object), "xmlns:*");
+ }
+
/**
* Marshals the given object and ensures that the result is equal to the
content of the given stream.
* The stream should be opened by a call to {@link
Class#getResourceAsStream(String)} from the module