1
|
/**
|
2
|
* Copyright (C) 2018 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 org.junit.Assert;
|
12
|
import org.junit.Before;
|
13
|
import org.junit.Test;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.common.Language;
|
16
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
17
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
18
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
19
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
20
|
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer;
|
21
|
|
22
|
/**
|
23
|
* @author a.mueller
|
24
|
* @since 18.04.2018
|
25
|
*
|
26
|
*/
|
27
|
public class TypeDesignationBaseTest {
|
28
|
|
29
|
/**
|
30
|
* @throws java.lang.Exception
|
31
|
*/
|
32
|
@Before
|
33
|
public void setUp() throws Exception {
|
34
|
if (Language.DEFAULT() == null){
|
35
|
new DefaultTermInitializer().initialize();
|
36
|
}
|
37
|
}
|
38
|
|
39
|
/**
|
40
|
* Test method for {@link TypeDesignationStatusBase#clone()}.
|
41
|
*/
|
42
|
@SuppressWarnings("cast")
|
43
|
@Test
|
44
|
public void testClone(){
|
45
|
DerivedUnit specimen = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
|
46
|
TaxonName name1 = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
47
|
SpecimenTypeDesignationStatus status = SpecimenTypeDesignationStatus.HOLOTYPE();
|
48
|
Reference citation = ReferenceFactory.newBook();
|
49
|
String microCitation = "p. 123";
|
50
|
String originalNameString = "orig. name";
|
51
|
boolean isNotDesignated = true;
|
52
|
SpecimenTypeDesignation originalDesignation = name1.addSpecimenTypeDesignation(specimen, status,
|
53
|
citation, microCitation, originalNameString, isNotDesignated, false);
|
54
|
Registration registration1 = Registration.NewInstance();
|
55
|
registration1.addTypeDesignation(originalDesignation);
|
56
|
|
57
|
//pre assert
|
58
|
Assert.assertTrue(originalDesignation instanceof TypeDesignationBase);
|
59
|
Assert.assertEquals(1, name1.getTypeDesignations().size());
|
60
|
Assert.assertTrue(name1.getTypeDesignations().contains(originalDesignation));
|
61
|
Assert.assertTrue(originalDesignation.getRegistrations().contains(registration1));
|
62
|
Assert.assertNotNull(status);
|
63
|
|
64
|
//clone
|
65
|
SpecimenTypeDesignation clonedDesignation = (SpecimenTypeDesignation)originalDesignation.clone();
|
66
|
|
67
|
//post assert
|
68
|
Assert.assertEquals(2, name1.getTypeDesignations().size());
|
69
|
Assert.assertTrue(name1.getTypeDesignations().contains(clonedDesignation));
|
70
|
Assert.assertTrue(clonedDesignation.getTypifiedNames().contains(name1));
|
71
|
Assert.assertEquals(2, registration1.getTypeDesignations().size());
|
72
|
Assert.assertTrue(registration1.getTypeDesignations().contains(clonedDesignation));
|
73
|
Assert.assertTrue(clonedDesignation.getRegistrations().contains(registration1));
|
74
|
|
75
|
Assert.assertSame(citation, clonedDesignation.getCitation());
|
76
|
Assert.assertSame(status, clonedDesignation.getTypeStatus());
|
77
|
|
78
|
}
|
79
|
}
|