Project

General

Profile

Revision 9630eead

ID9630eead962674f95964a6d9cb739e64347766d4
Parent 3d526586
Child 6b1127f8

Added by Andreas Kohlbecker over 2 years ago

ref #7608 string representations for media types implemented - tests

View differences:

src/test/java/eu/etaxonomy/cdm/vaadin/util/converter/TypeDesignationSetManagerIT.java
27 27
import eu.etaxonomy.cdm.api.service.exception.RegistrationValidationException;
28 28
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager;
29 29
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSet;
30
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
31
import eu.etaxonomy.cdm.model.media.Media;
30 32
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
31 33
import eu.etaxonomy.cdm.model.name.Rank;
32 34
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
......
38 40
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
39 41
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
40 42
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
43
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
41 44
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
42 45
import eu.etaxonomy.cdm.model.reference.Reference;
43 46
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
44
import eu.etaxonomy.cdm.ref.EntityReference;
45 47
import eu.etaxonomy.cdm.ref.TypedEntityReference;
46 48

  
47 49
/**
......
57 59
    private SpecimenTypeDesignation std_HT;
58 60
    private SpecimenTypeDesignation std_IT_2;
59 61
    private SpecimenTypeDesignation std_IT_3;
62
    private SpecimenTypeDesignation mtd_HT_published;
63
    private SpecimenTypeDesignation mtd_IT_unpublished;
60 64

  
61 65
    @Before
62 66
    public void init(){
......
82 86
        std_HT.setId(1);
83 87
        DerivedUnit specimen_HT = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
84 88
        specimen_HT.setTitleCache("OHA", true);
85
        DerivationEvent derivationEvent_1 = DerivationEvent.NewInstance();
86
        derivationEvent_1.addOriginal(fu_1);
87
        derivationEvent_1.addDerivative(specimen_HT);
89
        createDerivationEvent(fu_1, specimen_HT);
88 90
        specimen_HT.getOriginals().add(fu_1);
89 91
        std_HT.setTypeSpecimen(specimen_HT);
90 92
        std_HT.setTypeStatus(SpecimenTypeDesignationStatus.HOLOTYPE());
......
93 95
        std_IT.setId(2);
94 96
        DerivedUnit specimen_IT = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
95 97
        specimen_IT.setTitleCache("BER", true);
96
        DerivationEvent derivationEvent_2 = DerivationEvent.NewInstance();
97
        derivationEvent_2.addOriginal(fu_1);
98
        derivationEvent_2.addDerivative(specimen_IT);
98
        createDerivationEvent(fu_1, specimen_IT);
99 99
        std_IT.setTypeSpecimen(specimen_IT);
100 100
        std_IT.setTypeStatus(SpecimenTypeDesignationStatus.ISOTYPE());
101 101

  
......
103 103
        std_IT_2.setId(3);
104 104
        DerivedUnit specimen_IT_2 = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
105 105
        specimen_IT_2.setTitleCache("KEW", true);
106
        DerivationEvent derivationEvent_3 = DerivationEvent.NewInstance();
107
        derivationEvent_3.addOriginal(fu_1);
108
        derivationEvent_3.addDerivative(specimen_IT_2);
106
        createDerivationEvent(fu_1, specimen_IT_2);
109 107
        std_IT_2.setTypeSpecimen(specimen_IT_2);
110 108
        std_IT_2.setTypeStatus(SpecimenTypeDesignationStatus.ISOTYPE());
111 109

  
......
113 111
        std_IT_3.setId(4);
114 112
        DerivedUnit specimen_IT_3 = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
115 113
        specimen_IT_3.setTitleCache("M", true);
114
        createDerivationEvent(fu_1, specimen_IT_3);
116 115
        std_IT_3.setTypeSpecimen(specimen_IT_3);
117 116
        std_IT_3.setTypeStatus(SpecimenTypeDesignationStatus.ISOTYPE());
117

  
118
        mtd_HT_published = SpecimenTypeDesignation.NewInstance();
119
        mtd_HT_published.setId(5);
120
        MediaSpecimen mediaSpecimen_published = (MediaSpecimen)DerivedUnit.NewInstance(SpecimenOrObservationType.Media);
121
        Media media = Media.NewInstance();
122
        Reference ref = ReferenceFactory.newGeneric();
123
        ref.setTitleCache("A.K. & W.K (2008) Algae of the BGBM", true);
124
        media.addSource(IdentifiableSource.NewPrimaryMediaSourceInstance(ref, "p.33"));
125
        mediaSpecimen_published.setMediaSpecimen(media);
126
        createDerivationEvent(fu_1, mediaSpecimen_published);
127
        mtd_HT_published.setTypeSpecimen(mediaSpecimen_published);
128
        mtd_HT_published.setTypeStatus(SpecimenTypeDesignationStatus.HOLOTYPE());
129

  
130
        mtd_IT_unpublished = SpecimenTypeDesignation.NewInstance();
131
        mtd_IT_unpublished.setId(6);
132
        MediaSpecimen mediaSpecimen_unpublished = (MediaSpecimen)DerivedUnit.NewInstance(SpecimenOrObservationType.Media);
133
        eu.etaxonomy.cdm.model.occurrence.Collection collection = eu.etaxonomy.cdm.model.occurrence.Collection.NewInstance();
134
        collection.setCode("B");
135
        mediaSpecimen_unpublished.setCollection(collection);
136
        mediaSpecimen_unpublished.setAccessionNumber("Slide A565656");
137
        createDerivationEvent(fu_1, mediaSpecimen_unpublished);
138
        mtd_IT_unpublished.setTypeSpecimen(mediaSpecimen_unpublished);
139
        mtd_IT_unpublished.setTypeStatus(SpecimenTypeDesignationStatus.ISOTYPE());
140

  
141
    }
142

  
143
    /**
144
     * @param fu_1
145
     * @param specimen_IT_2
146
     */
