Search in sources :

Example 16 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class CustomMetadataTest method testSubtypeAttributes.

/**
 * Tests that the attributes defined in subtypes are also marshalled.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 *
 * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-108">GEOTK-108</a>
 */
@Test
public void testSubtypeAttributes() throws JAXBException {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    final DataIdentification identification = new DataIdentification() {

        @Override
        public InternationalString getAbstract() {
            Map<Locale, String> names = new HashMap<>();
            names.put(Locale.ENGLISH, "Description");
            return factory.createInternationalString(names);
        }

        @Override
        public InternationalString getEnvironmentDescription() {
            Map<Locale, String> names = new HashMap<>();
            names.put(Locale.ENGLISH, "Environment");
            return factory.createInternationalString(names);
        }

        @Override
        public InternationalString getSupplementalInformation() {
            return null;
        }

        @Override
        public Citation getCitation() {
            return null;
        }

        @Override
        public InternationalString getPurpose() {
            return null;
        }

        @Override
        public Collection<SpatialRepresentationType> getSpatialRepresentationTypes() {
            return null;
        }

        @Override
        public Collection<Resolution> getSpatialResolutions() {
            return null;
        }

        @Override
        public Collection<Locale> getLanguages() {
            return null;
        }

        @Override
        public Collection<CharacterSet> getCharacterSets() {
            return null;
        }

        @Override
        public Collection<TopicCategory> getTopicCategories() {
            return null;
        }

        @Override
        public Collection<Extent> getExtents() {
            return null;
        }

        @Override
        public Collection<String> getCredits() {
            return null;
        }

        @Override
        public Collection<Progress> getStatus() {
            return null;
        }

        @Override
        public Collection<ResponsibleParty> getPointOfContacts() {
            return null;
        }

        @Override
        public Collection<MaintenanceInformation> getResourceMaintenances() {
            return null;
        }

        @Override
        public Collection<BrowseGraphic> getGraphicOverviews() {
            return null;
        }

        @Override
        public Collection<Format> getResourceFormats() {
            return null;
        }

        @Override
        public Collection<Keywords> getDescriptiveKeywords() {
            return null;
        }

        @Override
        public Collection<Usage> getResourceSpecificUsages() {
            return null;
        }

        @Override
        public Collection<Constraints> getResourceConstraints() {
            return null;
        }

        @Deprecated
        @Override
        public Collection<AggregateInformation> getAggregationInfo() {
            return null;
        }
    };
    final DefaultMetadata data = new DefaultMetadata();
    data.setIdentificationInfo(singleton(identification));
    final String xml = XML.marshal(data);
    /*
         * A few simple checks.
         */
    assertTrue("Missing Identification attribute.", xml.contains("Description"));
    assertTrue("Missing DataIdentification attribute.", xml.contains("Environment"));
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) Extent(org.opengis.metadata.extent.Extent) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Format(org.opengis.metadata.distribution.Format) Constraints(org.opengis.metadata.constraint.Constraints) MaintenanceInformation(org.opengis.metadata.maintenance.MaintenanceInformation) NameFactory(org.opengis.util.NameFactory) SpatialRepresentationType(org.opengis.metadata.spatial.SpatialRepresentationType) Test(org.junit.Test)

Example 17 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class DefaultGeorectifiedTest method testCheckPointAvailable.

/**
 * Tests {@link DefaultGeorectified#isCheckPointAvailable()} and
 * {@link DefaultGeorectified#setCheckPointAvailable(boolean)}.
 */
@Test
public void testCheckPointAvailable() {
    final DefaultGeorectified metadata = new DefaultGeorectified();
    final InternationalString description = new SimpleInternationalString("A check point description.");
    assertFalse("checkPointAvailability", metadata.isCheckPointAvailable());
    // Setting the description shall set automatically the availability.
    metadata.setCheckPointDescription(description);
    assertTrue("checkPointAvailability", metadata.isCheckPointAvailable());
    loggings.assertNoUnexpectedLog();
    // Setting the availability flag shall hide the description and logs a message.
    metadata.setCheckPointAvailable(false);
    assertNull("checkPointDescription", metadata.getCheckPointDescription());
    loggings.assertNextLogContains("checkPointDescription", "checkPointAvailability");
    loggings.assertNoUnexpectedLog();
    // Setting the availability flag shall bring back the description.
    metadata.setCheckPointAvailable(true);
    assertSame("checkPointDescription", description, metadata.getCheckPointDescription());
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test)

