1 |
0ecfd682
|
Andreas Müller
|
/**
|
2 |
|
|
* Copyright (C) 2007 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 |
|
|
|
10 |
|
|
package eu.etaxonomy.cdm.model.common;
|
11 |
|
|
|
12 |
|
|
import static org.junit.Assert.assertNotNull;
|
13 |
|
|
import static org.junit.Assert.assertNull;
|
14 |
|
|
import static org.junit.Assert.assertSame;
|
15 |
|
|
import static org.junit.Assert.fail;
|
16 |
|
|
|
17 |
|
|
import java.net.URISyntaxException;
|
18 |
|
|
|
19 |
|
|
import org.apache.log4j.Logger;
|
20 |
|
|
import org.junit.After;
|
21 |
|
|
import org.junit.AfterClass;
|
22 |
|
|
import org.junit.Before;
|
23 |
|
|
import org.junit.BeforeClass;
|
24 |
|
|
import org.junit.Test;
|
25 |
|
|
|
26 |
de8249cf
|
Andreas Müller
|
import eu.etaxonomy.cdm.common.URI;
|
27 |
0ecfd682
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.agent.Person;
|
28 |
|
|
import eu.etaxonomy.cdm.model.name.Rank;
|
29 |
fe34a9eb
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
30 |
0ecfd682
|
Andreas Müller
|
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
|
31 |
|
|
|
32 |
|
|
/**
|
33 |
|
|
* @author a.mueller
|
34 |
|
|
*
|
35 |
|
|
*/
|
36 |
|
|
public class AnnotationTest extends EntityTestBase {
|
37 |
|
|
|
38 |
|
|
@SuppressWarnings("unused")
|
39 |
|
|
private static final Logger logger = Logger.getLogger(AnnotationTest.class);
|
40 |
|
|
|
41 |
|
|
private static final String TEST_URI_STR = "http://test.abc.de";
|
42 |
|
|
|
43 |
|
|
private static Annotation annotation1;
|
44 |
|
|
private static Person commentator;
|
45 |
|
|
private static URI linkbackUri;
|
46 |
|
|
private static AnnotatableEntity annotatedObject;
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
/**
|
50 |
|
|
* @throws java.lang.Exception
|
51 |
|
|
*/
|
52 |
|
|
@BeforeClass
|
53 |
|
|
public static void setUpBeforeClass() throws Exception {
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
/**
|
57 |
|
|
* @throws java.lang.Exception
|
58 |
|
|
*/
|
59 |
|
|
@AfterClass
|
60 |
|
|
public static void tearDownAfterClass() throws Exception {
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
/**
|
64 |
|
|
* @throws java.lang.Exception
|
65 |
|
|
*/
|
66 |
|
|
@Before
|
67 |
|
|
public void setUp() throws Exception {
|
68 |
|
|
commentator = Person.NewInstance();
|
69 |
|
|
commentator.setTitleCache("automatic importer", true);
|
70 |
|
|
annotation1 = Annotation.NewInstance("anno1", Language.DEFAULT());
|
71 |
|
|
annotation1.setCommentator(commentator);
|
72 |
fe34a9eb
|
Andreas Müller
|
annotatedObject = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
73 |
0ecfd682
|
Andreas Müller
|
annotatedObject.addAnnotation(annotation1);
|
74 |
|
|
linkbackUri = new URI("http://www.abc.de");
|
75 |
|
|
annotation1.setLinkbackUri(linkbackUri);
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
/**
|
79 |
|
|
* @throws java.lang.Exception
|
80 |
|
|
*/
|
81 |
|
|
@After
|
82 |
|
|
public void tearDown() throws Exception {
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
/* ****************** TESTS *************************************/
|
86 |
|
|
|
87 |
|
|
/**
|
88 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#Annotation(java.lang.String, eu.etaxonomy.cdm.model.common.Language)}.
|
89 |
|
|
*/
|
90 |
|
|
@Test
|
91 |
|
|
public void testNewInstanceStringLanguage() {
|
92 |
|
|
assertNotNull(annotation1);
|
93 |
|
|
assertSame(commentator, annotation1.getCommentator());
|
94 |
|
|
assertSame(Language.DEFAULT(), annotation1.getLanguage());
|
95 |
|
|
assertSame(linkbackUri, annotation1.getLinkbackUri());
|
96 |
|
|
assertSame(annotatedObject.getAnnotations().iterator().next(), annotation1);
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
/**
|
100 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#getCommentator()}.
|
101 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#setCommentator(eu.etaxonomy.cdm.model.agent.Person)}.
|
102 |
|
|
*/
|
103 |
|
|
@Test
|
104 |
|
|
public void testGetSetCommentator() {
|
105 |
|
|
Person person = Person.NewInstance();
|
106 |
|
|
annotation1.setCommentator(person);
|
107 |
|
|
assertSame(person, annotation1.getCommentator());
|
108 |
|
|
annotation1.setCommentator(null);
|
109 |
|
|
assertNull(annotation1.getCommentator());
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
/**
|
113 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#getLinkbackUri()}.
|
114 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#setLinkbackUri(URI))}.
|
115 |
|
|
*/
|
116 |
|
|
@Test
|
117 |
|
|
public void testGetSetLinkbackUri() {
|
118 |
|
|
URI uri = null;
|
119 |
|
|
try {
|
120 |
|
|
uri = new URI(TEST_URI_STR);
|
121 |
|
|
} catch (URISyntaxException e) {
|
122 |
|
|
fail();
|
123 |
|
|
}
|
124 |
|
|
annotation1.setLinkbackUri(uri);
|
125 |
|
|
assertSame(uri, annotation1.getLinkbackUri());
|
126 |
|
|
annotation1.setLinkbackUri(null);
|
127 |
|
|
assertNull(annotation1.getLinkbackUri());
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
}
|