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.vaadin.model;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.HashSet;
|
13
|
import java.util.List;
|
14
|
import java.util.Set;
|
15
|
|
16
|
import org.junit.Assert;
|
17
|
import org.junit.Test;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
20
|
import eu.etaxonomy.cdm.model.name.Rank;
|
21
|
import eu.etaxonomy.cdm.model.name.Registration;
|
22
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
23
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
24
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
25
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
26
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
27
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
28
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
29
|
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
|
30
|
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO;
|
31
|
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationValidationException;
|
32
|
|
33
|
/**
|
34
|
* @author a.kohlbecker
|
35
|
* @since Jan 11, 2018
|
36
|
*
|
37
|
*/
|
38
|
public class RegistrationWorkingSetTest {
|
39
|
|
40
|
@Test
|
41
|
public void test_2_names() throws RegistrationValidationException {
|
42
|
|
43
|
Reference article = ReferenceFactory.newArticle();
|
44
|
article.setTitleCache("Article", true);
|
45
|
article.setId(1);
|
46
|
|
47
|
Reference section = ReferenceFactory.newSection();
|
48
|
section.setTitleCache("Section", true);
|
49
|
section.setInReference(article);
|
50
|
section.setId(2);
|
51
|
|
52
|
TaxonName name1 = TaxonName.NewInstance(NomenclaturalCode.ICNAFP, Rank.SPECIES(), "Amphora", null, "exemplaris", null, null, article, null, null);
|
53
|
TaxonName name2 = TaxonName.NewInstance(NomenclaturalCode.ICNAFP, Rank.SPECIES(), "Amphora", null, "nonsensis", null, null, section, null, null);
|
54
|
Registration reg1 = Registration.NewInstance("http://phycobank/0001", "0001", name1, null);
|
55
|
Registration reg2 = Registration.NewInstance("http://phycobank/0002", "0002", name2, null);
|
56
|
|
57
|
List<RegistrationDTO> dtos = new ArrayList<>();
|
58
|
dtos.add(new RegistrationDTO(reg1));
|
59
|
dtos.add(new RegistrationDTO(reg2));
|
60
|
|
61
|
RegistrationWorkingSet ws = new RegistrationWorkingSet(dtos);
|
62
|
Assert.assertEquals(article.getUuid(), ws.getCitationUuid());
|
63
|
Assert.assertEquals(2, ws.getRegistrations().size());
|
64
|
}
|
65
|
|
66
|
|
67
|
@Test
|
68
|
public void test_name_and_type() throws RegistrationValidationException {
|
69
|
|
70
|
Reference article = ReferenceFactory.newArticle();
|
71
|
article.setTitleCache("Article", true);
|
72
|
article.setId(1);
|
73
|
|
74
|
Reference section = ReferenceFactory.newSection();
|
75
|
section.setTitleCache("Section", true);
|
76
|
section.setInReference(article);
|
77
|
section.setId(2);
|
78
|
|
79
|
Reference olderArticle = ReferenceFactory.newArticle();
|
80
|
olderArticle.setTitleCache("Older article", true);
|
81
|
olderArticle.setId(1);
|
82
|
|
83
|
TaxonName name1 = TaxonName.NewInstance(NomenclaturalCode.ICNAFP, Rank.SPECIES(), "Amphora", null, "exemplaris", null, null, olderArticle, null, null);
|
84
|
SpecimenTypeDesignation std = SpecimenTypeDesignation.NewInstance();
|
85
|
std.setCitation(article);
|
86
|
std.setTypeSpecimen(DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen));
|
87
|
Set<TypeDesignationBase> typeDesignations = new HashSet<>();
|
88
|
name1.addTypeDesignation(std, false);
|
89
|
typeDesignations.add(std);
|
90
|
TaxonName name2 = TaxonName.NewInstance(NomenclaturalCode.ICNAFP, Rank.SPECIES(), "Amphora", null, "nonsensis", null, null, section, null, null);
|
91
|
Registration reg1 = Registration.NewInstance("http://phycobank/0001", "0001", null, typeDesignations);
|
92
|
Registration reg2 = Registration.NewInstance("http://phycobank/0002", "0002", name2, null);
|
93
|
|
94
|
List<RegistrationDTO> dtos = new ArrayList<>();
|
95
|
dtos.add(new RegistrationDTO(reg1));
|
96
|
dtos.add(new RegistrationDTO(reg2));
|
97
|
|
98
|
RegistrationWorkingSet ws = new RegistrationWorkingSet(dtos);
|
99
|
Assert.assertEquals(article.getUuid(), ws.getCitationUuid());
|
100
|
Assert.assertEquals(2, ws.getRegistrations().size());
|
101
|
}
|
102
|
|
103
|
}
|