Search in sources :

Example 1 with Series

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

the class NilReasonMarshallingTest method testURI.

/**
 * Tests a case where the nil reason is specified by a URI.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
@DependsOnMethod("testMissing")
public void testURI() throws JAXBException {
    final String expected = "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + "  <cit:title>\n" + "    <gco:CharacterString>A title</gco:CharacterString>\n" + "  </cit:title>\n" + "  <cit:series gco:nilReason=\"http://www.myreason.org\"/>\n" + "</cit:CI_Citation>";
    final Citation citation = unmarshal(Citation.class, expected);
    assertTitleEquals("citation", "A title", citation);
    final Series series = citation.getSeries();
    assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
    final NilReason reason = ((NilObject) series).getNilReason();
    assertNull("NilReason.explanation", reason.getOtherExplanation());
    assertEquals("NilReason.URI", "http://www.myreason.org", String.valueOf(reason.getURI()));
    assertEquals("Series[http://www.myreason.org]", series.toString());
    assertNull("All attributes are expected to be null.", series.getName());
    final String actual = marshal(citation);
    assertXmlEquals(expected, actual, "xmlns:*");
    assertEquals(citation, unmarshal(Citation.class, actual));
}
Also used : Series(org.opengis.metadata.citation.Series) Citation(org.opengis.metadata.citation.Citation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 2 with Series

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

the class NilReasonMarshallingTest method testOther.

/**
 * Tests a case where the nil reason is specified by an other reason.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
@DependsOnMethod("testMissing")
public void testOther() throws JAXBException {
    final String expected = "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + "  <cit:title>\n" + "    <gco:CharacterString>A title</gco:CharacterString>\n" + "  </cit:title>\n" + "  <cit:series gco:nilReason=\"other:myReason\"/>\n" + "</cit:CI_Citation>";
    final Citation citation = unmarshal(Citation.class, expected);
    assertTitleEquals("citation", "A title", citation);
    final Series series = citation.getSeries();
    assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
    final NilReason reason = ((NilObject) series).getNilReason();
    assertEquals("NilReason.explanation", "myReason", reason.getOtherExplanation());
    assertNull("NilReason.URI", reason.getURI());
    assertEquals("Series[other:myReason]", series.toString());
    assertNull("All attributes are expected to be null.", series.getName());
    final String actual = marshal(citation);
    assertXmlEquals(expected, actual, "xmlns:*");
    assertEquals(citation, unmarshal(Citation.class, actual));
}
Also used : Series(org.opengis.metadata.citation.Series) Citation(org.opengis.metadata.citation.Citation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 3 with Series

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

the class UUIDMarshallingTest method testReferenceInEmptyObject.

/**
 * The same test than {@link #testReference()}, except that the {@code <gmd:CI_Series>} element is empty.
 * This situation shall force the creation of a new, empty, element for storing the {@code uuidref} information.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
@DependsOnMethod("testReference")
public void testReferenceInEmptyObject() throws JAXBException {
    final Citation citation = (Citation) XML.unmarshal(REFERENCED_XML);
    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);
    assertNull("Citation.series.name", series.getName());
    assertTrue("Citation.series.isProxy", Proxy.isProxyClass(series.getClass()));
    assertInstanceOf("Citation.series", NilObject.class, series);
    assertEquals("Series[{gco:uuid=“" + UUID_VALUE + "”}]", series.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.
         */
    final String actual = XML.marshal(citation);
    assertXmlEquals(REFERENCED_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) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 4 with Series

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

the class UUIDMarshallingTest method testIdentification.

/**
 * Tests (un)marshalling of an object identified by the {@code uuid} attribute.
 * The element of interest for this test is the {@code "uuid"} attribute value
 * in the {@code <gmd:CI_Series>} element of the following XML fragment:
 *
 * {@preformat xml
 *   <cit:CI_Citation>
 *     <cit:title>
 *       <gco:CharacterString>My data</gco:CharacterString>
 *     </cit:title>
 *     <cit:series>
 *       <cit:CI_Series uuid="f8f5fcb1-d57b-4013-b3a4-4eaa40df6dcf">
 *         <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 uuid} and other attributes of the {@code <gmd:CI_Series>}
 * elements are handled by {@link org.apache.sis.internal.jaxb.gco.PropertyType}.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
public void testIdentification() throws JAXBException {
    final Citation citation = (Citation) XML.unmarshal(IDENTIFIED_XML);
    assertTitleEquals("Citation", "My data", citation);
    /*
         * Programmatic verification of the Series properties,
         * which is the main object of interest in this test.
         */
    final Series series = citation.getSeries();
    assertFalse("Unexpected proxy", Proxy.isProxyClass(series.getClass()));
    assertInstanceOf("Expected IdentifiedObject", IdentifiedObject.class, series);
    final IdentifierMap map = ((IdentifiedObject) series).getIdentifierMap();
    assertEquals("series", "My aggregate dataset", series.getName().toString());
    assertNull("href", map.get(IdentifierSpace.HREF));
    assertEquals(UUID_VALUE, String.valueOf(map.get(IdentifierSpace.UUID)));
    /*
         * Marshal the object back to XML and compare with the original string
         * supplied to this method.
         */
    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)

Example 5 with Series

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

the class NilReasonMarshallingTest method testMissing.

/**
 * Tests a simple case for a missing data.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
public void testMissing() throws JAXBException {
    final String expected = "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + "  <cit:title>\n" + "    <gco:CharacterString>A title</gco:CharacterString>\n" + "  </cit:title>\n" + "  <cit:series gco:nilReason=\"missing\"/>\n" + "</cit:CI_Citation>";
    final Citation citation = unmarshal(Citation.class, expected);
    assertTitleEquals("citation", "A title", citation);
    final Series series = citation.getSeries();
    assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
    final NilReason reason = ((NilObject) series).getNilReason();
    assertSame("nilReason", NilReason.MISSING, reason);
    assertNull("NilReason.explanation", reason.getOtherExplanation());
    assertNull("NilReason.URI", reason.getURI());
    assertEquals("Series[missing]", series.toString());
    assertNull("All attributes are expected to be null.", series.getName());
    final String actual = marshal(citation);
    assertXmlEquals(expected, actual, "xmlns:*");
    assertEquals(citation, unmarshal(Citation.class, 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