Project

General

Profile

Revision b557cf20

IDb557cf20c6c4cc8dbc23476d7183ad3b331e8993
Parent 5bfe953d
Child 4133992a

Added by Andreas Müller 10 months ago

rename IAPT import test package (same name as import package itself)

View differences:

app-import/src/test/java/eu/etaxonomy/cdm/io/iapt/IAPTImportTest.java
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.io.phycobank.IAPTExcelImport;
10
import eu.etaxonomy.cdm.io.phycobank.IAPTImportConfigurator;
11
import eu.etaxonomy.cdm.model.occurrence.Collection;
12
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
13
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
14

  
15
/**
16
 * Created by andreas on 9/15/16.
17
 */
18
public class IAPTImportTest extends Assert {
19

  
20
    IAPTExcelImport<IAPTImportConfigurator> importer = null;
21

  
22
    @Before
23
    public void setup(){
24
        System.getProperties().put("TEST_MODE", "1");
25
        importer = new IAPTExcelImport<>();
26
    }
27

  
28
    @Test
29
    public void testDateParser(){
30

  
31
        String[] dateStrings = new String[]{
32
                "25 februari 1998",
33
                "April 12, 1969",
34
                "april 12th 1999",
35
                "April 99",
36
                "April, 1999",
37
                "Apr. 12",
38
                "12.04.1969",
39
                "12. 04. 1969",
40
                "12/04/1969",
41
                "12-04-1969",
42
                "12 de Enero de 1999",
43
                "17 de dezembro 1997",
44
                "15 diciembre de 1997",
45
                "Enero de 1999",
46
                "04.1969",
47
                "04/1969",
48
                "04-1969",
49
                "1999-04",
50
                "VI-1969",
51
                "12-VI-1969",
52
                "12. April 1969",
53
                "april 1999",
54
                "22 Dec.1999",
55
        };
56

  
57
        for (String d: dateStrings) {
58
            Assert.assertNotNull("Could not parse " + d, importer.parseDate("0", d));
59
        }
60
    }
61

  
62
    @Test
63
    public void testTypeSpecimenSplit(){
64

  
65
        String[][] typeStrings = new String[][]{
66
                new String[]{
67
                        "Type: Willershausen, ehemalige Ziegelei-Grube am Ostrand der Ortschaft. - Hellgraue, feingeschichtete Mergelsteinknollen, Pliozän.Holotype: STU P 1425.",
68
                        "STU P 1425",
69
                        ""},
70
                new String[]{
71
                        "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.",
72
                        "ERE 146518.",
73
                        "B 147519-147520, LE 146520."}
74
        };
75
        for (String[] t: typeStrings) {
76
            Matcher m = IAPTExcelImport.typeSpecimenSplitPattern.matcher(t[0]);
77
            assertTrue("typeSpecimenSplitPattern is not matching: " + t[0], m.matches());
78
            if(!t[1].isEmpty()){
79
                assertEquals(t[1], m.group("holotype").trim());
80
            }
81
            if(!t[2].isEmpty()){
82
                assertEquals(t[2], m.group("isotype").trim());
83
            }
84
        }
85

  
86
    }
87

  
88
    @Test
89
    public void testSpecimentTypeParser(){
90

  
91
        FieldUnit fu = FieldUnit.NewInstance();
92
        Collection collection = null;
93

  
94
        String[][] typeStrings = new String[][]{
95
                new String[]{ "Coll. Lange-Bertalot, Bot. Inst., Univ. Frankfurt/Main, Germany Praep. No. Eu-PL 72", "Praep. No. Eu-PL 72"},
96
                new String[]{ "LE 1700b-114", "1700b-114"},
97
                new String[]{ "AD 99530159", "99530159"},
98
                new String[]{"STU P 1425", "P 1425"},
99
                new String[]{"GAUF (Gansu Agricultural University) No. 1207-1222", " No. 1207-1222"},
100
                new String[]{ "KASSEL Coll. Krasske, Praep. DII 78", "Praep. DII 78"},
101
                new String[]{ "Coll. Lange-Bertalot, Botanisches Institut, Frankfurt am Main slide Eh-B 91", "slide Eh-B 91"},
102
                new String[]{ "Coll. Østrup, Botan. Museum Copenhagen, Dänemark Praep. 3944", "Praep. 3944"},
103
                new String[]{ "Coll. L.P.B.V. No. 0736", "No. 0736"},
104
                new String[]{ "Coll. Ruhr University-Bochum, Inst. of Geology No. 11532", "No. 11532"},
105
                new String[]{ "Coll. Paläontol. Inst. Univ. Bucuresti. Nr. 2515", "Nr. 2515"},
106
                new String[]{ "Coll. Dr.h.c. R. Mundlos (Bad Friedrichshall, später Stuttgart) Inv. Nr. P 1396", "Inv. Nr. P 1396"},
107
                new String[]{ "Inst. Geological Sciences, Acad. Sci. Belarus, Minsk N 212 A", "N 212 A"},
108
                new String[]{ "Coll. Lange-Bertalot, Bot. Inst., Univ. Frankfurt/Main, Germany"},
109
                new String[]{ "in coll. H. F. Paulus (Wien)"},
110
        };
111

  
112
        for (String t[]: typeStrings) {
113
            DerivedUnit specimen = importer.parseSpecimenType(fu, IAPTExcelImport.TypesName.holotype, collection, t[0], "0");
114
            assertNotNull("Could not parse: " + t[0], specimen);
115
            if(t.length > 1){
116
                assertEquals(t[1], specimen.getAccessionNumber());
117
            }
118
        }
119

  
120
    }
121

  
122
    @Test
123
    public void testParseFieldUnit(){
124

  
125
        String[] typeStrings = new String[]{
126
                "Lake Bungarby, (36°09'S, 149°08'E), south-eastern New South Wales. - leg. Greg Jordan, Graham Taylor & Leanne Dansie.",
127
                "Mt. Koghis, Nouvelle-Calédonie (leg. Moser et al., 06.03.1994).",
128
                "Salt marsh, Wladyslawowo, Puck Bay, Poland (leg. A. Witkowski, 1993).",
129
                "Blankaart, Woumen (Belgium), sediment sample Jun 1993, core III, 16-17 cm depth (leg. L. Denys, January 1997). In sediment and epiphyton.",
130
                "Rivière des Lacs, Cascade (Chutes de la Madeleine), Nouvelle-Calédonie (leg. Moser et al., 10.03.1994).",
131
                "Bulgaria austro-occidentalis. In graminosis saxosis prope vic. Strumesnitza, cca 120 m s.m., Petric district. Leg. D.Delipavlov 03.06.1987.",
132
                "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",
133
                "Haute Hienghène, au nord-est de l'île Nouvelle-Calédonie. Expression de mousses (leg. Guillaumin).",
134
                "leg. J. J. Halda 18.3.1997"
135
        };
136
        for (String t: typeStrings) {
137
            assertTrue("collectorPattern is not matching: " + t, IAPTExcelImport.collectorPattern.matcher(t).matches());
138
        }
139
    }
140
}
app-import/src/test/java/eu/etaxonomy/cdm/io/phycobank/IAPTImportTest.java
1
package eu.etaxonomy.cdm.io.phycobank;
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.io.phycobank.IAPTExcelImport;
10
import eu.etaxonomy.cdm.io.phycobank.IAPTImportConfigurator;
11
import eu.etaxonomy.cdm.model.occurrence.Collection;
12
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
13
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
14

  
15
/**
16
 * Created by andreas on 9/15/16.
17
 */
