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
|
|
15
|
import java.io.InputStreamReader;
|
16
|
import java.net.URI;
|
17
|
|
18
|
import org.junit.Ignore;
|
19
|
import org.junit.Test;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.description.Feature;
|
22
|
import eu.etaxonomy.cdm.model.term.FeatureNode;
|
23
|
import eu.etaxonomy.cdm.model.term.FeatureTree;
|
24
|
|
25
|
@Ignore //does not work anymore since FeatureNode + Tree was moved to term package
|
26
|
public class FeatureTest {
|
27
|
|
28
|
private String resource = "/eu/etaxonomy/cdm/io/jaxb/FeatureTest.xml";
|
29
|
|
30
|
@Test
|
31
|
public void testUnmarshalFeatureTree() throws Exception {
|
32
|
CdmDocumentBuilder cdmDocumentBuilder = new CdmDocumentBuilder();
|
33
|
URI uri = new URI(URIEncoder.encode(this.getClass().getResource(resource).toString()));
|
34
|
DataSet dataSet = cdmDocumentBuilder.unmarshal(DataSet.class, new InputStreamReader(this.getClass().getResourceAsStream(resource)),uri.toString());
|
35
|
|
36
|
FeatureTree<Feature> featureTree = dataSet.getFeatureTrees().get(0);
|
37
|
Feature feature = (Feature)dataSet.getTerms().get(1);
|
38
|
|
39
|
assertNotNull("FeatureTree must not be null", featureTree);
|
40
|
assertNotNull("Feature must not be null", feature);
|
41
|
|
42
|
assertNotNull("FeatureTree.root must not be null", featureTree.getRoot());
|
43
|
FeatureNode<Feature> root = featureTree.getRoot();
|
44
|
assertNotNull("FeatureNode.feature must not be null", root.getTerm());
|
45
|
assertEquals("FeatureNode.feature must equal Feature", feature, root.getTerm());
|
46
|
|
47
|
assertNotNull("FeatureNode.children must not be null", root.getChildNodes());
|
48
|
assertFalse("FeatureNode.children must not be empty", root.getChildNodes().isEmpty());
|
49
|
assertEquals("FeatureNode.children must have 4 child nodes", 4, root.getChildNodes().size());
|
50
|
|
51
|
}
|
52
|
}
|