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.NameTypeDesignation;
|
19
|
import eu.etaxonomy.cdm.model.name.Rank;
|
20
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
21
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
22
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
23
|
import eu.etaxonomy.cdm.validation.constraint.TypeDesignationValidator;
|
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 a.mueller
|
34
|
*
|
35
|
*
|
36
|
*/
|
37
|
public class ValidTypeDesignationTest extends ValidationTestBase {
|
38
|
@SuppressWarnings("unused")
|
39
|
private static final Logger logger = Logger.getLogger(ValidTypeDesignationTest.class);
|
40
|
|
41
|
static Class validatorClass = TypeDesignationValidator.class;
|
42
|
static Class group = Level2.class;
|
43
|
|
44
|
private NameTypeDesignation nameDesignation;
|
45
|
private SpecimenTypeDesignation specimenDesignation;
|
46
|
private BotanicalName name1;
|
47
|
private BotanicalName name2;
|
48
|
private DerivedUnit specimen;
|
49
|
|
50
|
|
51
|
@Before
|
52
|
public void setUp() {
|
53
|
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
|
54
|
vocabularyStore.initialize();
|
55
|
|
56
|
|
57
|
|
58
|
name1 = BotanicalName.NewInstance(Rank.SPECIES());
|
59
|
name1.setNameCache("Aus aus");
|
60
|
|
61
|
name2 = BotanicalName.NewInstance(Rank.SPECIES());
|
62
|
name2.setNameCache("Aus bus");
|
63
|
|
64
|
specimen = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
|
65
|
|
66
|
|
67
|
}
|
68
|
|
69
|
|
70
|
/****************** TESTS *****************************/
|
71
|
|
72
|
@Test
|
73
|
public void testNameTypeDesignations() {
|
74
|
nameDesignation = NameTypeDesignation.NewInstance();
|
75
|
validateHasConstraint(nameDesignation, validatorClass, group);
|
76
|
|
77
|
name1.addTypeDesignation(nameDesignation, false);
|
78
|
nameDesignation.setTypeName(name2);
|
79
|
validateHasNoConstraint(nameDesignation, validatorClass, group);
|
80
|
|
81
|
nameDesignation.setTypeName(null);
|
82
|
validateHasConstraint(nameDesignation, validatorClass, group);
|
83
|
|
84
|
nameDesignation.setNotDesignated(true);
|
85
|
validateHasNoConstraint(nameDesignation, validatorClass, group);
|
86
|
|
87
|
}
|
88
|
|
89
|
@Test
|
90
|
public void testSpecimenTypeDesignations() {
|
91
|
specimenDesignation = SpecimenTypeDesignation.NewInstance();
|
92
|
validateHasConstraint(specimenDesignation, validatorClass, group);
|
93
|
|
94
|
name1.addTypeDesignation(specimenDesignation, false);
|
95
|
specimenDesignation.setTypeSpecimen(specimen);
|
96
|
validateHasNoConstraint(specimenDesignation, validatorClass, group);
|
97
|
|
98
|
specimenDesignation.setTypeSpecimen(null);
|
99
|
validateHasConstraint(specimenDesignation, validatorClass, group);
|
100
|
|
101
|
specimenDesignation.setNotDesignated(true);
|
102
|
validateHasNoConstraint(specimenDesignation, validatorClass, group);
|
103
|
|
104
|
}
|
105
|
|
106
|
}
|