Project

General

Profile

« Previous | Next » 

Revision 0ecfd682

Added by Andreas Müller almost 8 years ago

Remove bidirectionality for supplemental data #5743

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/AnnotationTest.java
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

  
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.URI;
18
import java.net.URISyntaxException;
19

  
20
import org.apache.log4j.Logger;
21
import org.junit.After;
22
import org.junit.AfterClass;
23
import org.junit.Before;
24
import org.junit.BeforeClass;
25
import org.junit.Test;
26

  
27
import eu.etaxonomy.cdm.model.agent.Person;
28
import eu.etaxonomy.cdm.model.name.BotanicalName;
29
import eu.etaxonomy.cdm.model.name.Rank;
30
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
31
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
32

  
33
/**
34
 * @author a.mueller
35
 *
36
 */
37
public class AnnotationTest extends EntityTestBase {
38
	
39
	@SuppressWarnings("unused")
40
	private static final Logger logger = Logger.getLogger(AnnotationTest.class);
41

  
42
	private static final String TEST_URI_STR = "http://test.abc.de";
43
	
44
	private static Annotation annotation1;
45
	private static Person commentator;
46
	private static URI linkbackUri;
47
	private static AnnotatableEntity annotatedObject;
48

  
49

  
50
	/**
51
	 * @throws java.lang.Exception
52
	 */
53
	@BeforeClass
54
	public static void setUpBeforeClass() throws Exception {
55
	}
56

  
57
	/**
58
	 * @throws java.lang.Exception
59
	 */
60
	@AfterClass
61
	public static void tearDownAfterClass() throws Exception {
62
	}
63

  
64
	/**
65
	 * @throws java.lang.Exception
66
	 */
67
	@Before
68
	public void setUp() throws Exception {
69
		commentator = Person.NewInstance();
70
		commentator.setTitleCache("automatic importer", true);
71
		annotation1 = Annotation.NewInstance("anno1", Language.DEFAULT());
72
		annotation1.setCommentator(commentator);
73
		annotatedObject = BotanicalName.NewInstance(Rank.SPECIES());
74
		annotatedObject.addAnnotation(annotation1);
75
		linkbackUri = new URI("http://www.abc.de");
76
        annotation1.setLinkbackUri(linkbackUri);
77
	}
78

  
79
	/**
80
	 * @throws java.lang.Exception
81
	 */
82
	@After
83
	public void tearDown() throws Exception {
84
	}
85

  
86
/* ****************** TESTS *************************************/
87

  
88
	/**
89
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#Annotation(java.lang.String, eu.etaxonomy.cdm.model.common.Language)}.
90
	 */
91
	@Test
92
	public void testNewInstanceStringLanguage() {
93
		assertNotNull(annotation1);
94
		assertSame(commentator, annotation1.getCommentator());
95
		assertSame(Language.DEFAULT(), annotation1.getLanguage());
96
		assertSame(linkbackUri, annotation1.getLinkbackUri());
97
		assertSame(annotatedObject.getAnnotations().iterator().next(), annotation1);
98
	}
99

  
100
	/**
101
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#getAnnotatedObj()}.
102
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#setAnnotatedObj(eu.etaxonomy.cdm.model.common.AnnotatableEntity)}.
103
	 */
104
	@Test
105
	public void testGetSetAnnotatedObj() {
106
		AnnotatableEntity database = ReferenceFactory.newDatabase();
107
		annotation1.setAnnotatedObj(database);
108
		assertSame(database, annotation1.getAnnotatedObj());
109
		annotation1.setAnnotatedObj(null);
110
		assertNull(annotation1.getAnnotatedObj());
111
	}
112

  
113

  
114
	/**
115
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#getCommentator()}.
116
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#setCommentator(eu.etaxonomy.cdm.model.agent.Person)}.
117
	 */
118
	@Test
119
	public void testGetSetCommentator() {
120
		Person person = Person.NewInstance();
121
		annotation1.setCommentator(person);
122
		assertSame(person, annotation1.getCommentator());
123
		annotation1.setCommentator(null);
124
		assertNull(annotation1.getCommentator());
125
	}
126

  
127
	/**
128
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#getLinkbackUri()}.
129
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Annotation#setLinkbackUri(URI))}.
130
	 */
131
	@Test
132
	public void testGetSetLinkbackUri() {
133
		URI uri = null;
134
		try {
135
			uri = new URI(TEST_URI_STR);
136
		} catch (URISyntaxException e) {
137
		    fail();
138
        }
139
		annotation1.setLinkbackUri(uri);
140
		assertSame(uri, annotation1.getLinkbackUri());
141
		annotation1.setLinkbackUri(null);
142
		assertNull(annotation1.getLinkbackUri());
143
	}
144

  
145
}
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

  
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.URI;
18
import java.net.URISyntaxException;
19

  
20
import org.apache.log4j.Logger;
21
import org.junit.After;
22
import org.junit.AfterClass;
23
import org.junit.Before;
24
import org.junit.BeforeClass;
25
import org.junit.Test;
26

  
27
import eu.etaxonomy.cdm.model.agent.Person;
28
import eu.etaxonomy.cdm.model.name.BotanicalName;
29
import eu.etaxonomy.cdm.model.name.Rank;
30
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
		annotatedObject = BotanicalName.NewInstance(Rank.SPECIES());
73
		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
}

Also available in: Unified diff