18
public class IAPTImportTest extends Assert {
19

  
20
    IAPTExcelImport<IAPTImportConfigurator> importer = null;
21

  
22
    @Before
23
    public void setup(){
24
        System.getProperties().put("TEST_MODE", "1");
25
        importer = new IAPTExcelImport<>();
26
    }
27

  
28
    @Test
29
    public void testDateParser(){
30

  
31
        String[] dateStrings = new String[]{
32
                "25 februari 1998",
33
                "April 12, 1969",
34
                "april 12th 1999",
35
                "April 99",
36
                "April, 1999",
37
                "Apr. 12",
38
                "12.04.1969",
39
                "12. 04. 1969",
40
                "12/04/1969",
41
                "12-04-1969",
42
                "12 de Enero de 1999",
43
                "17 de dezembro 1997",
44
                "15 diciembre de 1997",
45
                "Enero de 1999",
46
                "04.1969",
47
                "04/1969",
48
                "04-1969",
49
                "1999-04",
50
                "VI-1969",
51
                "12-VI-1969",
52
                "12. April 1969",
53
                "april 1999",
54
                "22 Dec.1999",
55
        };
56

  
57
        for (String d: dateStrings) {
58
            Assert.assertNotNull("Could not parse " + d, importer.parseDate("0", d));
59
        }
60
    }
61

  
62
    @Test
63
    public void testTypeSpecimenSplit(){
64

  
65
        String[][] typeStrings = new String[][]{
66
                new String[]{
67
                        "Type: Willershausen, ehemalige Ziegelei-Grube am Ostrand der Ortschaft. - Hellgraue, feingeschichtete Mergelsteinknollen, Pliozän.Holotype: STU P 1425.",
68
                        "STU P 1425",
69
                        ""},
70
                new String[]{
71
                        "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.",
72
                        "ERE 146518.",
73
                        "B 147519-147520, LE 146520."}
74
        };
75
        for (String[] t: typeStrings) {
76
            Matcher m = IAPTExcelImport.typeSpecimenSplitPattern.matcher(t[0]);
77
            assertTrue("typeSpecimenSplitPattern is not matching: " + t[0], m.matches());
78
            if(!t[1].isEmpty()){
79
                assertEquals(t[1], m.group("holotype").trim());
80
            }
81
            if(!t[2].isEmpty()){
82
                assertEquals(t[2], m.group("isotype").trim());
83
            }
84
        }
85

  
86
    }
87

  
88
    @Test
89
    public void testSpecimentTypeParser(){
90

  
91
        FieldUnit fu = FieldUnit.NewInstance();
92
        Collection collection = null;
93

  
94
        String[][] typeStrings = new String[][]{
95
                new String[]{ "Coll. Lange-Bertalot, Bot. Inst., Univ. Frankfurt/Main, Germany Praep. No. Eu-PL 72", "Praep. No. Eu-PL 72"},
96
                new String[]{ "LE 1700b-114", "1700b-114"},
97
                new String[]{ "AD 99530159", "99530159"},
98
                new String[]{"STU P 1425", "P 1425"},
99
                new String[]{"GAUF (Gansu Agricultural University) No. 1207-1222", " No. 1207-1222"},
100
                new String[]{ "KASSEL Coll. Krasske, Praep. DII 78", "Praep. DII 78"},
101
                new String[]{ "Coll. Lange-Bertalot, Botanisches Institut, Frankfurt am Main slide Eh-B 91", "slide Eh-B 91"},
102
                new String[]{ "Coll. Østrup, Botan. Museum Copenhagen, Dänemark Praep. 3944", "Praep. 3944"},
103
                new String[]{ "Coll. L.P.B.V. No. 0736", "No. 0736"},
104
                new String[]{ "Coll. Ruhr University-Bochum, Inst. of Geology No. 11532", "No. 11532"},
105
                new String[]{ "Coll. Paläontol. Inst. Univ. Bucuresti. Nr. 2515", "Nr. 2515"},
106
                new String[]{ "Coll. Dr.h.c. R. Mundlos (Bad Friedrichshall, später Stuttgart) Inv. Nr. P 1396", "Inv. Nr. P 1396"},
107
                new String[]{ "Inst. Geological Sciences, Acad. Sci. Belarus, Minsk N 212 A", "N 212 A"},
108
                new String[]{ "Coll. Lange-Bertalot, Bot. Inst., Univ. Frankfurt/Main, Germany"},
109
                new String[]{ "in coll. H. F. Paulus (Wien)"},
110
        };
111

  
112
        for (String t[]: typeStrings) {
113
            DerivedUnit specimen = importer.parseSpecimenType(fu, IAPTExcelImport.TypesName.holotype, collection, t[0], "0");
114
            assertNotNull("Could not parse: " + t[0], specimen);
115
            if(t.length > 1){
116
                assertEquals(t[1], specimen.getAccessionNumber());
117
            }
118
        }
119

  
120
    }
121

  
122
    @Test
123
    public void testParseFieldUnit(){
124

  
125
        String[] typeStrings = new String[]{
126
                "Lake Bungarby, (36°09'S, 149°08'E), south-eastern New South Wales. - leg. Greg Jordan, Graham Taylor & Leanne Dansie.",
127
                "Mt. Koghis, Nouvelle-Calédonie (leg. Moser et al., 06.03.1994).",
128
                "Salt marsh, Wladyslawowo, Puck Bay, Poland (leg. A. Witkowski, 1993).",
129
                "Blankaart, Woumen (Belgium), sediment sample Jun 1993, core III, 16-17 cm depth (leg. L. Denys, January 1997). In sediment and epiphyton.",
130
                "Rivière des Lacs, Cascade (Chutes de la Madeleine), Nouvelle-Calédonie (leg. Moser et al., 10.03.1994).",
131
                "Bulgaria austro-occidentalis. In graminosis saxosis prope vic. Strumesnitza, cca 120 m s.m., Petric district. Leg. D.Delipavlov 03.06.1987.",
132
                "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",
133
                "Haute Hienghène, au nord-est de l'île Nouvelle-Calédonie. Expression de mousses (leg. Guillaumin).",
134
                "leg. J. J. Halda 18.3.1997"
135
        };
136
        for (String t: typeStrings) {
137
            assertTrue("collectorPattern is not matching: " + t, IAPTExcelImport.collectorPattern.matcher(t).matches());
138
        }
139
    }
140
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)