ref #6026 solving problems in date and specimenType parsers, also implementing tests
[cdmlib-apps.git] / app-import / src / test / java / eu / etaxonomy / cdm / io / iapt / IAPTImportTest.java
1 package eu.etaxonomy.cdm.io.iapt;
2
3 import eu.etaxonomy.cdm.model.occurrence.Collection;
4 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
5 import org.junit.Before;
6 import org.junit.Test;
7 import org.springframework.util.Assert;
8
9 /**
10 * Created by andreas on 9/15/16.
11 */
12 public class IAPTImportTest {
13
14 IAPTExcelImport importer = null;
15
16 @Before
17 public void setup(){
18 System.getProperties().put("TEST_MODE", "1");
19 importer = new IAPTExcelImport();
20 }
21
22 @Test
23 public void testDateParser(){
24
25 String[] dateStrings = new String[]{
26 "April 12, 1969",
27 "april 12th 1999",
28 "April 99",
29 "April, 1999",
30 "Apr. 12",
31 "12.04.1969",
32 "12. 04. 1969",
33 "12/04/1969",
34 "12-04-1969",
35 "12 de Enero de 1999",
36 "Enero de 1999",
37 "04.1969",
38 "04/1969",
39 "04-1969",
40 "1999-04",
41 "VI-1969",
42 "12-VI-1969",
43 "12. April 1969",
44 "april 1999",
45 "22 Dec.1999"
46 };
47
48 for (String d: dateStrings) {
49 Assert.notNull(importer.parseDate("0", d), "Could not parse " + d);
50 }
51 }
52
53 @Test
54 public void testSpecimentTypeParser(){
55
56 FieldUnit fu = FieldUnit.NewInstance();
57 Collection collection = null;
58
59 String[] typeStrings = new String[]{
60 "Coll. Lange-Bertalot, Bot. Inst., Univ. Frankfurt/Main, Germany Praep. No. Eu-PL 72",
61 "LE 1700b-114",
62 "AD 99530159",
63 "STU P 1425",
64 "GAUF (Gansu Agricultural University) No. 1207-1222",
65 "KASSEL Coll. Krasske, Praep. DII 78",
66 "Coll. Lange-Bertalot, Botanisches Institut, Frankfurt am Main slide Eh-B 91",
67 "Coll. Østrup, Botan. Museum Copenhagen, Dänemark Praep. 3944",
68
69
70 };
71 for (String t: typeStrings) {
72 Assert.notNull(importer.parseSpecimenType(fu, IAPTExcelImport.TypesName.holotype, collection, t, "0"), "Could not parse: " + t);
73 }
74
75 }
76 }