Search in sources :

Example 11 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeNodeChildrenTest method testReadOnlyWithSingletonInCollections.

/**
 * Tests read-only operations on a list of properties for a shallow metadata object with singleton
 * values in collections.
 */
@Test
@DependsOnMethod("testReadOnlyWithoutCollections")
public void testReadOnlyWithSingletonInCollections() {
    final DefaultCitation citation = metadataWithSingletonInCollections();
    final TreeNodeChildren children = create(citation, ValueExistencePolicy.NON_EMPTY);
    final String[] expected = { "Some title", "First alternate title", "Some edition", "PresentationForm[MAP_DIGITAL]", "Some other details" };
    assertEquals("titleProperty", -1, children.titleProperty);
    assertFalse("isEmpty()", children.isEmpty());
    assertEquals("size()", expected.length, children.size());
    assertAllNextEqual(expected, children.iterator());
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 12 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeNodeChildrenTest method metadataWithoutCollections.

/**
 * Creates a shallow metadata object without collections.
 *
 * {@preformat text
 *   DefaultCitation
 *     ├─Title………………………………………………… Some title
 *     ├─Edition…………………………………………… Some edition
 *     └─Other citation details…… Some other details
 * }
 */
static DefaultCitation metadataWithoutCollections() {
    final DefaultCitation citation = new DefaultCitation("Some title");
    citation.setEdition(new SimpleInternationalString("Some edition"));
    citation.setOtherCitationDetails(new SimpleInternationalString("Some other details"));
    return citation;
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString)

Example 13 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeNodeChildrenTest method testSimplifiable.

/**
 * Tests a metadata than can be simplified by displaying a child property value directly as the parent value.
 */
@Test
@DependsOnMethod("testReadOnlyWithoutCollections")
public void testSimplifiable() {
    final DefaultCitation citation = metadataSimplifiable();
    /*
         *   DefaultCitation
         *     └─Date
         *        ├─Date………………… 2012-01-01
         *        └─Date type…… Creation
         *
         * We need to perform the tests on the "Date" node, not on the "DefaultCitation" node.
         */
    final TreeTable.Node node = TestUtilities.getSingleton(create(citation, ValueExistencePolicy.COMPACT));
    assertEquals("value", 1325376000000L, ((Date) node.getValue(TableColumn.VALUE)).getTime());
    final TreeNodeChildren children = (TreeNodeChildren) node.getChildren();
    final String[] expected = { // The "Date" node should be omitted because merged with the parent "Date" node.
    "DateType[CREATION]" };
    assertEquals("titleProperty", 0, children.titleProperty);
    assertFalse("isEmpty()", children.isEmpty());
    assertEquals("size()", expected.length, children.size());
    assertAllNextEqual(expected, children.iterator());
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) TreeTable(org.apache.sis.util.collection.TreeTable) DefaultTreeTable(org.apache.sis.util.collection.DefaultTreeTable) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 14 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeNodeChildrenTest method testAdd.

/**
 * Tests the {@link TreeNodeChildren#add(TreeTable.Node)} method.
 */
@Test
@DependsOnMethod("testReadOnlyWithMultiOccurrences")
public void testAdd() {
    final DefaultCitation citation = metadataWithMultiOccurrences();
    final TreeNodeChildren children = create(citation, ValueExistencePolicy.NON_EMPTY);
    assertEquals("titleProperty", -1, children.titleProperty);
    final DefaultTreeTable.Node toAdd = new DefaultTreeTable.Node(new DefaultTreeTable(TableColumn.IDENTIFIER, TableColumn.VALUE));
    final String[] expected = { "Some title", "First alternate title", "Second alternate title", // After addition
    "Third alternate title", // After "addition" (actually change).
    "New edition", // After addition
    "PresentationForm[IMAGE_DIGITAL]", "PresentationForm[MAP_DIGITAL]", "PresentationForm[MAP_HARDCOPY]", "Some other details" };
    toAdd.setValue(TableColumn.IDENTIFIER, "edition");
    toAdd.setValue(TableColumn.VALUE, citation.getEdition());
    assertFalse("Adding the same value shall be a no-op.", children.add(toAdd));
    toAdd.setValue(TableColumn.VALUE, "New edition");
    try {
        children.add(toAdd);
        fail("Setting a different value shall be refused.");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("edition"));
    }
    // Clears so we are allowed to add.
    citation.setEdition(null);
    assertTrue("Setting a new value shall be a change.", children.add(toAdd));
    toAdd.setValue(TableColumn.IDENTIFIER, "presentationForm");
    toAdd.setValue(TableColumn.VALUE, PresentationForm.MAP_DIGITAL);
    assertFalse("Adding the same value shall be a no-op.", children.add(toAdd));
    toAdd.setValue(TableColumn.VALUE, PresentationForm.IMAGE_DIGITAL);
    assertTrue("Adding a new value shall be a change.", children.add(toAdd));
    toAdd.setValue(TableColumn.IDENTIFIER, "alternateTitle");
    toAdd.setValue(TableColumn.VALUE, "Third alternate title");
    assertTrue("Adding a new value shall be a change.", children.add(toAdd));
    assertEquals("size()", expected.length, children.size());
    assertAllNextEqual(expected, children.iterator());
}
Also used : DefaultTreeTable(org.apache.sis.util.collection.DefaultTreeTable) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 15 with DefaultCitation

use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.

the class TreeNodeChildrenTest method testClear.

/**
 * Tests the {@link TreeNodeChildren#clear()} method.
 */
@Test
public void testClear() {
    final DefaultCitation citation = metadataWithSingletonInCollections();
    final TreeNodeChildren children = create(citation, ValueExistencePolicy.NON_EMPTY);
    assertEquals("titleProperty", -1, children.titleProperty);
    assertFalse("isEmpty()", children.isEmpty());
    children.clear();
    assertTrue("isEmpty()", children.isEmpty());
    assertNull(citation.getTitle());
    assertTrue(citation.getAlternateTitles().isEmpty());
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Test(org.junit.Test)

Aggregations

DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)65 Test (org.junit.Test)35 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)32 DependsOnMethod (org.apache.sis.test.DependsOnMethod)21 InternationalString (org.opengis.util.InternationalString)14 Citation (org.opengis.metadata.citation.Citation)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)9 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)5 DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)5 URI (java.net.URI)3 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)3 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)3 DefaultCitationTest (org.apache.sis.metadata.iso.citation.DefaultCitationTest)3 DefaultOnlineResource (org.apache.sis.metadata.iso.citation.DefaultOnlineResource)3 ArrayList (java.util.ArrayList)2 CI_Citation (org.apache.sis.internal.jaxb.metadata.CI_Citation)2 SimpleIdentifiedObject (org.apache.sis.internal.simple.SimpleIdentifiedObject)2 SimpleIdentifier (org.apache.sis.internal.simple.SimpleIdentifier)2 DefaultCitationDate (org.apache.sis.metadata.iso.citation.DefaultCitationDate)2 DefaultIndividual (org.apache.sis.metadata.iso.citation.DefaultIndividual)2