Project

General

Profile

Download (2.7 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
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
package eu.etaxonomy.cdm.model.common;
10

    
11
import static org.junit.Assert.assertNotNull;
12
import static org.junit.Assert.assertNull;
13
import static org.junit.Assert.assertSame;
14
import static org.junit.Assert.fail;
15

    
16
import java.net.URISyntaxException;
17

    
18
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
19
import org.junit.Before;
20
import org.junit.Test;
21

    
22
import eu.etaxonomy.cdm.common.URI;
23
import eu.etaxonomy.cdm.model.agent.Person;
24
import eu.etaxonomy.cdm.model.name.Rank;
25
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
26
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
27

    
28
/**
29
 * @author a.mueller
30
 */
31
public class AnnotationTest extends EntityTestBase {
32

    
33
	@SuppressWarnings("unused")
34
	private static final Logger logger = LogManager.getLogger(AnnotationTest.class);
35

    
36
	private static final String TEST_URI_STR = "http://test.abc.de";
37

    
38
	private static Annotation annotation1;
39
	private static Person commentator;
40
	private static URI linkbackUri;
41
	private static AnnotatableEntity annotatedObject;
42

    
43
	@Before
44
	public void setUp() throws Exception {
45
		commentator = Person.NewInstance();
46
		commentator.setTitleCache("automatic importer", true);
47
		annotation1 = Annotation.NewInstance("anno1", Language.DEFAULT());
48
		annotation1.setCommentator(commentator);
49
		annotatedObject = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
50
		annotatedObject.addAnnotation(annotation1);
51
		linkbackUri = new URI("http://www.abc.de");
52
        annotation1.setLinkbackUri(linkbackUri);
53
	}
54

    
55
/* ****************** TESTS *************************************/
56

    
57
	@Test
58
	public void testNewInstanceStringLanguage() {
59
		assertNotNull(annotation1);
60
		assertSame(commentator, annotation1.getCommentator());
61
		assertSame(Language.DEFAULT(), annotation1.getLanguage());
62
		assertSame(linkbackUri, annotation1.getLinkbackUri());
63
		assertSame(annotatedObject.getAnnotations().iterator().next(), annotation1);
64
	}
65

    
66
	@Test
67
	public void testGetSetCommentator() {
68
		Person person = Person.NewInstance();
69
		annotation1.setCommentator(person);
70
		assertSame(person, annotation1.getCommentator());
71
		annotation1.setCommentator(null);
72
		assertNull(annotation1.getCommentator());
73
	}
74

    
75
	@Test
76
	public void testGetSetLinkbackUri() {
77
		URI uri = null;
78
		try {
79
			uri = new URI(TEST_URI_STR);
80
		} catch (URISyntaxException e) {
81
		    fail();
82
        }
83
		annotation1.setLinkbackUri(uri);
84
		assertSame(uri, annotation1.getLinkbackUri());
85
		annotation1.setLinkbackUri(null);
86
		assertNull(annotation1.getLinkbackUri());
87
	}
88
}
(1-1/12)