2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.vaadin
.model
;
11 import java
.util
.ArrayList
;
12 import java
.util
.HashSet
;
13 import java
.util
.List
;
16 import org
.junit
.Assert
;
17 import org
.junit
.Test
;
19 import eu
.etaxonomy
.cdm
.api
.service
.dto
.RegistrationDTO
;
20 import eu
.etaxonomy
.cdm
.api
.service
.dto
.RegistrationWorkingSet
;
21 import eu
.etaxonomy
.cdm
.api
.service
.exception
.RegistrationValidationException
;
22 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
23 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
24 import eu
.etaxonomy
.cdm
.model
.name
.Registration
;
25 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
26 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
27 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
28 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
29 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
30 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
31 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
34 * @author a.kohlbecker
38 public class RegistrationWorkingSetTest
{
41 public void test_2_names() throws RegistrationValidationException
{
43 Reference article
= ReferenceFactory
.newArticle();
44 article
.setTitleCache("Article", true);
47 Reference section
= ReferenceFactory
.newSection();
48 section
.setTitleCache("Section", true);
49 section
.setInReference(article
);
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);
57 List
<RegistrationDTO
> dtos
= new ArrayList
<>();
58 dtos
.add(new RegistrationDTO(reg1
));
59 dtos
.add(new RegistrationDTO(reg2
));
61 RegistrationWorkingSet ws
= new RegistrationWorkingSet(dtos
);
62 Assert
.assertEquals(article
.getUuid(), ws
.getCitationUuid());
63 Assert
.assertEquals(2, ws
.getRegistrations().size());
68 public void test_name_and_type() throws RegistrationValidationException
{
70 Reference article
= ReferenceFactory
.newArticle();
71 article
.setTitleCache("Article", true);
74 Reference section
= ReferenceFactory
.newSection();
75 section
.setTitleCache("Section", true);
76 section
.setInReference(article
);
79 Reference olderArticle
= ReferenceFactory
.newArticle();
80 olderArticle
.setTitleCache("Older article", true);
81 olderArticle
.setId(1);
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);
94 List
<RegistrationDTO
> dtos
= new ArrayList
<>();
95 dtos
.add(new RegistrationDTO(reg1
));
96 dtos
.add(new RegistrationDTO(reg2
));
98 RegistrationWorkingSet ws
= new RegistrationWorkingSet(dtos
);
99 Assert
.assertEquals(article
.getUuid(), ws
.getCitationUuid());
100 Assert
.assertEquals(2, ws
.getRegistrations().size());