1
|
/**
|
2
|
* Copyright (C) 2017 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.api.utility;
|
10
|
|
11
|
import org.junit.Assert;
|
12
|
import org.junit.Test;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
15
|
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
|
16
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
17
|
|
18
|
/**
|
19
|
*
|
20
|
* @author a.kohlbecker
|
21
|
* @since Jun 23, 2017
|
22
|
*
|
23
|
*/
|
24
|
public class DerivedUnitConverterTest extends Assert {
|
25
|
|
26
|
@Test
|
27
|
public void toMediaSpecimen() throws DerivedUnitConversionException {
|
28
|
DerivedUnit du = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
|
29
|
du.setTitleCache("test derived unit", true);
|
30
|
DerivedUnitConverter<MediaSpecimen> duc = new DerivedUnitConverter<MediaSpecimen>(du);
|
31
|
MediaSpecimen target = duc.convertTo(MediaSpecimen.class, SpecimenOrObservationType.StillImage);
|
32
|
assertNotNull(target);
|
33
|
assertEquals(SpecimenOrObservationType.StillImage, target.getRecordBasis());
|
34
|
assertEquals("test derived unit", target.getTitleCache());
|
35
|
}
|
36
|
|
37
|
@Test
|
38
|
public void toDerivedUnit() throws DerivedUnitConversionException {
|
39
|
|
40
|
MediaSpecimen du = MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage);
|
41
|
du.setTitleCache("test media specimen", true);
|
42
|
DerivedUnitConverter<DerivedUnit> duc = new DerivedUnitConverter<DerivedUnit>(du);
|
43
|
DerivedUnit target = duc.convertTo(DerivedUnit.class, SpecimenOrObservationType.PreservedSpecimen);
|
44
|
assertNotNull(target);
|
45
|
assertEquals(SpecimenOrObservationType.PreservedSpecimen, target.getRecordBasis());
|
46
|
assertEquals("test media specimen", target.getTitleCache());
|
47
|
}
|
48
|
|
49
|
}
|