1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.io.jaxb;
|
10
|
|
11
|
import static org.junit.Assert.assertEquals;
|
12
|
import static org.junit.Assert.assertFalse;
|
13
|
import static org.junit.Assert.assertNotNull;
|
14
|
import static org.junit.Assert.assertTrue;
|
15
|
|
16
|
import java.io.InputStreamReader;
|
17
|
import eu.etaxonomy.cdm.common.URI;
|
18
|
|
19
|
import org.junit.Test;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.name.IBotanicalName;
|
22
|
import eu.etaxonomy.cdm.model.name.IZoologicalName;
|
23
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
|
24
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
25
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
26
|
|
27
|
public class TaxonNameTest {
|
28
|
|
29
|
private String resource = "/eu/etaxonomy/cdm/io/jaxb/TaxonNameTest.xml";
|
30
|
|
31
|
@Test
|
32
|
public void testUnmarshalName() throws Exception {
|
33
|
CdmDocumentBuilder cdmDocumentBuilder = new CdmDocumentBuilder();
|
34
|
URI uri = new URI(URIEncoder.encode(this.getClass().getResource(resource).toString()));
|
35
|
DataSet dataSet = cdmDocumentBuilder.unmarshal(DataSet.class, new InputStreamReader(this.getClass().getResourceAsStream(resource)),uri.toString());
|
36
|
|
37
|
IBotanicalName botanicalName = dataSet.getTaxonomicNames().get(0);
|
38
|
assertNotNull("BotanicalName must not be null",botanicalName);
|
39
|
DerivedUnit specimen = (DerivedUnit)dataSet.getOccurrences().get(0);
|
40
|
|
41
|
assertNotNull("BotanicalName.typeDesignations must not be null",botanicalName.getTypeDesignations());
|
42
|
assertFalse("BotanicalName.typeDesignations must contain TypeDesignation entities", botanicalName.getTypeDesignations().isEmpty());
|
43
|
|
44
|
SpecimenTypeDesignation specimenTypeDesignation = (SpecimenTypeDesignation)botanicalName.getTypeDesignations().iterator().next();
|
45
|
assertNotNull("SpecimenTypeDesignation.typifiedNames must not be null",specimenTypeDesignation.getTypifiedNames());
|
46
|
assertFalse("SpecimenTypeDesignation.typifiedNames must not be empty",specimenTypeDesignation.getTypifiedNames().isEmpty());
|
47
|
assertTrue("SpecimenTypeDesignation.typifiedNames must contain BotanicalName",specimenTypeDesignation.getTypifiedNames().contains(botanicalName));
|
48
|
|
49
|
assertNotNull("SpecimenTypeDesignation.typeSpecimen must not be null",specimenTypeDesignation.getTypeSpecimen());
|
50
|
assertEquals("SpecimenTypeDesignation.typeSpecimen must equal Specimen",specimen,specimenTypeDesignation.getTypeSpecimen());
|
51
|
|
52
|
IZoologicalName zoologicalName = dataSet.getTaxonomicNames().get(5);
|
53
|
assertNotNull("ZoologicalName must not be null",zoologicalName);
|
54
|
|
55
|
NameTypeDesignation nameTypeDesignation = (NameTypeDesignation)zoologicalName.getTypeDesignations().iterator().next();
|
56
|
assertNotNull("NameTypeDesignation.typeName must not be null",nameTypeDesignation.getTypeName());
|
57
|
assertEquals("NameTypeDesignation.typeName must equal ZoologicalName",dataSet.getTaxonomicNames().get(6),nameTypeDesignation.getTypeName());
|
58
|
|
59
|
}
|
60
|
}
|