Example 18 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class MetadataAssert method assertTitleEquals.

/**
 * Asserts that the English title of the given citation is equals to the expected string.
 *
 * @param message   the message to report in case of test failure.
 * @param expected  the expected English title.
 * @param citation  the citation to test.
 *
 * @since 0.6
 *
 * @see #assertAnyTitleEquals(String, String, Citation)
 */
public static void assertTitleEquals(final String message, final String expected, final Citation citation) {
    assertNotNull(message, citation);
    final InternationalString title = citation.getTitle();
    assertNotNull(message, title);
    assertEquals(message, expected, title.toString(Locale.US));
}
Also used : InternationalString(org.opengis.util.InternationalString)

Example 19 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class MetadataAssert method assertPartyNameEquals.

/**
 * Asserts that the given citation has only one responsible party,
 * and its English name is equals to the expected string.
 *
 * @param message   the message to report in case of test failure.
 * @param expected  the expected English responsibly party name.
 * @param citation  the citation to test.
 *
 * @since 0.8
 */
public static void assertPartyNameEquals(final String message, final String expected, final DefaultCitation citation) {
    assertNotNull(message, citation);
    final DefaultResponsibility r = (DefaultResponsibility) TestUtilities.getSingleton(citation.getCitedResponsibleParties());
    final InternationalString name = TestUtilities.getSingleton(r.getParties()).getName();
    assertNotNull(message, name);
    assertEquals(message, expected, name.toString(Locale.US));
}
Also used : DefaultResponsibility(org.apache.sis.metadata.iso.citation.DefaultResponsibility) InternationalString(org.opengis.util.InternationalString)

Example 20 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class AbstractPositionalAccuracyTest method roundtrip.

/**
 * Unmarshals the given file and verify the content.
 * Then marshals the object and verify that we get equivalent XML.
 */
private void roundtrip(final String filename, final Version version) throws JAXBException {
    final AbstractElement metadata = unmarshalFile(AbstractElement.class, filename);
    final InternationalString nameOfMeasure = getSingleton(metadata.getNamesOfMeasure());
    /*
         * Programmatic verification of the text group.
         */
    assertEquals("Quantitative quality measure focusing on the effective class percent " + "regarded to the total surface size", nameOfMeasure.toString(Locale.ENGLISH));
    assertEquals("Mesure qualité quantitative de type pourcentage de représentation de la " + "classe par rapport à la surface totale", nameOfMeasure.toString(Locale.FRENCH));
    /*
         * Opportunist test. While it was not the purpose of this test, the above metadata
         * needs to contain a "result" element in order to pass XML validation test.
         */
    final Result result = getSingleton(metadata.getResults());
    assertInstanceOf("Wrong value for <gmd:result>", DefaultConformanceResult.class, result);
    assertEquals("result.pass", Boolean.TRUE, ((DefaultConformanceResult) result).pass());
    /*
         * Marshalling: ensure that we didn't lost any information.
         */
    assertMarshalEqualsFile(filename, metadata, version, "xmlns:*", "xsi:schemaLocation", "xsi:type");
}
Also used : InternationalString(org.opengis.util.InternationalString) Result(org.opengis.metadata.quality.Result)

Aggregations

InternationalString (org.opengis.util.InternationalString)86 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)20 Test (org.junit.Test)17 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)13 IdentifiedObject (org.opengis.referencing.IdentifiedObject)10 ArrayList (java.util.ArrayList)7 Locale (java.util.Locale)6 GenericName (org.opengis.util.GenericName)6 Extent (org.opengis.metadata.extent.Extent)5 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)4 DependsOnMethod (org.apache.sis.test.DependsOnMethod)4 Vocabulary (org.apache.sis.util.resources.Vocabulary)4 Citation (org.opengis.metadata.citation.Citation)4 IllegalArgumentException (com.sun.star.lang.IllegalArgumentException)3 ResultSet (java.sql.ResultSet)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TableAppender (org.apache.sis.io.TableAppender)3 AbstractIdentifiedObject (org.apache.sis.referencing.AbstractIdentifiedObject)3 DataStoreException (org.apache.sis.storage.DataStoreException)3