Project

General

Profile

Download (3.31 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
package eu.etaxonomy.cdm.validation;
10

    
11
import org.apache.log4j.Logger;
12
import org.junit.Before;
13
import org.junit.Test;
14

    
15
import eu.etaxonomy.cdm.model.name.IBotanicalName;
16
import eu.etaxonomy.cdm.model.name.IZoologicalName;
17
import eu.etaxonomy.cdm.model.name.Rank;
18
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
19
import eu.etaxonomy.cdm.model.reference.Reference;
20
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
21
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
22
import eu.etaxonomy.cdm.validation.constraint.ValidTaxonomicYearValidator;
23

    
24
/**
25
 * NOTE: In this test, the words "valid" and "invalid", loaded though
26
 * these terms are when applied to taxonomic names, only mean "passes the
27
 * rules of this validator" or not and should not be confused with the strict
28
 * nomenclatural and taxonomic sense of these words.
29
 *
30
 * @author ben.clark
31
 */
32
public class ValidTaxonomicYearTest extends ValidationTestBase {
33
	@SuppressWarnings("unused")
34
    private static final Logger logger = Logger.getLogger(ValidTaxonomicYearTest.class);
35

    
36
    static Class<ValidTaxonomicYearValidator> validatorClass = ValidTaxonomicYearValidator.class;
37
    static Class<Level3> group = Level3.class;
38

    
39
	private IBotanicalName name;
40

    
41
	private Reference beforeLineeRef;
42
    private Reference afterLineeRef;
43

    
44
	@Before
45
	public void setUp() {
46

    
47
		name = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
48
		name.setNameCache("Aus aus");
49
		name.setAuthorshipCache("L.");
50
		name.setFullTitleCache("Aus aus L.");
51
		name.setTitleCache("Aus aus L.", true);
52

    
53
		beforeLineeRef = ReferenceFactory.newBook();
54
		beforeLineeRef.setDatePublished(TimePeriodParser.parseStringVerbatim("1752"));
55

    
56
	    afterLineeRef = ReferenceFactory.newBook();
57
	    afterLineeRef.setDatePublished(TimePeriodParser.parseStringVerbatim("1754"));
58
	}
59

    
60
/****************** TESTS *****************************/
61

    
62
	@Test
63
	public void testNotBeforeLinee() {
64
        name.setNomenclaturalReference(beforeLineeRef);
65
        validateHasConstraint(name, validatorClass, group);
66
	}
67

    
68
	@Test
69
    public void testAfterLinee() {
70
        name.setNomenclaturalReference(afterLineeRef);
71
        validateHasNoConstraint(name, validatorClass, group);
72
    }
73

    
74
    @Test
75
    public void testNoNomRef() {
76
        name.setNomenclaturalReference(null);
77
        validateHasNoConstraint(name, validatorClass, group);
78
    }
79

    
80
    @Test
81
    public void testZooName() {
82

    
83
        IZoologicalName zooName = TaxonNameFactory.NewZoologicalInstance(Rank.SPECIES());
84

    
85
        zooName.setNomenclaturalReference(null);
86
        zooName.setPublicationYear(1788);
87
        validateHasNoConstraint(zooName, validatorClass, group);
88

    
89
        zooName.setPublicationYear(1730);
90
        //currently we do not use the publication year for zooName.getYear, but this may change in future.
91
        //we may adapt this test then
92
        validateHasNoConstraint(zooName, validatorClass, group);
93

    
94
        zooName.setNomenclaturalReference(beforeLineeRef);
95
        validateHasConstraint(zooName, validatorClass, group);
96
    }
97
}
(11-11/13)