Project

General

Profile

« Previous | Next » 

Revision 0ecfd682

Added by Andreas Müller over 8 years ago

Remove bidirectionality for supplemental data #5743

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/MarkerTest.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.*;
13

  
14
import org.apache.log4j.Logger;
15
import org.junit.After;
16
import org.junit.AfterClass;
17
import org.junit.Before;
18
import org.junit.BeforeClass;
19
import org.junit.Test;
20

  
21
import eu.etaxonomy.cdm.model.name.BotanicalName;
22
import eu.etaxonomy.cdm.model.name.Rank;
23
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
24

  
25
/**
26
 * @author a.mueller
27
 * @created 22.04.2008
28
 * @version 1.0
29
 */
30
public class MarkerTest extends EntityTestBase {
31
	@SuppressWarnings("unused")
32
	private static Logger logger = Logger.getLogger(MarkerTest.class);
33

  
34
	private static boolean flag1;
35
	private static Marker marker1;
36
	private static MarkerType markerType1;
37
	private static AnnotatableEntity annotatedObject1;
38
	private static AnnotatableEntity annotatedObject2;
39

  
40
	/**
41
	 * @throws java.lang.Exception
42
	 */
43
	@BeforeClass
44
	public static void setUpBeforeClass() throws Exception {
45
	}
46

  
47
	/**
48
	 * @throws java.lang.Exception
49
	 */
50
	@AfterClass
51
	public static void tearDownAfterClass() throws Exception {
52
	}
53

  
54
	/**
55
	 * @throws java.lang.Exception
56
	 */
57
	@Before
58
	public void setUp() throws Exception {
59
		flag1 = true;
60
		markerType1 = MarkerType.TO_BE_CHECKED();
61
		marker1 = Marker.NewInstance(markerType1 ,  flag1);
62
		annotatedObject1 = BotanicalName.NewInstance(Rank.SPECIES());
63
		annotatedObject1.addMarker(marker1);
64
		annotatedObject2 = BotanicalName.NewInstance(Rank.GENUS());
65
	}
66

  
67
	/**
68
	 * @throws java.lang.Exception
69
	 */
70
	@After
71
	public void tearDown() throws Exception {
72
	}
73
	
74
	
75
/* *************** TESTS ********************************************/
76

  
77
	/**
78
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#NewInstance(eu.etaxonomy.cdm.model.common.MarkerType, boolean)}.
79
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#Marker(eu.etaxonomy.cdm.model.common.MarkerType, boolean)}.
80
	 */
81
	@Test
82
	public void testNewInstance() {
83
		assertNotNull(marker1);
84
		assertSame(annotatedObject1, marker1.getMarkedObj());
85
		assertEquals(flag1, marker1.getFlag());
86
		assertSame(markerType1, marker1.getMarkerType());
87
		assertSame(1, annotatedObject1.getMarkers().size());
88
		assertSame(annotatedObject1.getMarkers().toArray()[0], marker1);
89
	}
90

  
91
	/**
92
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#getMarkedObj()}.
93
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#setMarkedObj(eu.etaxonomy.cdm.model.common.AnnotatableEntity)}.
94
	 */
95
	@Test
96
	public void testGetSetMarkedObj() {
97
		marker1.setMarkedObj(annotatedObject2);
98
		assertSame(annotatedObject2, marker1.getMarkedObj());
99
		marker1.setMarkedObj(null);
100
		assertNull(marker1.getMarkedObj());
101
	}
102

  
103
	/**
104
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#getType()}.
105
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#setType(eu.etaxonomy.cdm.model.common.MarkerType)}.
106
	 */
107
	@Test
108
	public void testGetSetType() {
109
		marker1.setMarkerType(MarkerType.IS_DOUBTFUL());
110
		assertSame(MarkerType.IS_DOUBTFUL(), marker1.getMarkerType());
111
		marker1.setMarkerType(null);
112
		assertNull(marker1.getMarkerType());
113
	}
114

  
115
	/**
116
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#getFlag()}.
117
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#setFlag(boolean)}.
118
	 */
119
	@Test
120
	public void testGetSetFlag() {
121
		marker1.setFlag(true);
122
		assertTrue(marker1.getFlag());
123
		marker1.setFlag(false);
124
		assertFalse(marker1.getFlag());
125
	}
126

  
127
}
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.assertEquals;
13
import static org.junit.Assert.assertFalse;
14
import static org.junit.Assert.assertNotNull;
15
import static org.junit.Assert.assertNull;
16
import static org.junit.Assert.assertSame;
17
import static org.junit.Assert.assertTrue;
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
import eu.etaxonomy.cdm.model.name.BotanicalName;
27
import eu.etaxonomy.cdm.model.name.Rank;
28
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
29

  
30
/**
31
 * @author a.mueller
32
 * @created 22.04.2008
33
 * @version 1.0
34
 */
