Project

General

Profile

Download (3.37 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 org.apache.log4j.Logger;
13
import org.junit.Before;
14
import org.junit.Test;
15

    
16
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
17
import eu.etaxonomy.cdm.model.name.BotanicalName;
18
import eu.etaxonomy.cdm.model.name.Rank;
19
import eu.etaxonomy.cdm.model.name.ZoologicalName;
20
import eu.etaxonomy.cdm.model.reference.Reference;
21
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
22
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
23
import eu.etaxonomy.cdm.validation.constraint.ValidTaxonomicYearValidator;
24

    
25

    
26

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

    
41
    static Class validatorClass = ValidTaxonomicYearValidator.class;
42
    static Class group = Level3.class;
43

    
44

    
45
	private BotanicalName name;
46

    
47
	private Reference beforeLineeRef;
48
    private Reference afterLineeRef;
49

    
50

    
51
	@Before
52
	public void setUp() {
53
		DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
54
		vocabularyStore.initialize();
55

    
56
		name = BotanicalName.NewInstance(Rank.SPECIES());
57
		name.setNameCache("Aus aus");
58
		name.setAuthorshipCache("L.");
59
		name.setFullTitleCache("Aus aus L.");
60
		name.setTitleCache("Aus aus L.", true);
61

    
62
		beforeLineeRef = ReferenceFactory.newBook();
63
		beforeLineeRef.setDatePublished(TimePeriodParser.parseString("1752"));
64

    
65
	    afterLineeRef = ReferenceFactory.newBook();
66
	    afterLineeRef.setDatePublished(TimePeriodParser.parseString("1754"));
67

    
68
	}
69

    
70

    
71
/****************** TESTS *****************************/
72

    
73
	@Test
74
	public void testNotBeforeLinee() {
75
        name.setNomenclaturalReference(beforeLineeRef);
76
        validateHasConstraint(name, validatorClass, group);
77
	}
78

    
79
	@Test
80
    public void testAfterLinee() {
81
        name.setNomenclaturalReference(afterLineeRef);
82
        validateHasNoConstraint(name, validatorClass, group);
83
    }
84

    
85
    @Test
86
    public void testNoNomRef() {
87
        name.setNomenclaturalReference(null);
88
        validateHasNoConstraint(name, validatorClass, group);
89
    }
90

    
91
    @Test
92
    public void testZooName() {
93

    
94
        ZoologicalName zooName = ZoologicalName.NewInstance(Rank.SPECIES());
95

    
96
        zooName.setNomenclaturalReference(null);
97
        zooName.setPublicationYear(1788);
98
        validateHasNoConstraint(zooName, validatorClass, group);
99

    
100
        zooName.setPublicationYear(1730);
101
        //currently we do not use the publication year for zooName.getYear, but this may change in future.
102
        //we may adapt this test then
103
        validateHasNoConstraint(zooName, validatorClass, group);
104

    
105
        zooName.setNomenclaturalReference(beforeLineeRef);
106
        validateHasConstraint(zooName, validatorClass, group);
107

    
108

    
109
    }
110

    
111

    
112
}
(8-8/10)