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());
}
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;
}
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());
}
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());
}
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());
}
Aggregations