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.assertNotNull;
|
13
|
|
14
|
import java.io.InputStreamReader;
|
15
|
import eu.etaxonomy.cdm.common.URI;
|
16
|
|
17
|
import org.junit.Test;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
|
20
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
21
|
|
22
|
public class AnnotationTest {
|
23
|
|
24
|
private String resource = "/eu/etaxonomy/cdm/io/jaxb/AnnotationTest.xml";
|
25
|
|
26
|
@Test
|
27
|
public void testUnmarshalAnnotations() throws Exception {
|
28
|
CdmDocumentBuilder cdmDocumentBuilder = new CdmDocumentBuilder();
|
29
|
URI uri = new URI(URIEncoder.encode(this.getClass().getResource(resource).toString()));
|
30
|
DataSet dataSet = cdmDocumentBuilder.unmarshal(DataSet.class, new InputStreamReader(this.getClass().getResourceAsStream(resource)),uri.toString());
|
31
|
|
32
|
AnnotatableEntity annotatableEntity = dataSet.getTaxonBases().get(0);
|
33
|
assertNotNull("annotatableEntity must exist",annotatableEntity);
|
34
|
|
35
|
assertNotNull("annotatableEntity must have annotations",annotatableEntity.getAnnotations());
|
36
|
assertEquals("There should be one annotation",1,annotatableEntity.getAnnotations().size());
|
37
|
|
38
|
Annotation annotation = annotatableEntity.getAnnotations().iterator().next();
|
39
|
// assertEquals("object must also be the annotated object",annotatableEntity,annotation.getAnnotatedObj());
|
40
|
assertNotNull("Annotation must have annotations",annotation.getAnnotations());
|
41
|
assertEquals("There should be one annotation",1,annotation.getAnnotations().size());
|
42
|
Annotation annotationTwo = annotation.getAnnotations().iterator().next();
|
43
|
// assertEquals("Annotation should be the annotated object",annotation,annotationTwo.getAnnotatedObj());
|
44
|
}
|
45
|
}
|