35
public class MarkerTest extends EntityTestBase {
36
	@SuppressWarnings("unused")
37
	private static Logger logger = Logger.getLogger(MarkerTest.class);
38

  
39
	private static boolean flag1;
40
	private static Marker marker1;
41
	private static MarkerType markerType1;
42
	private static AnnotatableEntity annotatedObject1;
43

  
44
	/**
45
	 * @throws java.lang.Exception
46
	 */
47
	@BeforeClass
48
	public static void setUpBeforeClass() throws Exception {
49
	}
50

  
51
	/**
52
	 * @throws java.lang.Exception
53
	 */
54
	@AfterClass
55
	public static void tearDownAfterClass() throws Exception {
56
	}
57

  
58
	/**
59
	 * @throws java.lang.Exception
60
	 */
61
	@Before
62
	public void setUp() throws Exception {
63
		flag1 = true;
64
		markerType1 = MarkerType.TO_BE_CHECKED();
65
		marker1 = Marker.NewInstance(markerType1 ,  flag1);
66
		annotatedObject1 = BotanicalName.NewInstance(Rank.SPECIES());
67
		annotatedObject1.addMarker(marker1);
68
	}
69

  
70
	/**
71
	 * @throws java.lang.Exception
72
	 */
73
	@After
74
	public void tearDown() throws Exception {
75
	}
76

  
77

  
78
/* *************** TESTS ********************************************/
79

  
80
	/**
81
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#NewInstance(eu.etaxonomy.cdm.model.common.MarkerType, boolean)}.
82
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#Marker(eu.etaxonomy.cdm.model.common.MarkerType, boolean)}.
83
	 */
84
	@Test
85
	public void testNewInstance() {
86
		assertNotNull(marker1);
87
		assertEquals(flag1, marker1.getFlag());
88
		assertSame(markerType1, marker1.getMarkerType());
89
		assertSame(1, annotatedObject1.getMarkers().size());
90
		assertSame(annotatedObject1.getMarkers().toArray()[0], marker1);
91
	}
92

  
93
	/**
94
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#getType()}.
95
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#setType(eu.etaxonomy.cdm.model.common.MarkerType)}.
96
	 */
97
	@Test
98
	public void testGetSetType() {
99
		marker1.setMarkerType(MarkerType.IS_DOUBTFUL());
100
		assertSame(MarkerType.IS_DOUBTFUL(), marker1.getMarkerType());
101
		marker1.setMarkerType(null);
102
		assertNull(marker1.getMarkerType());
103
	}
104

  
105
	/**
106
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#getFlag()}.
107
	 * Test method for {@link eu.etaxonomy.cdm.model.common.Marker#setFlag(boolean)}.
108
	 */
109
	@Test
110
	public void testGetSetFlag() {
111
		marker1.setFlag(true);
112
		assertTrue(marker1.getFlag());
113
		marker1.setFlag(false);
114
		assertFalse(marker1.getFlag());
115
	}
116

  
117
}

Also available in: Unified diff