Search in sources :

Example 26 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class PropertyTypeTest method testWithXLink.

/**
 * Implementation of the public {@code test*XLink()} methods.
 *
 * <ul>
 *   <li>If {@code useReferenceResolverMock} is {@code false}, then this test uses the default SIS behavior,
 *       which is to not omit the metadata and still write the XLink for informative purpose.</li>
 *
 *   <li>If {@code useReferenceResolverMock} is {@code true}, then the metadata object shall be replaced
 *       by the XLink because the {@link ReferenceResolverMock#canSubstituteByReference(MarshalContext,
 *       Class, Object, XLink)} method returns {@code true}.</li>
 * </ul>
 */
private void testWithXLink(final boolean useReferenceResolverMock) {
    final XLink link = new XLink();
    link.setShow(XLink.Show.REPLACE);
    link.setActuate(XLink.Actuate.ON_LOAD);
    link.setTitle(new SimpleInternationalString("myLinkTitle"));
    metadata.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, link);
    if (useReferenceResolverMock) {
        context = ReferenceResolverMock.begin(true);
    // XMLTestCase.clearContext() will dispose the context.
    }
    final PropertyTypeMock property = marshal();
    if (!useReferenceResolverMock) {
        assertSame(metadata, property.metadata);
    } else {
        assertNull("metadata", property.metadata);
    }
    assertNull("nilReason", property.getNilReason());
    assertNull("uuidref", property.getUUIDREF());
    assertNull("href", property.getHRef());
    assertNull("role", property.getRole());
    assertNull("arcrole", property.getArcRole());
    assertEquals("title", "myLinkTitle", property.getTitle());
    assertEquals("show", XLink.Show.REPLACE, property.getShow());
    assertEquals("actuate", XLink.Actuate.ON_LOAD, property.getActuate());
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) XLink(org.apache.sis.xml.XLink)

Example 27 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class ValueMapTest method createCitation.

/**
 * Creates the metadata instance to be used for testing purpose.
 * This method creates the following metadata
 * (ignoring identifiers, which will be inferred from the ISBN value):
 *
 * {@preformat text
 *     Citation
 *       ├─Title…………………………………………………… Undercurrent
 *       ├─Edition……………………………………………… <nil:unknown>
 *       ├─Cited Responsible Parties
 *       │   └─Individual Name……………… Testsuya Toyoda
 *       └─ISBN……………………………………………………… 9782505004509
 * }
 *
 * The citation instance is stored in the {@link #citation} field.
 * The title and author instances are stored in the {@link #title} and {@link #author} fields.
 *
 * @return the map view of the citation create by this method.
 */
private Map<String, Object> createCitation() {
    title = new SimpleInternationalString("Undercurrent");
    author = new DefaultResponsibleParty();
    citation = new DefaultCitation(title);
    author.setParties(singleton(new DefaultIndividual("Testsuya Toyoda", null, null)));
    citation.setCitedResponsibleParties(singleton(author));
    citation.setISBN("9782505004509");
    citation.setEdition(NilReason.UNKNOWN.createNilObject(InternationalString.class));
    return MetadataStandard.ISO_19115.asValueMap(citation, null, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
}
Also used : DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultIndividual(org.apache.sis.metadata.iso.citation.DefaultIndividual)

Example 28 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class CustomMetadataTest method testProxy.

/**
 * Tests the marshalling of a metadata implemented by {@link Proxy}.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
public void testProxy() throws JAXBException {
    /*
         * A trivial metadata implementation which return the method name
         * for every attribute of type InternationalString.
         */
    final InvocationHandler handler = (Object proxy, Method method, Object[] args) -> {
        if (method.getReturnType() == InternationalString.class) {
            return new SimpleInternationalString(method.getName());
        }
        return null;
    };
    Citation data = (Citation) Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[] { Citation.class }, handler);
    /*
         * Wrap the metadata in a DefaultMetadata, and ensure
         * we can marshall it without an exception being throw.
         */
    data = new DefaultCitation(data);
    final String xml = XML.marshal(data);
    /*
         * A few simple checks.
         */
    assertTrue(xml.contains("title"));
    assertTrue(xml.contains("edition"));
}
Also used : InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Method(java.lang.reflect.Method) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) InvocationHandler(java.lang.reflect.InvocationHandler) Test(org.junit.Test)

Example 29 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class DefaultMetadataTest method testParentIdentifier.

/**
 * Tests {@link DefaultMetadata#getParentIdentifier()} and {@link DefaultMetadata#setParentIdentifier(String)}
 * methods.
 */
@Test
@SuppressWarnings("deprecation")
public void testParentIdentifier() {
    final DefaultMetadata metadata = new DefaultMetadata();
    assertNull("parentIdentifier", metadata.getParentIdentifier());
    metadata.setParentIdentifier("ParentID");
    assertEquals("parentIdentifier", "ParentID", metadata.getParentIdentifier());
    DefaultCitation c = (DefaultCitation) metadata.getParentMetadata();
    assertTitleEquals("parentMetadata", "ParentID", c);
    c.setTitle(new SimpleInternationalString("New parent"));
    assertEquals("parentIdentifier", "New parent", metadata.getParentIdentifier());
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test)

Example 30 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class DefaultKeywordsTest method testConstructor.

/**
 * Tests {@link DefaultKeywords#DefaultKeywords(CharSequence[])}.
 */
@Test
public void testConstructor() {
    final DefaultKeywords keywords = new DefaultKeywords("Keyword 1", "Keyword 2", "Keyword 3");
    assertArrayEquals(new Object[] { new SimpleInternationalString("Keyword 1"), new SimpleInternationalString("Keyword 2"), new SimpleInternationalString("Keyword 3") }, keywords.getKeywords().toArray());
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test)

Aggregations

SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)45 Test (org.junit.Test)20 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)19 InternationalString (org.opengis.util.InternationalString)14 URI (java.net.URI)4 DependsOnMethod (org.apache.sis.test.DependsOnMethod)4 NamedIdentifier (org.apache.sis.referencing.NamedIdentifier)3 Citation (org.opengis.metadata.citation.Citation)3 IdentifiedObject (org.opengis.referencing.IdentifiedObject)3 Collection (java.util.Collection)2 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)2 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)2 DefaultAcquisitionInformation (org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation)2 DefaultInstrument (org.apache.sis.metadata.iso.acquisition.DefaultInstrument)2 DefaultPlatform (org.apache.sis.metadata.iso.acquisition.DefaultPlatform)2 DefaultFormat (org.apache.sis.metadata.iso.distribution.DefaultFormat)2 DefaultDataQuality (org.apache.sis.metadata.iso.quality.DefaultDataQuality)2 InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1 URISyntaxException (java.net.URISyntaxException)1