Project

General

Profile

Download (3.27 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

    
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.logging.log4j.LogManager;import org.apache.logging.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.Rank;
27
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
28
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
29

    
30
/**
31
 * @author a.mueller
32
 * @since 22.04.2008
33
 * @version 1.0
34
 */
35
public class MarkerTest extends EntityTestBase {
36
	@SuppressWarnings("unused")
37
	private static Logger logger = LogManager.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 = TaxonNameFactory.NewBotanicalInstance(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
}
(8-8/12)