Project

General

Profile

Download (2.65 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.name;
10

    
11
import static org.junit.Assert.assertEquals;
12
import static org.junit.Assert.assertNotNull;
13
import static org.junit.Assert.assertTrue;
14

    
15
import java.util.Set;
16

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

    
22
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
23
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
24

    
25
/**
26
 * @author a.babadshanjan
27
 * @since 19.05.2009
28
 */
29
public class SpecimenTypeDesignationTest extends EntityTestBase {
30

    
31
	@SuppressWarnings("unused")
32
	private static final Logger logger = LogManager.getLogger(SpecimenTypeDesignationTest.class);
33

    
34
	private SpecimenTypeDesignation term1 = null;
35
	private SpecimenTypeDesignation term2 = null;
36

    
37
	@Before
38
	public void setUp() {
39
		term1 = new SpecimenTypeDesignation();
40
		term2 = new SpecimenTypeDesignation(DerivedUnit.NewPreservedSpecimenInstance(),
41
				SpecimenTypeDesignationStatus.ISOTYPE(), null, null, null, false);
42
	}
43

    
44
	@Test
45
	public void testSpecimenTypeDesignation() {
46
		assertNotNull(term1);
47
		assertNotNull(term2);
48
	}
49

    
50
	@Test
51
	public void testGetTypeStatus() {
52
		SpecimenTypeDesignationStatus std = term1.getTypeStatus();
53
		std = term2.getTypeStatus();
54
		term1.setTypeStatus(SpecimenTypeDesignationStatus.EPITYPE());
55
		assertEquals(term1.getTypeStatus(), SpecimenTypeDesignationStatus.EPITYPE());
56
		assertTrue(term1.getTypeStatus().isInstanceOf(SpecimenTypeDesignationStatus.class));
57
	}
58

    
59
	@Test
60
	public void testBidirectionalRelationship(){
61
		term2 = new SpecimenTypeDesignation(DerivedUnit.NewPreservedSpecimenInstance(), SpecimenTypeDesignationStatus.ISOTYPE(),
62
				null, null, null, false);
63
		DerivedUnit specimen = term2.getTypeSpecimen();
64
		Set<SpecimenTypeDesignation> set = specimen.getSpecimenTypeDesignations();
65
		boolean contains = false;
66
		for (SpecimenTypeDesignation spec: set){
67
			if (spec.equals(term2)){
68
				contains = true;
69
				break;
70
			}
71
		}
72
		assertTrue(contains);
73
	}
74

    
75
    @Test
76
    public void beanTests(){
77
//      #5307 Test that BeanUtils does not fail
78
        BeanUtils.getPropertyDescriptors(SpecimenTypeDesignation.class);
79
        BeanUtils.getPropertyDescriptors(NameTypeDesignation.class);
80
        BeanUtils.getPropertyDescriptors(HomotypicalGroup.class);
81
        BeanUtils.getPropertyDescriptors(NomenclaturalStatusType.class);
82
        BeanUtils.getPropertyDescriptors(Rank.class);
83
    }
84
}
(13-13/17)