Search in sources :

Example 6 with Series

use of org.opengis.metadata.citation.Series in project sis by apache.

the class UUIDMarshallingTest method testReference.

/**
 * Tests (un)marshalling of an object referenced by a {@code uuidref} attribute.
 * This test does not try to resolve the reference, but only check that the identifier is properly saved.
 *
 * <p>The element of interest for this test is the {@code "uuidref"} part
 * in the {@code <gmd:series>} property of the following XML fragment:</p>
 *
 * {@preformat xml
 *   <cit:CI_Citation>
 *     <cit:title>
 *       <gco:CharacterString>My data</gco:CharacterString>
 *     </cit:title>
 *     <cit:series uuidref="f8f5fcb1-d57b-4013-b3a4-4eaa40df6dcf">
 *       <cit:CI_Series>
 *         <cit:name>
 *           <gco:CharacterString>My aggregate dataset</gco:CharacterString>
 *         </cit:name>
 *       </cit:CI_Series>
 *     </cit:series>
 *   </cit:CI_Citation>
 * }
 *
 * On an implementation note, the {@code uuidref}, {@code xlink:href} and other attributes of the
 * {@code <gmd:series>} element are handled by {@link org.apache.sis.internal.jaxb.gco.PropertyType}.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
public void testReference() throws JAXBException {
    final Citation citation = (Citation) XML.unmarshal(REFERENCED_XML_WITH_BODY);
    assertTitleEquals("Citation.title", "My data", citation);
    /*
         * Programmatic verification of the Series properties,
         * which is the main object of interest in this test.
         */
    final Series series = citation.getSeries();
    assertInstanceOf("Citation.series", IdentifiedObject.class, series);
    assertFalse("Citation.series.isProxy", Proxy.isProxyClass(series.getClass()));
    assertEquals("Citation.series.name", "My aggregate dataset", series.getName().toString());
    final IdentifierMap map = ((IdentifiedObject) series).getIdentifierMap();
    assertNull("href", map.get(IdentifierSpace.HREF));
    assertEquals("uuid", UUID_VALUE, map.get(IdentifierSpace.UUID));
    /*
         * Marshal the object back to XML and compare with the expected result. The result shall be
         * slightly different than the original XML, since the UUID in the <gmd:series> element shall
         * move to the <gmd:CI_Series> element. This is the expected behavior because we have a fully
         * constructed object, not a reference to an object defined elsewhere.
         */
    final String actual = XML.marshal(citation);
    assertXmlEquals(IDENTIFIED_XML, actual, "xmlns:*");
    assertEquals(citation, XML.unmarshal(actual));
}
Also used : Series(org.opengis.metadata.citation.Series) Citation(org.opengis.metadata.citation.Citation) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 Citation (org.opengis.metadata.citation.Citation)6 Series (org.opengis.metadata.citation.Series)6 DependsOnMethod (org.apache.sis.test.DependsOnMethod)3