use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class TreeNodeChildrenTest method testShowAll.
/**
* Tests the children list with the {@link ValueExistencePolicy#ALL}.
*/
@Test
@DependsOnMethod("testReadOnlyWithMultiOccurrences")
public void testShowAll() {
final DefaultCitation citation = metadataWithMultiOccurrences();
final TreeNodeChildren children = create(citation, ValueExistencePolicy.ALL);
final String[] expected = { "Some title", "First alternate title", "Second alternate title", // dates (collection)
null, "Some edition", // edition date
null, // identifiers (collection)
null, // cited responsibly parties (collection)
null, "PresentationForm[MAP_DIGITAL]", "PresentationForm[MAP_HARDCOPY]", // series
null, "Some other details", // ISBN
null, // ISSN
null, // onlineResources (collection)
null, // graphics (collection)
null };
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 TreeNodeTest method metadataWithHierarchy.
/**
* Creates a metadata hierarchy to be used for the tests.
* This method creates the following metadata:
*
* {@preformat text
* Citation
* ├─Title…………………………………………………………………………………………… Some title
* ├─Alternate title (1 of 2)………………………………………… First alternate title
* ├─Alternate title (2 of 2)………………………………………… Second alternate title
* ├─Edition……………………………………………………………………………………… Some edition
* ├─Cited responsible party (1 of 2)
* │ └─Organisation
* │ ├─Name…………………………………………………………………………… Some organisation
* │ └─Role…………………………………………………………………………… Distributor
* ├─Cited responsible party (2 of 2)
* │ └─Individual
* │ ├─Name…………………………………………………………………………… Some person of contact
* │ ├─Contact info
* │ │ └─Address
* │ │ └─Electronic mail address…… Some email
* │ └─Role…………………………………………………………………………… Point of contact
* ├─Presentation form (1 of 2)…………………………………… Map digital
* ├─Presentation form (2 of 2)…………………………………… map hardcopy
* └─Other citation details……………………………………………… Some other details
* }
*/
static DefaultCitation metadataWithHierarchy() {
final DefaultCitation citation = TreeNodeChildrenTest.metadataWithMultiOccurrences();
AbstractParty party = new DefaultOrganisation("Some organisation", null, null, null);
DefaultResponsibleParty responsibility = new DefaultResponsibleParty(Role.DISTRIBUTOR);
responsibility.setParties(singleton(party));
assertTrue(citation.getCitedResponsibleParties().add(responsibility));
// Add a second responsible party with deeper hierarchy.
final DefaultContact contact = new DefaultContact();
final DefaultAddress address = new DefaultAddress();
address.setElectronicMailAddresses(singleton("Some email"));
contact.setAddresses(singleton(address));
party = new DefaultIndividual("Some person of contact", null, contact);
responsibility = new DefaultResponsibleParty(Role.POINT_OF_CONTACT);
responsibility.setParties(singleton(party));
assertTrue(citation.getCitedResponsibleParties().add(responsibility));
return citation;
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class TreeNodeTest method testNewChild.
/**
* Tests {@link TreeNode#newChild()}.
*/
@Test
@DependsOnMethod("testGetValue")
public void testNewChild() {
final DefaultCitation citation = metadataWithHierarchy();
final TreeNode node = create(citation, Citation.class);
/*
* Ensure that we can not overwrite existing nodes.
*/
TreeTable.Node child = node.newChild();
child.setValue(TableColumn.IDENTIFIER, "title");
try {
child.setValue(TableColumn.VALUE, "A new title");
fail("Attemps to overwrite an existing value shall fail.");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains("title"));
}
/*
* Clear the title and try again. This time, it shall work.
*/
citation.setTitle(null);
child = node.newChild();
child.setValue(TableColumn.IDENTIFIER, "title");
child.setValue(TableColumn.VALUE, "A new title");
assertTitleEquals("citation", "A new title", citation);
assertSame(citation.getTitle(), child.getValue(TableColumn.VALUE));
/*
* Try adding a new element in a collection.
* Note that the code below imply a conversion from String to InternationalString.
*/
child = node.newChild();
child.setValue(TableColumn.IDENTIFIER, "alternateTitle");
child.setValue(TableColumn.VALUE, "Third alternate title");
assertEquals(3, citation.getAlternateTitles().size());
assertEquals("Third alternate title", child.getValue(TableColumn.VALUE).toString());
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class TreeNodeTest method testGetNameForMultiOccurrences.
/**
* Tests {@link TreeNode#getName()} on a metadata with more than one entry in collections.
* Those names <em>shall</em> contain numbering like <cite>"(1 of 2)"</cite>.
*/
@Test
@DependsOnMethod("testGetNameForSingleton")
public void testGetNameForMultiOccurrences() {
final DefaultCitation citation = TreeNodeChildrenTest.metadataWithMultiOccurrences();
assertColumnContentEquals(create(citation, Citation.class), TableColumn.NAME, "Citation", "Title", "Alternate title (1 of 2)", "Alternate title (2 of 2)", "Edition", "Presentation form (1 of 2)", "Presentation form (2 of 2)", "Other citation details");
}
use of org.apache.sis.metadata.iso.citation.DefaultCitation in project sis by apache.
the class TreeTableFormatTest method testProcessing.
/**
* Tests the formatting of a {@link DefaultProcessing} object.
*/
@Test
public void testProcessing() {
final DefaultCitation titled = new DefaultCitation("Some specification");
final DefaultCitation coded = new DefaultCitation();
final DefaultCitation untitled = new DefaultCitation();
titled.setPresentationForms(singleton(PresentationForm.DOCUMENT_HARDCOPY));
coded.setPresentationForms(singleton(PresentationForm.IMAGE_HARDCOPY));
untitled.setCitedResponsibleParties(singleton(new DefaultResponsibleParty(Role.AUTHOR)));
final DefaultProcessing processing = new DefaultProcessing();
processing.setDocumentations(asList(titled, coded, untitled));
final String text = format.format(processing.asTreeTable());
assertMultilinesEquals("Processing\n" + " ├─Documentation (1 of 3)…………… Some specification\n" + " │ └─Presentation form……………… Document hardcopy\n" + " ├─Documentation (2 of 3)\n" + " │ └─Presentation form……………… Image hardcopy\n" + " └─Documentation (3 of 3)\n" + " └─Cited responsible party\n" + " └─Role……………………………………… Author\n", text);
}
Aggregations