Project

General

Profile

Download (3.54 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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.validation;
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.assertTrue;
16

    
17
import java.util.Set;
18
import java.util.UUID;
19

    
20
import javax.validation.ConstraintViolation;
21
import javax.validation.Validator;
22
import javax.validation.groups.Default;
23

    
24
import junit.framework.Assert;
25

    
26
import org.apache.log4j.Logger;
27
import org.junit.Before;
28
import org.junit.Ignore;
29
import org.junit.Test;
30

    
31
import org.unitils.spring.annotation.SpringBeanByType;
32

    
33
import eu.etaxonomy.cdm.model.agent.Person;
34
import eu.etaxonomy.cdm.model.name.BotanicalName;
35
import eu.etaxonomy.cdm.model.name.Rank;
36

    
37
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
38

    
39
/**
40
 * NOTE: In this test, the words "valid" and "invalid", loaded though 
41
 * these terms are when applied to taxonomic names, only mean "passes the
42
 * rules of this validator" or not and should not be confused with the strict
43
 * nomenclatural and taxonomic sense of these words.
44
 * 
45
 * @author ben.clark
46
 *
47
 */
48
@Ignore //FIXME ignoring only for merging 8.6.2010 a.kohlbecker
49
public class MustHaveAuthorityTest extends CdmIntegrationTest {
50
	private static final Logger logger = Logger.getLogger(MustHaveAuthorityTest.class);
51
	
52
	@SpringBeanByType
53
	private Validator validator;
54
	
55
	private BotanicalName name;
56
	
57
	@Before
58
	public void setUp() {
59
		name = BotanicalName.NewInstance(Rank.SPECIES());
60
		name.setNameCache("Aus aus");
61
		name.setGenusOrUninomial("Aus");
62
		name.setSpecificEpithet("aus");
63
		name.setAuthorshipCache("L.");
64
		name.setFullTitleCache("Aus aus L.");
65
		name.setTitleCache("Aus aus L.", true);
66
	}
67
	
68
	
69
/****************** TESTS *****************************/
70
	
71
	@Test
72
	public void testValidSpecificName() {
73
        Set<ConstraintViolation<BotanicalName>> constraintViolations  = validator.validate(name, Level2.class);
74
        assertTrue("There should be no constraint violations as this name has the correct epithets for it rank",constraintViolations.isEmpty());
75
	}
76
	
77
	@Test
78
	public void testValidSpecificNameWithBasionymAuthorTeam() {
79
		name.setAuthorshipCache(null);
80
		name.setBasionymAuthorTeam(Person.NewInstance());
81
        Set<ConstraintViolation<BotanicalName>> constraintViolations  = validator.validate(name, Level2.class);
82
        assertTrue("There should be no constraint violations as this name has the correct epithets for it rank",constraintViolations.isEmpty());
83
	}
84
	
85
	@Test
86
	public void testInValidSpecificName() {
87
		name.setAuthorshipCache(null);
88
        Set<ConstraintViolation<BotanicalName>> constraintViolations  = validator.validate(name, Level2.class);
89
        assertFalse("There should be a constraint violation as this name does not have a specific epithet",constraintViolations.isEmpty());
90
	}
91
	
92
	@Test
93
	public void testValidAutonym() {
94
		name.setInfraSpecificEpithet("aus");
95
		name.setAuthorshipCache(null);
96
		name.setBasionymAuthorTeam(null);
97
		name.setRank(Rank.SUBSPECIES());
98
        Set<ConstraintViolation<BotanicalName>> constraintViolations  = validator.validate(name, Level2.class);
99
        assertTrue("There should be no constraint violations as this name has the correct epithets for it rank",constraintViolations.isEmpty());
100
	}
101
}
(2-2/6)