use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class MetadataSourceTest method testSearch.
/**
* Tests {@link MetadataSource#search(Object)}
*
* @param source the instance to test.
* @throws MetadataStoreException if an error occurred while querying the database.
*/
@TestStep
public static void testSearch(final MetadataSource source) throws MetadataStoreException {
final DefaultCitation specification = new DefaultCitation("PNG (Portable Network Graphics) Specification");
specification.setAlternateTitles(Collections.singleton(new SimpleInternationalString("PNG")));
final DefaultFormat format = new DefaultFormat();
format.setFormatSpecificationCitation(specification);
assertEquals("PNG", source.search(format));
specification.setTitle(null);
assertNull(source.search(format));
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation 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);
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation 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"));
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation 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());
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class ImmutableIdentifierTest method testMarshal.
/**
* Test XML marshalling.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*/
@Test
public void testMarshal() throws JAXBException {
final ImmutableIdentifier identifier = new ImmutableIdentifier(new DefaultCitation("EPSG"), null, "4326");
assertXmlEquals("<gmd:RS_Identifier xmlns:gmd=\"" + LegacyNamespaces.GMD + "\" " + "xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n" + " <gmd:authority>\n" + " <gmd:CI_Citation>\n" + " <gmd:title>\n" + " <gco:CharacterString>EPSG</gco:CharacterString>\n" + " </gmd:title>\n" + " </gmd:CI_Citation>\n" + " </gmd:authority>\n" + " <gmd:code>\n" + " <gco:CharacterString>4326</gco:CharacterString>\n" + " </gmd:code>\n" + "</gmd:RS_Identifier>", marshal(identifier, VERSION_2007), "xmlns:*");
}
Aggregations