147
    protected void createDerivationEvent(FieldUnit fu_1, DerivedUnit specimen_IT_2) {
148
        DerivationEvent derivationEvent_3 = DerivationEvent.NewInstance();
149
        derivationEvent_3.addOriginal(fu_1);
150
        derivationEvent_3.addDerivative(specimen_IT_2);
118 151
    }
119 152

  
120 153
    @Test
......
148 181

  
149 182
        LinkedHashMap<TypedEntityReference, TypeDesignationWorkingSet> orderedTypeDesignations =
150 183
                typeDesignationManager.getOrderdTypeDesignationWorkingSets();
151
        Map<TypeDesignationStatusBase<?>, Collection<EntityReference>> byStatusMap = orderedTypeDesignations.values().iterator().next();
184
        Map<TypeDesignationStatusBase<?>, Collection<TypedEntityReference>> byStatusMap = orderedTypeDesignations.values().iterator().next();
152 185
        Iterator<TypeDesignationStatusBase<?>> keyIt = byStatusMap.keySet().iterator();
153 186
        assertEquals("Holotype", keyIt.next().getLabel());
154 187
        assertEquals("Isotype", keyIt.next().getLabel());
......
187 220

  
188 221
    }
189 222

  
223
    @Test
224
    public void test_mediaType(){
225

  
226
        for(int i = 0; i < 10; i++ ){
227

  
228
            init();
229
            // repeat 10 times to assure the order of typedesignations is fix in the representations
230
            TaxonName typifiedName = TaxonNameFactory.NewBacterialInstance(Rank.SPECIES());
231
            typifiedName.setTitleCache("Prionus coriatius L.", true);
232
            typifiedName.addTypeDesignation(mtd_HT_published, false);
233
            typifiedName.addTypeDesignation(mtd_IT_unpublished, false);
234

  
235
            TypeDesignationSetManager typeDesignationManager = new TypeDesignationSetManager(typifiedName);
236
            typeDesignationManager.addTypeDesigations(null, mtd_HT_published);
237
            typeDesignationManager.addTypeDesigations(null, mtd_IT_unpublished);
238

  
239
            assertEquals("failed after repreating " + i + " times",
240
                    "Prionus coriatius L. Type: Testland, near Bughausen, A.Kohlbecker 81989, 2017 Holotype, [icon] p.33 in A.K. & W.K (2008) Algae of the BGBM; Isotype, [icon] (B Slide A565656)."
241
                    , typeDesignationManager.print()
242
                    );
243
        }
244

  
245
    }
246

  
190 247
    /**
191 248
     * {@inheritDoc}
192 249
     */

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)