1
|
package eu.etaxonomy.cdm.io.iapt;
|
2
|
|
3
|
import java.util.regex.Matcher;
|
4
|
|
5
|
import org.junit.Assert;
|
6
|
import org.junit.Before;
|
7
|
import org.junit.Test;
|
8
|
|
9
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
10
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
11
|
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
12
|
|
13
|
/**
|
14
|
* Created by andreas on 9/15/16.
|
15
|
*/
|
16
|
public class IAPTImportTest extends Assert {
|
17
|
|
18
|
IAPTExcelImport<IAPTImportConfigurator> importer = null;
|
19
|
|
20
|
@Before
|
21
|
public void setup(){
|
22
|
System.getProperties().put("TEST_MODE", "1");
|
23
|
importer = new IAPTExcelImport<>();
|
24
|
}
|
25
|
|
26
|
@Test
|
27
|
public void testDateParser(){
|
28
|
|
29
|
String[] dateStrings = new String[]{
|
30
|
"25 februari 1998",
|
31
|
"April 12, 1969",
|
32
|
"april 12th 1999",
|
33
|
"April 99",
|
34
|
"April, 1999",
|
35
|
"Apr. 12",
|
36
|
"12.04.1969",
|
37
|
"12. 04. 1969",
|
38
|
"12/04/1969",
|
39
|
"12-04-1969",
|
40
|
"12 de Enero de 1999",
|
41
|
"17 de dezembro 1997",
|
42
|
"15 diciembre de 1997",
|
43
|
"Enero de 1999",
|
44
|
"04.1969",
|
45
|
"04/1969",
|
46
|
"04-1969",
|
47
|
"1999-04",
|
48
|
"VI-1969",
|
49
|
"12-VI-1969",
|
50
|
"12. April 1969",
|
51
|
"april 1999",
|
52
|
"22 Dec.1999",
|
53
|
};
|
54
|
|
55
|
for (String d: dateStrings) {
|
56
|
Assert.assertNotNull("Could not parse " + d, importer.parseDate("0", d));
|
57
|
}
|
58
|
}
|
59
|
|
60
|
@Test
|
61
|
public void testTypeSpecimenSplit(){
|
62
|
|
63
|
String[][] typeStrings = new String[][]{
|
64
|
new String[]{
|
65
|
"Type: Willershausen, ehemalige Ziegelei-Grube am Ostrand der Ortschaft. - Hellgraue, feingeschichtete Mergelsteinknollen, Pliozän.Holotype: STU P 1425.",
|
66
|
"STU P 1425",
|
67
|
""},
|
68
|
new String[]{
|
69
|
"Type: Armenia, Shirak distr. in vicinitate pag. Areg. m. Arteni in steppis tragacanthaceis, 1500-1700 m s.m. 9.4.1998, E. Gabrielian legitHolotype: ERE 146518. Isotype(s): B 147519-147520, LE 146520.",
|
70
|
"ERE 146518.",
|
71
|
"B 147519-147520, LE 146520."}
|
72
|
};
|
73
|
for (String[] t: typeStrings) {
|
74
|
Matcher m = IAPTExcelImport.typeSpecimenSplitPattern.matcher(t[0]);
|
75
|
assertTrue("typeSpecimenSplitPattern is not matching: " + t[0], m.matches());
|
76
|
if(!t[1].isEmpty()){
|
77
|
assertEquals(t[1], m.group("holotype").trim());
|
78
|
}
|
79
|
if(!t[2].isEmpty()){
|
80
|
assertEquals(t[2], m.group("isotype").trim());
|
81
|
}
|
82
|
}
|
83
|
|
84
|
}
|
85
|
|
86
|
@Test
|
87
|
public void testSpecimentTypeParser(){
|
88
|
|
89
|
FieldUnit fu = FieldUnit.NewInstance();
|
90
|
Collection collection = null;
|
91
|
|
92
|
String[][] typeStrings = new String[][]{
|
93
|
new String[]{ "Coll. Lange-Bertalot, Bot. Inst., Univ. Frankfurt/Main, Germany Praep. No. Eu-PL 72", "Praep. No. Eu-PL 72"},
|
94
|
new String[]{ "LE 1700b-114", "1700b-114"},
|
95
|
new String[]{ "AD 99530159", "99530159"},
|
96
|
new String[]{"STU P 1425", "P 1425"},
|
97
|
new String[]{"GAUF (Gansu Agricultural University) No. 1207-1222", " No. 1207-1222"},
|
98
|
new String[]{ "KASSEL Coll. Krasske, Praep. DII 78", "Praep. DII 78"},
|
99
|
new String[]{ "Coll. Lange-Bertalot, Botanisches Institut, Frankfurt am Main slide Eh-B 91", "slide Eh-B 91"},
|
100
|
new String[]{ "Coll. Østrup, Botan. Museum Copenhagen, Dänemark Praep. 3944", "Praep. 3944"},
|
101
|
new String[]{ "Coll. L.P.B.V. No. 0736", "No. 0736"},
|
102
|
new String[]{ "Coll. Ruhr University-Bochum, Inst. of Geology No. 11532", "No. 11532"},
|
103
|
new String[]{ "Coll. Paläontol. Inst. Univ. Bucuresti. Nr. 2515", "Nr. 2515"},
|
104
|
new String[]{ "Coll. Dr.h.c. R. Mundlos (Bad Friedrichshall, später Stuttgart) Inv. Nr. P 1396", "Inv. Nr. P 1396"},
|
105
|
new String[]{ "Inst. Geological Sciences, Acad. Sci. Belarus, Minsk N 212 A", "N 212 A"},
|
106
|
new String[]{ "Coll. Lange-Bertalot, Bot. Inst., Univ. Frankfurt/Main, Germany"},
|
107
|
new String[]{ "in coll. H. F. Paulus (Wien)"},
|
108
|
};
|
109
|
|
110
|
for (String t[]: typeStrings) {
|
111
|
DerivedUnit specimen = importer.parseSpecimenType(fu, IAPTExcelImport.TypesName.holotype, collection, t[0], "0");
|
112
|
assertNotNull("Could not parse: " + t[0], specimen);
|
113
|
if(t.length > 1){
|
114
|
assertEquals(t[1], specimen.getAccessionNumber());
|
115
|
}
|
116
|
}
|
117
|
|
118
|
}
|
119
|
|
120
|
@Test
|
121
|
public void testParseFieldUnit(){
|
122
|
|
123
|
String[] typeStrings = new String[]{
|
124
|
"Lake Bungarby, (36°09'S, 149°08'E), south-eastern New South Wales. - leg. Greg Jordan, Graham Taylor & Leanne Dansie.",
|
125
|
"Mt. Koghis, Nouvelle-Calédonie (leg. Moser et al., 06.03.1994).",
|
126
|
"Salt marsh, Wladyslawowo, Puck Bay, Poland (leg. A. Witkowski, 1993).",
|
127
|
"Blankaart, Woumen (Belgium), sediment sample Jun 1993, core III, 16-17 cm depth (leg. L. Denys, January 1997). In sediment and epiphyton.",
|
128
|
"Rivière des Lacs, Cascade (Chutes de la Madeleine), Nouvelle-Calédonie (leg. Moser et al., 10.03.1994).",
|
129
|
"Bulgaria austro-occidentalis. In graminosis saxosis prope vic. Strumesnitza, cca 120 m s.m., Petric district. Leg. D.Delipavlov 03.06.1987.",
|
130
|
"Lesbos 152, mit sechs Schliffen, ein kleines Geröll mit einem Durchmesser von ca. 4,5 x 5,5 cm. - Strand von Lapsarna, nordwestlich von Antissa. Versteinerter Wald von Lesbos, Griechenland. - Tertiär, Oberoligozän/Untermiozän. - Leg.: E. Velitzelo",
|
131
|
"Haute Hienghène, au nord-est de l'île Nouvelle-Calédonie. Expression de mousses (leg. Guillaumin).",
|
132
|
"leg. J. J. Halda 18.3.1997"
|
133
|
};
|
134
|
for (String t: typeStrings) {
|
135
|
assertTrue("collectorPattern is not matching: " + t, IAPTExcelImport.collectorPattern.matcher(t).matches());
|
136
|
}
|
137
|
}
|
138
|
}
|