Search in sources :

Example 56 with InternationalString

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

the class TypesTest method testToInternationalString.

/**
 * Implementation of {@link #testToInternationalString()} using the given map implementation.
 */
private static void testToInternationalString(final Map<String, Object> properties) {
    assertNull(properties.put("name", "Some name"));
    assertNull(properties.put("identifier", "Some identifier"));
    assertNull(properties.put("code", "Some code"));
    assertNull(properties.put("codeSpace", "Some code space"));
    assertNull(properties.put("authority", "Some authority"));
    assertNull(properties.put("version", "Some version"));
    assertNull(properties.put("remarks", "Some remarks"));
    assertNull(Types.toInternationalString(properties, "dummy"));
    InternationalString i18n = Types.toInternationalString(properties, "remarks");
    assertInstanceOf("Single locale", SimpleInternationalString.class, i18n);
    assertEquals("Some remarks", i18n.toString());
    assertNull(properties.put("remarks_fr", "Une remarque"));
    i18n = Types.toInternationalString(properties, "remarks");
    assertInstanceOf("Two locales", DefaultInternationalString.class, i18n);
    assertEquals("Some remarks", i18n.toString(Locale.ROOT));
    assertEquals("Une remarque", i18n.toString(Locale.FRENCH));
    assertNotNull(properties.remove("remarks"));
    i18n = Types.toInternationalString(properties, "remarks");
    assertInstanceOf("Single locale", SimpleInternationalString.class, i18n);
    assertEquals("Une remarque", i18n.toString());
}
Also used : InternationalString(org.opengis.util.InternationalString)

Example 57 with InternationalString

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

the class TypesTest method testGetDescription.

/**
 * Tests the {@link Types#getDescription(Class)} method.
 */
@Test
public void testGetDescription() {
    final InternationalString description = Types.getDescription(OnLineFunction.class);
    assertEquals("Function performed by the resource.", description.toString(Locale.ROOT));
    assertEquals("Function performed by the resource.", description.toString(Locale.ENGLISH));
    assertEquals("Fonctionnalité offerte par la ressource.", description.toString(Locale.FRENCH));
}
Also used : InternationalString(org.opengis.util.InternationalString) Test(org.junit.Test)

Example 58 with InternationalString

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

the class TypesTest method testGetCodeTitle.

/**
 * Tests {@code Types.getCodeTitle(ControlledVocabulary)}.
 * Also opportunistically tests {@link Types#forCodeTitle(CharSequence)}.
 */
@Test
public void testGetCodeTitle() {
    final InternationalString title = Types.getCodeTitle(OnLineFunction.DOWNLOAD);
    assertSame("forCodeTitle", OnLineFunction.DOWNLOAD, Types.forCodeTitle(title));
    assertEquals("Download", title.toString(Locale.ROOT));
    assertEquals("Download", title.toString(Locale.ENGLISH));
    assertEquals("Téléchargement", title.toString(Locale.FRENCH));
}
Also used : InternationalString(org.opengis.util.InternationalString) Test(org.junit.Test)

Example 59 with InternationalString

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

the class TypesTest method testGetCodeDescription.

/**
 * Tests the {@code Types.getDescription(ControlledVocabulary)} method.
 */
@Test
public void testGetCodeDescription() {
    final InternationalString description = Types.getDescription(OnLineFunction.DOWNLOAD);
    assertEquals("Online instructions for transferring data from one storage device or system to another.", description.toString(Locale.ROOT));
    assertEquals("Online instructions for transferring data from one storage device or system to another.", description.toString(Locale.ENGLISH));
    assertEquals("Transfert de la ressource d'un système à un autre.", description.toString(Locale.FRENCH));
}
Also used : InternationalString(org.opengis.util.InternationalString) Test(org.junit.Test)

Example 60 with InternationalString

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

the class NilReasonTest method testCreateNilInternationalString.

/**
 * Tests {@link NilReason#createNilObject(Class)} for an international string type.
 * Opportunistically tests {@link NilReason#forObject(Object)} with the created object.
 *
 * @since 0.4
 */
@Test
public void testCreateNilInternationalString() {
    final InternationalString value = NilReason.MISSING.createNilObject(InternationalString.class);
    assertEquals("", value.toString());
    assertInstanceOf("Unexpected impl.", NilObject.class, value);
    assertSame("NilReason.forObject(…)", NilReason.MISSING, NilReason.forObject(value));
    assertSame("Expected cached value.", value, NilReason.MISSING.createNilObject(InternationalString.class));
}
Also used : InternationalString(org.opengis.util.InternationalString) Test(org.junit.Test)

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