Revision 7d8050b3
Added by Andreas Kohlbecker over 8 years ago
src/test/java/org/bgbm/biovel/drf/checklist/BgbmEditChecklistTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.checklist; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import javax.xml.bind.JAXBException; |
|
7 |
|
|
8 |
import org.bgbm.biovel.drf.checklist.BgbmEditClient; |
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
11 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
12 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
13 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
14 |
import org.bgbm.biovel.drf.tnr.msg.Query; |
|
15 |
import org.bgbm.biovel.drf.tnr.msg.TnrMsg; |
|
16 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
17 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
18 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
19 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
20 |
import org.junit.BeforeClass; |
|
21 |
import org.junit.Test; |
|
22 |
|
|
23 |
public class BgbmEditChecklistTest { |
|
24 |
|
|
25 |
private static DRFCSVInputParser parser; |
|
26 |
private static List<String> nameCompleteList; |
|
27 |
|
|
28 |
private static ServiceProviderInfo ci; |
|
29 |
|
|
30 |
@BeforeClass |
|
31 |
public static void setup() { |
|
32 |
parser = new DRFCSVInputParser(); |
|
33 |
|
|
34 |
nameCompleteList = new ArrayList<String>(); |
|
35 |
nameCompleteList.add("Ameira divagans"); |
|
36 |
nameCompleteList.add("Boccardi redeki"); |
|
37 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
38 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
39 |
nameCompleteList.add("Cercopagis pengoi"); |
|
40 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
41 |
|
|
42 |
|
|
43 |
ci = new ServiceProviderInfo(BgbmEditClient.ID, |
|
44 |
BgbmEditClient.LABEL, |
|
45 |
BgbmEditClient.DOC_URL, |
|
46 |
BgbmEditClient.COPYRIGHT_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
47 |
ci.addSubChecklist(new ServiceProviderInfo("col", |
|
48 |
"EDIT - Catalogue Of Life", |
|
49 |
"http://wp5.e-taxonomy.eu/cdmlib/rest-api-name-catalogue.html", |
|
50 |
"http://www.catalogueoflife.org/col/info/copyright", ServiceProviderInfo.DEFAULT_SEARCH_MODE)); |
|
51 |
} |
|
52 |
|
|
53 |
@Test |
|
54 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
55 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
56 |
System.out.println("Json : " + checklistInfoJson); |
|
57 |
} |
|
58 |
|
|
59 |
@Test |
|
60 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
61 |
parser = new DRFCSVInputParser(); |
|
62 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/vibrant.csv","UTF-8")); |
|
63 |
//List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
64 |
TnrMsg tnrMsg = TnrMsgUtils.mergeTnrMsgs(tnrMsgs); |
|
65 |
String json = JSONUtils.convertObjectToJson(ci); |
|
66 |
BgbmEditClient bec = new BgbmEditClient(json); |
|
67 |
|
|
68 |
|
|
69 |
for(Query query : tnrMsg.getQuery()) { |
|
70 |
query.getRequest().setSearchMode(SearchMode.scientificNameExact.toString()); |
|
71 |
} |
|
72 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
73 |
bec.queryChecklist(tnrMsg); |
|
74 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
75 |
System.out.println(outputXML); |
|
76 |
} |
|
77 |
} |
src/test/java/org/bgbm/biovel/drf/checklist/ChecklistTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.checklist; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
8 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
9 |
import org.bgbm.biovel.drf.utils.ServiceProviderInfoUtils; |
|
10 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
11 |
import org.junit.BeforeClass; |
|
12 |
import org.junit.Test; |
|
13 |
|
|
14 |
public class ChecklistTest { |
|
15 |
|
|
16 |
@BeforeClass |
|
17 |
public static void setup() { |
|
18 |
} |
|
19 |
|
|
20 |
@Test |
|
21 |
public void generateChecklistInfoList() throws DRFChecklistException { |
|
22 |
String checklistInfoListJson = ServiceProviderInfoUtils.generateChecklistInfoListAsJson(); |
|
23 |
System.out.println("Json : " + checklistInfoListJson); |
|
24 |
} |
|
25 |
|
|
26 |
@Test |
|
27 |
public void generateChecklistInfoListFromStringArray() throws DRFChecklistException { |
|
28 |
List<String> ciList = new ArrayList<String>(); |
|
29 |
ciList.add("species2000col;species2000col;Species2000 - Catalogue Of Life;http://www.catalogueoflife.org;http://www.catalogueoflife.org/col/info/copyright"); |
|
30 |
ciList.add("edit;col;EDIT - Catalogue Of Life;http://wp5.e-taxonomy.eu/cdmlib/rest-api-name-catalogue.html;http://www.catalogueoflife.org/col/info/copyright"); |
|
31 |
ciList.add("gbif;1028;Afromoths, online datbase of Afrotropical moth species (Lepidoptera);http://ecat-dev.gbif.org/checklist/1028;"); |
|
32 |
ciList.add("gbif;1000;Afromoths, online datbase of Afrotropical moth species (Lepidoptera);http://ecat-dev.gbif.org/checklist/1000;"); |
|
33 |
|
|
34 |
List<ServiceProviderInfo> ciInfoList = ServiceProviderInfoUtils.convertStringToChecklistInfo(ciList); |
|
35 |
Iterator<ServiceProviderInfo> ciInfoItr = ciInfoList.iterator(); |
|
36 |
while(ciInfoItr.hasNext()) { |
|
37 |
System.out.println(JSONUtils.convertObjectToJson(ciInfoItr.next())); |
|
38 |
} |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
|
|
43 |
} |
|
44 |
|
src/test/java/org/bgbm/biovel/drf/checklist/GBIFBetaChecklistTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.checklist; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.xml.bind.JAXBException; |
|
8 |
|
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.GBIFBetaBackboneClient; |
|
11 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
12 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
13 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
14 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
15 |
import org.bgbm.biovel.drf.tnr.msg.TnrMsg; |
|
16 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
17 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
18 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
19 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
20 |
import org.junit.BeforeClass; |
|
21 |
import org.junit.Ignore; |
|
22 |
import org.junit.Test; |
|
23 |
|
|
24 |
@Ignore |
|
25 |
public class GBIFBetaChecklistTest { |
|
26 |
|
|
27 |
private static DRFCSVInputParser parser; |
|
28 |
private static List<String> nameCompleteList; |
|
29 |
|
|
30 |
private static ServiceProviderInfo ci; |
|
31 |
|
|
32 |
@BeforeClass |
|
33 |
public static void setup() { |
|
34 |
parser = new DRFCSVInputParser(); |
|
35 |
|
|
36 |
nameCompleteList = new ArrayList<String>(); |
|
37 |
nameCompleteList.add("Ameira divagans"); |
|
38 |
nameCompleteList.add("Boccardi redeki"); |
|
39 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
40 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
41 |
nameCompleteList.add("Cercopagis pengoi"); |
|
42 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
43 |
|
|
44 |
|
|
45 |
ci = new ServiceProviderInfo(GBIFBetaBackboneClient.ID, |
|
46 |
GBIFBetaBackboneClient.LABEL, |
|
47 |
GBIFBetaBackboneClient.URL, |
|
48 |
GBIFBetaBackboneClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
49 |
ci.addSubChecklist(new ServiceProviderInfo("1", "GBIF NUB Taxonomy", "http://ecat-dev.gbif.org/checklist/1")); |
|
50 |
} |
|
51 |
|
|
52 |
@Test |
|
53 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
54 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
55 |
System.out.println("Json : " + checklistInfoJson); |
|
56 |
} |
|
57 |
|
|
58 |
@Test |
|
59 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
60 |
parser = new DRFCSVInputParser(); |
|
61 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
62 |
//List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/singleNameCompleteOnly.csv","UTF-8")); |
|
63 |
|
|
64 |
|
|
65 |
GBIFBetaBackboneClient gbbc = new GBIFBetaBackboneClient(JSONUtils.convertObjectToJson(ci)); |
|
66 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
67 |
while(tnrMsgItr.hasNext()) { |
|
68 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
69 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
70 |
gbbc.queryChecklist(tnrMsg); |
|
71 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
72 |
System.out.println(outputXML); |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
|
src/test/java/org/bgbm/biovel/drf/checklist/GBIFChecklistTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.checklist; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.xml.bind.JAXBException; |
|
8 |
|
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.GBIFBackboneClient; |
|
11 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
12 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
13 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
14 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
15 |
import org.bgbm.biovel.drf.tnr.msg.TnrMsg; |
|
16 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
17 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
18 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
19 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
20 |
import org.junit.BeforeClass; |
|
21 |
import org.junit.Test; |
|
22 |
|
|
23 |
//@Ignore |
|
24 |
public class GBIFChecklistTest { |
|
25 |
|
|
26 |
private static DRFCSVInputParser parser; |
|
27 |
private static List<String> nameCompleteList; |
|
28 |
|
|
29 |
private static ServiceProviderInfo ci; |
|
30 |
|
|
31 |
@BeforeClass |
|
32 |
public static void setup() { |
|
33 |
parser = new DRFCSVInputParser(); |
|
34 |
|
|
35 |
nameCompleteList = new ArrayList<String>(); |
|
36 |
nameCompleteList.add("Ameira divagans"); |
|
37 |
nameCompleteList.add("Boccardiella ligerica"); |
|
38 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
39 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
40 |
nameCompleteList.add("Cercopagis pengoi"); |
|
41 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
42 |
|
|
43 |
ci = new ServiceProviderInfo(GBIFBackboneClient.ID, |
|
44 |
GBIFBackboneClient.LABEL, |
|
45 |
GBIFBackboneClient.URL, |
|
46 |
GBIFBackboneClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
47 |
ci.addSubChecklist(new ServiceProviderInfo("d7dddbf4-2cf0-4f39-9b2a-bb099caae36c", "GBIF NUB Taxonomy", "http://uat.gbif.org/dataset/d7dddbf4-2cf0-4f39-9b2a-bb099caae36c")); |
|
48 |
} |
|
49 |
|
|
50 |
@Test |
|
51 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
52 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
53 |
System.out.println("Json : " + checklistInfoJson); |
|
54 |
} |
|
55 |
|
|
56 |
@Test |
|
57 |
public void buildServiceProviderInfo() throws DRFChecklistException { |
|
58 |
GBIFBackboneClient gbc = new GBIFBackboneClient(); |
|
59 |
ServiceProviderInfo spiInfo = gbc.buildServiceProviderInfo(); |
|
60 |
List<ServiceProviderInfo> spiList = spiInfo.getSubChecklists(); |
|
61 |
Iterator<ServiceProviderInfo> spiItr = spiList.iterator(); |
|
62 |
while(spiItr.hasNext()) { |
|
63 |
ServiceProviderInfo spi = spiItr.next(); |
|
64 |
System.out.println("Dataset : " + spi.getLabel() ); |
|
65 |
} |
|
66 |
String checklistInfoJson = JSONUtils.convertObjectToJson(spiInfo); |
|
67 |
System.out.println("Json : " + checklistInfoJson); |
|
68 |
|
|
69 |
} |
|
70 |
|
|
71 |
@Test |
|
72 |
public void nameCompleteCsvTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
73 |
parser = new DRFCSVInputParser(); |
|
74 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
75 |
//List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/singleNameCompleteOnly.csv","UTF-8")); |
|
76 |
List<String> chosenKeyList = new ArrayList<String>(); |
|
77 |
chosenKeyList.add("7ddf754f-d193-4cc9-b351-99906754a03b"); |
|
78 |
|
|
79 |
GBIFBackboneClient gbc = new GBIFBackboneClient(JSONUtils.convertObjectToJson(ci)); |
|
80 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
81 |
while(tnrMsgItr.hasNext()) { |
|
82 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
83 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
84 |
gbc.queryChecklist(tnrMsg); |
|
85 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
86 |
System.out.println(outputXML); |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
@Test |
|
91 |
public void nameCompleteStringListTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
92 |
parser = new DRFCSVInputParser(); |
|
93 |
List<TnrMsg> tnrMsgs = TnrMsgUtils.convertStringListToTnrMsgList(nameCompleteList, SearchMode.scientificNameExact, false); |
|
94 |
//List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/singleNameCompleteOnly.csv","UTF-8")); |
|
95 |
List<String> chosenKeyList = new ArrayList<String>(); |
|
96 |
chosenKeyList.add("7ddf754f-d193-4cc9-b351-99906754a03b"); |
|
97 |
|
|
98 |
GBIFBackboneClient gbc = new GBIFBackboneClient(JSONUtils.convertObjectToJson(ci)); |
|
99 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
100 |
while(tnrMsgItr.hasNext()) { |
|
101 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
102 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
103 |
gbc.queryChecklist(tnrMsg); |
|
104 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
105 |
System.out.println(outputXML); |
|
106 |
} |
|
107 |
} |
|
108 |
} |
src/test/java/org/bgbm/biovel/drf/checklist/PESIClientTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.checklist; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.xml.bind.JAXBException; |
|
8 |
|
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.PESIClient; |
|
11 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
12 |
import org.bgbm.biovel.drf.checklist.Species2000ColClient; |
|
13 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
14 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
15 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
16 |
import org.bgbm.biovel.drf.tnr.msg.TnrMsg; |
|
17 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
18 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
19 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
20 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
21 |
import org.junit.BeforeClass; |
|
22 |
import org.junit.Test; |
|
23 |
|
|
24 |
public class PESIClientTest { |
|
25 |
|
|
26 |
private static DRFCSVInputParser parser; |
|
27 |
private static List<String> nameCompleteList; |
|
28 |
|
|
29 |
private static ServiceProviderInfo ci; |
|
30 |
|
|
31 |
@BeforeClass |
|
32 |
public static void setup() { |
|
33 |
parser = new DRFCSVInputParser(); |
|
34 |
|
|
35 |
nameCompleteList = new ArrayList<String>(); |
|
36 |
nameCompleteList.add("Ameira divagans"); |
|
37 |
nameCompleteList.add("Boccardi redeki"); |
|
38 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
39 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
40 |
nameCompleteList.add("Cercopagis pengoi"); |
|
41 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
42 |
|
|
43 |
|
|
44 |
ci = new ServiceProviderInfo(Species2000ColClient.ID, |
|
45 |
Species2000ColClient.LABEL, |
|
46 |
Species2000ColClient.URL, |
|
47 |
Species2000ColClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
48 |
} |
|
49 |
|
|
50 |
@Test |
|
51 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
52 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
53 |
System.out.println("Json : " + checklistInfoJson); |
|
54 |
} |
|
55 |
|
|
56 |
@Test |
|
57 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
58 |
parser = new DRFCSVInputParser(); |
|
59 |
//List<String> inputXMLList = parser.parseToXML(BiovelUtils.getCSVAsString("org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
60 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
61 |
// List<String> chosenKeyList = new ArrayList<String>(); |
|
62 |
// chosenKeyList.add("d7dddbf4-2cf0-4f39-9b2a-bb099caae36c"); |
|
63 |
|
|
64 |
PESIClient pesic = new PESIClient(); |
|
65 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
66 |
while(tnrMsgItr.hasNext()) { |
|
67 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
68 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
69 |
pesic.queryChecklist(tnrMsg); |
|
70 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
71 |
System.out.println(outputXML); |
|
72 |
} |
|
73 |
} |
|
74 |
} |
|
75 |
|
src/test/java/org/bgbm/biovel/drf/checklist/Species2000ColClientTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.checklist; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.xml.bind.JAXBException; |
|
8 |
|
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
11 |
import org.bgbm.biovel.drf.checklist.Species2000ColClient; |
|
12 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
13 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
14 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
15 |
import org.bgbm.biovel.drf.tnr.msg.TnrMsg; |
|
16 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
17 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
18 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
19 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
20 |
import org.junit.BeforeClass; |
|
21 |
import org.junit.Test; |
|
22 |
|
|
23 |
public class Species2000ColClientTest { |
|
24 |
|
|
25 |
private static DRFCSVInputParser parser; |
|
26 |
private static List<String> nameCompleteList; |
|
27 |
|
|
28 |
private static ServiceProviderInfo ci; |
|
29 |
|
|
30 |
@BeforeClass |
|
31 |
public static void setup() { |
|
32 |
parser = new DRFCSVInputParser(); |
|
33 |
|
|
34 |
nameCompleteList = new ArrayList<String>(); |
|
35 |
nameCompleteList.add("Ameira divagans"); |
|
36 |
nameCompleteList.add("Boccardi redeki"); |
|
37 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
38 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
39 |
nameCompleteList.add("Cercopagis pengoi"); |
|
40 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
41 |
|
|
42 |
|
|
43 |
ci = new ServiceProviderInfo(Species2000ColClient.ID, |
|
44 |
Species2000ColClient.LABEL, |
|
45 |
Species2000ColClient.URL, |
|
46 |
Species2000ColClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
47 |
} |
|
48 |
|
|
49 |
@Test |
|
50 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
51 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
52 |
System.out.println("Json : " + checklistInfoJson); |
|
53 |
} |
|
54 |
|
|
55 |
@Test |
|
56 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
57 |
parser = new DRFCSVInputParser(); |
|
58 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
59 |
|
|
60 |
Species2000ColClient scc = new Species2000ColClient(); |
|
61 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
62 |
while(tnrMsgItr.hasNext()) { |
|
63 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
64 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
65 |
scc.queryChecklist(tnrMsg); |
|
66 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
67 |
System.out.println(outputXML); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
71 |
|
src/test/java/org/bgbm/biovel/drf/checklist/WoRMSClientTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.checklist; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
import java.util.logging.Level; |
|
7 |
import java.util.logging.Logger; |
|
8 |
|
|
9 |
import javax.xml.bind.JAXBException; |
|
10 |
|
|
11 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
12 |
import org.bgbm.biovel.drf.checklist.PESIClient; |
|
13 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
14 |
import org.bgbm.biovel.drf.checklist.Species2000ColClient; |
|
15 |
import org.bgbm.biovel.drf.checklist.WoRMSClient; |
|
16 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
17 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
18 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
19 |
import org.bgbm.biovel.drf.tnr.msg.TnrMsg; |
|
20 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
21 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
22 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
23 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
24 |
import org.junit.BeforeClass; |
|
25 |
import org.junit.Test; |
|
26 |
|
|
27 |
public class WoRMSClientTest { |
|
28 |
private static final Logger logger = Logger.getLogger(WoRMSClientTest.class.getName()); |
|
29 |
private static DRFCSVInputParser parser; |
|
30 |
private static List<String> nameCompleteList; |
|
31 |
|
|
32 |
private static ServiceProviderInfo ci; |
|
33 |
|
|
34 |
@BeforeClass |
|
35 |
public static void setup() { |
|
36 |
|
|
37 |
logger.setLevel(Level.INFO); |
|
38 |
parser = new DRFCSVInputParser(); |
|
39 |
|
|
40 |
nameCompleteList = new ArrayList<String>(); |
|
41 |
nameCompleteList.add("Ameira divagans"); |
|
42 |
nameCompleteList.add("Boccardi redeki"); |
|
43 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
44 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
45 |
nameCompleteList.add("Cercopagis pengoi"); |
|
46 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
47 |
|
|
48 |
|
|
49 |
ci = new ServiceProviderInfo(WoRMSClient.ID, |
|
50 |
WoRMSClient.LABEL, |
|
51 |
WoRMSClient.URL, |
|
52 |
WoRMSClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
53 |
} |
|
54 |
|
|
55 |
@Test |
|
56 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
57 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
58 |
logger.info("ChecklistInfo : " + checklistInfoJson); |
|
59 |
} |
|
60 |
|
|
61 |
@Test |
|
62 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
63 |
parser = new DRFCSVInputParser(); |
|
64 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
65 |
|
|
66 |
WoRMSClient wormsc = new WoRMSClient(); |
|
67 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
68 |
while(tnrMsgItr.hasNext()) { |
|
69 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
70 |
logger.info("Querying WoRMS for name : " + tnrMsg.getQuery().get(0).getRequest().getQueryString()); |
|
71 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
72 |
wormsc.queryChecklist(tnrMsg); |
|
73 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
74 |
logger.info(outputXML); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
@Test |
|
79 |
public void resolveScientificNamesLikeTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
80 |
|
|
81 |
parser = new DRFCSVInputParser(); |
|
82 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
83 |
|
|
84 |
WoRMSClient wormsc = new WoRMSClient(); |
|
85 |
// strip off the last to characters of the names since we will do a like query |
|
86 |
for (TnrMsg tnrMsg : tnrMsgs) { |
|
87 |
String name = tnrMsg.getQuery().get(0).getRequest().getQueryString(); |
|
88 |
tnrMsg.getQuery().get(0).getRequest().setSearchMode(SearchMode.scientificNameExact.toString()); |
|
89 |
String nameTrunk = name.substring(0, name.length() - 2); |
|
90 |
logger.info("Querying WoRMS for name : " + nameTrunk); |
|
91 |
|
|
92 |
tnrMsg.getQuery().get(0).getRequest().setQueryString(nameTrunk); |
|
93 |
wormsc.resolveScientificNamesLike(tnrMsg); |
|
94 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
95 |
logger.info(outputXML); |
|
96 |
} |
|
97 |
|
|
98 |
} |
|
99 |
} |
|
100 |
|
src/test/java/org/bgbm/biovel/drf/tnr/msg/BgbmEditChecklistTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.tnr.msg; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import javax.xml.bind.JAXBException; |
|
7 |
|
|
8 |
import org.bgbm.biovel.drf.checklist.BgbmEditClient; |
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
11 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
12 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
13 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
14 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
15 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
16 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
17 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
18 |
import org.junit.BeforeClass; |
|
19 |
import org.junit.Test; |
|
20 |
|
|
21 |
public class BgbmEditChecklistTest { |
|
22 |
|
|
23 |
private static DRFCSVInputParser parser; |
|
24 |
private static List<String> nameCompleteList; |
|
25 |
|
|
26 |
private static ServiceProviderInfo ci; |
|
27 |
|
|
28 |
@BeforeClass |
|
29 |
public static void setup() { |
|
30 |
parser = new DRFCSVInputParser(); |
|
31 |
|
|
32 |
nameCompleteList = new ArrayList<String>(); |
|
33 |
nameCompleteList.add("Ameira divagans"); |
|
34 |
nameCompleteList.add("Boccardi redeki"); |
|
35 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
36 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
37 |
nameCompleteList.add("Cercopagis pengoi"); |
|
38 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
39 |
|
|
40 |
|
|
41 |
ci = new ServiceProviderInfo(BgbmEditClient.ID, |
|
42 |
BgbmEditClient.LABEL, |
|
43 |
BgbmEditClient.DOC_URL, |
|
44 |
BgbmEditClient.COPYRIGHT_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
45 |
ci.addSubChecklist(new ServiceProviderInfo("col", |
|
46 |
"EDIT - Catalogue Of Life", |
|
47 |
"http://wp5.e-taxonomy.eu/cdmlib/rest-api-name-catalogue.html", |
|
48 |
"http://www.catalogueoflife.org/col/info/copyright", ServiceProviderInfo.DEFAULT_SEARCH_MODE)); |
|
49 |
} |
|
50 |
|
|
51 |
@Test |
|
52 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
53 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
54 |
System.out.println("Json : " + checklistInfoJson); |
|
55 |
} |
|
56 |
|
|
57 |
@Test |
|
58 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
59 |
parser = new DRFCSVInputParser(); |
|
60 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/vibrant.csv","UTF-8")); |
|
61 |
//List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
62 |
TnrMsg tnrMsg = TnrMsgUtils.mergeTnrMsgs(tnrMsgs); |
|
63 |
String json = JSONUtils.convertObjectToJson(ci); |
|
64 |
BgbmEditClient bec = new BgbmEditClient(json); |
|
65 |
|
|
66 |
|
|
67 |
for(Query query : tnrMsg.getQuery()) { |
|
68 |
query.getRequest().setSearchMode(SearchMode.scientificNameExact.toString()); |
|
69 |
} |
|
70 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
71 |
bec.queryChecklist(tnrMsg); |
|
72 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
73 |
System.out.println(outputXML); |
|
74 |
} |
|
75 |
} |
src/test/java/org/bgbm/biovel/drf/tnr/msg/ChecklistTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.tnr.msg; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
8 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
9 |
import org.bgbm.biovel.drf.utils.ServiceProviderInfoUtils; |
|
10 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
11 |
import org.junit.BeforeClass; |
|
12 |
import org.junit.Test; |
|
13 |
|
|
14 |
public class ChecklistTest { |
|
15 |
|
|
16 |
@BeforeClass |
|
17 |
public static void setup() { |
|
18 |
} |
|
19 |
|
|
20 |
@Test |
|
21 |
public void generateChecklistInfoList() throws DRFChecklistException { |
|
22 |
String checklistInfoListJson = ServiceProviderInfoUtils.generateChecklistInfoListAsJson(); |
|
23 |
System.out.println("Json : " + checklistInfoListJson); |
|
24 |
} |
|
25 |
|
|
26 |
@Test |
|
27 |
public void generateChecklistInfoListFromStringArray() throws DRFChecklistException { |
|
28 |
List<String> ciList = new ArrayList<String>(); |
|
29 |
ciList.add("species2000col;species2000col;Species2000 - Catalogue Of Life;http://www.catalogueoflife.org;http://www.catalogueoflife.org/col/info/copyright"); |
|
30 |
ciList.add("edit;col;EDIT - Catalogue Of Life;http://wp5.e-taxonomy.eu/cdmlib/rest-api-name-catalogue.html;http://www.catalogueoflife.org/col/info/copyright"); |
|
31 |
ciList.add("gbif;1028;Afromoths, online datbase of Afrotropical moth species (Lepidoptera);http://ecat-dev.gbif.org/checklist/1028;"); |
|
32 |
ciList.add("gbif;1000;Afromoths, online datbase of Afrotropical moth species (Lepidoptera);http://ecat-dev.gbif.org/checklist/1000;"); |
|
33 |
|
|
34 |
List<ServiceProviderInfo> ciInfoList = ServiceProviderInfoUtils.convertStringToChecklistInfo(ciList); |
|
35 |
Iterator<ServiceProviderInfo> ciInfoItr = ciInfoList.iterator(); |
|
36 |
while(ciInfoItr.hasNext()) { |
|
37 |
System.out.println(JSONUtils.convertObjectToJson(ciInfoItr.next())); |
|
38 |
} |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
|
|
43 |
} |
|
44 |
|
src/test/java/org/bgbm/biovel/drf/tnr/msg/GBIFBetaChecklistTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.tnr.msg; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.xml.bind.JAXBException; |
|
8 |
|
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.GBIFBetaBackboneClient; |
|
11 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
12 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
13 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
14 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
15 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
16 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
17 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
18 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
19 |
import org.junit.BeforeClass; |
|
20 |
import org.junit.Ignore; |
|
21 |
import org.junit.Test; |
|
22 |
|
|
23 |
@Ignore |
|
24 |
public class GBIFBetaChecklistTest { |
|
25 |
|
|
26 |
private static DRFCSVInputParser parser; |
|
27 |
private static List<String> nameCompleteList; |
|
28 |
|
|
29 |
private static ServiceProviderInfo ci; |
|
30 |
|
|
31 |
@BeforeClass |
|
32 |
public static void setup() { |
|
33 |
parser = new DRFCSVInputParser(); |
|
34 |
|
|
35 |
nameCompleteList = new ArrayList<String>(); |
|
36 |
nameCompleteList.add("Ameira divagans"); |
|
37 |
nameCompleteList.add("Boccardi redeki"); |
|
38 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
39 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
40 |
nameCompleteList.add("Cercopagis pengoi"); |
|
41 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
42 |
|
|
43 |
|
|
44 |
ci = new ServiceProviderInfo(GBIFBetaBackboneClient.ID, |
|
45 |
GBIFBetaBackboneClient.LABEL, |
|
46 |
GBIFBetaBackboneClient.URL, |
|
47 |
GBIFBetaBackboneClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
48 |
ci.addSubChecklist(new ServiceProviderInfo("1", "GBIF NUB Taxonomy", "http://ecat-dev.gbif.org/checklist/1")); |
|
49 |
} |
|
50 |
|
|
51 |
@Test |
|
52 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
53 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
54 |
System.out.println("Json : " + checklistInfoJson); |
|
55 |
} |
|
56 |
|
|
57 |
@Test |
|
58 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
59 |
parser = new DRFCSVInputParser(); |
|
60 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
61 |
//List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/singleNameCompleteOnly.csv","UTF-8")); |
|
62 |
|
|
63 |
|
|
64 |
GBIFBetaBackboneClient gbbc = new GBIFBetaBackboneClient(JSONUtils.convertObjectToJson(ci)); |
|
65 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
66 |
while(tnrMsgItr.hasNext()) { |
|
67 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
68 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
69 |
gbbc.queryChecklist(tnrMsg); |
|
70 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
71 |
System.out.println(outputXML); |
|
72 |
} |
|
73 |
} |
|
74 |
} |
|
75 |
|
src/test/java/org/bgbm/biovel/drf/tnr/msg/GBIFChecklistTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.tnr.msg; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.xml.bind.JAXBException; |
|
8 |
|
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.GBIFBackboneClient; |
|
11 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
12 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
13 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
14 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
15 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
16 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
17 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
18 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
19 |
import org.junit.BeforeClass; |
|
20 |
import org.junit.Test; |
|
21 |
|
|
22 |
//@Ignore |
|
23 |
public class GBIFChecklistTest { |
|
24 |
|
|
25 |
private static DRFCSVInputParser parser; |
|
26 |
private static List<String> nameCompleteList; |
|
27 |
|
|
28 |
private static ServiceProviderInfo ci; |
|
29 |
|
|
30 |
@BeforeClass |
|
31 |
public static void setup() { |
|
32 |
parser = new DRFCSVInputParser(); |
|
33 |
|
|
34 |
nameCompleteList = new ArrayList<String>(); |
|
35 |
nameCompleteList.add("Ameira divagans"); |
|
36 |
nameCompleteList.add("Boccardiella ligerica"); |
|
37 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
38 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
39 |
nameCompleteList.add("Cercopagis pengoi"); |
|
40 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
41 |
|
|
42 |
ci = new ServiceProviderInfo(GBIFBackboneClient.ID, |
|
43 |
GBIFBackboneClient.LABEL, |
|
44 |
GBIFBackboneClient.URL, |
|
45 |
GBIFBackboneClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
46 |
ci.addSubChecklist(new ServiceProviderInfo("d7dddbf4-2cf0-4f39-9b2a-bb099caae36c", "GBIF NUB Taxonomy", "http://uat.gbif.org/dataset/d7dddbf4-2cf0-4f39-9b2a-bb099caae36c")); |
|
47 |
} |
|
48 |
|
|
49 |
@Test |
|
50 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
51 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
52 |
System.out.println("Json : " + checklistInfoJson); |
|
53 |
} |
|
54 |
|
|
55 |
@Test |
|
56 |
public void buildServiceProviderInfo() throws DRFChecklistException { |
|
57 |
GBIFBackboneClient gbc = new GBIFBackboneClient(); |
|
58 |
ServiceProviderInfo spiInfo = gbc.buildServiceProviderInfo(); |
|
59 |
List<ServiceProviderInfo> spiList = spiInfo.getSubChecklists(); |
|
60 |
Iterator<ServiceProviderInfo> spiItr = spiList.iterator(); |
|
61 |
while(spiItr.hasNext()) { |
|
62 |
ServiceProviderInfo spi = spiItr.next(); |
|
63 |
System.out.println("Dataset : " + spi.getLabel() ); |
|
64 |
} |
|
65 |
String checklistInfoJson = JSONUtils.convertObjectToJson(spiInfo); |
|
66 |
System.out.println("Json : " + checklistInfoJson); |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
@Test |
|
71 |
public void nameCompleteCsvTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
72 |
parser = new DRFCSVInputParser(); |
|
73 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
74 |
//List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/singleNameCompleteOnly.csv","UTF-8")); |
|
75 |
List<String> chosenKeyList = new ArrayList<String>(); |
|
76 |
chosenKeyList.add("7ddf754f-d193-4cc9-b351-99906754a03b"); |
|
77 |
|
|
78 |
GBIFBackboneClient gbc = new GBIFBackboneClient(JSONUtils.convertObjectToJson(ci)); |
|
79 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
80 |
while(tnrMsgItr.hasNext()) { |
|
81 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
82 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
83 |
gbc.queryChecklist(tnrMsg); |
|
84 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
85 |
System.out.println(outputXML); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
@Test |
|
90 |
public void nameCompleteStringListTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
91 |
parser = new DRFCSVInputParser(); |
|
92 |
List<TnrMsg> tnrMsgs = TnrMsgUtils.convertStringListToTnrMsgList(nameCompleteList, SearchMode.scientificNameExact, false); |
|
93 |
//List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/singleNameCompleteOnly.csv","UTF-8")); |
|
94 |
List<String> chosenKeyList = new ArrayList<String>(); |
|
95 |
chosenKeyList.add("7ddf754f-d193-4cc9-b351-99906754a03b"); |
|
96 |
|
|
97 |
GBIFBackboneClient gbc = new GBIFBackboneClient(JSONUtils.convertObjectToJson(ci)); |
|
98 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
99 |
while(tnrMsgItr.hasNext()) { |
|
100 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
101 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
102 |
gbc.queryChecklist(tnrMsg); |
|
103 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
104 |
System.out.println(outputXML); |
|
105 |
} |
|
106 |
} |
|
107 |
} |
src/test/java/org/bgbm/biovel/drf/tnr/msg/PESIClientTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.tnr.msg; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.xml.bind.JAXBException; |
|
8 |
|
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.PESIClient; |
|
11 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
12 |
import org.bgbm.biovel.drf.checklist.Species2000ColClient; |
|
13 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
14 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
15 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
16 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
17 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
18 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
19 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
20 |
import org.junit.BeforeClass; |
|
21 |
import org.junit.Test; |
|
22 |
|
|
23 |
public class PESIClientTest { |
|
24 |
|
|
25 |
private static DRFCSVInputParser parser; |
|
26 |
private static List<String> nameCompleteList; |
|
27 |
|
|
28 |
private static ServiceProviderInfo ci; |
|
29 |
|
|
30 |
@BeforeClass |
|
31 |
public static void setup() { |
|
32 |
parser = new DRFCSVInputParser(); |
|
33 |
|
|
34 |
nameCompleteList = new ArrayList<String>(); |
|
35 |
nameCompleteList.add("Ameira divagans"); |
|
36 |
nameCompleteList.add("Boccardi redeki"); |
|
37 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
38 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
39 |
nameCompleteList.add("Cercopagis pengoi"); |
|
40 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
41 |
|
|
42 |
|
|
43 |
ci = new ServiceProviderInfo(Species2000ColClient.ID, |
|
44 |
Species2000ColClient.LABEL, |
|
45 |
Species2000ColClient.URL, |
|
46 |
Species2000ColClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
47 |
} |
|
48 |
|
|
49 |
@Test |
|
50 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
51 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
52 |
System.out.println("Json : " + checklistInfoJson); |
|
53 |
} |
|
54 |
|
|
55 |
@Test |
|
56 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
57 |
parser = new DRFCSVInputParser(); |
|
58 |
//List<String> inputXMLList = parser.parseToXML(BiovelUtils.getCSVAsString("org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
59 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
60 |
// List<String> chosenKeyList = new ArrayList<String>(); |
|
61 |
// chosenKeyList.add("d7dddbf4-2cf0-4f39-9b2a-bb099caae36c"); |
|
62 |
|
|
63 |
PESIClient pesic = new PESIClient(); |
|
64 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
65 |
while(tnrMsgItr.hasNext()) { |
|
66 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
67 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
68 |
pesic.queryChecklist(tnrMsg); |
|
69 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
70 |
System.out.println(outputXML); |
|
71 |
} |
|
72 |
} |
|
73 |
} |
|
74 |
|
src/test/java/org/bgbm/biovel/drf/tnr/msg/Species2000ColClientTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.tnr.msg; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.xml.bind.JAXBException; |
|
8 |
|
|
9 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
10 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
11 |
import org.bgbm.biovel.drf.checklist.Species2000ColClient; |
|
12 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
13 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
14 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
15 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
16 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
17 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
18 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
19 |
import org.junit.BeforeClass; |
|
20 |
import org.junit.Test; |
|
21 |
|
|
22 |
public class Species2000ColClientTest { |
|
23 |
|
|
24 |
private static DRFCSVInputParser parser; |
|
25 |
private static List<String> nameCompleteList; |
|
26 |
|
|
27 |
private static ServiceProviderInfo ci; |
|
28 |
|
|
29 |
@BeforeClass |
|
30 |
public static void setup() { |
|
31 |
parser = new DRFCSVInputParser(); |
|
32 |
|
|
33 |
nameCompleteList = new ArrayList<String>(); |
|
34 |
nameCompleteList.add("Ameira divagans"); |
|
35 |
nameCompleteList.add("Boccardi redeki"); |
|
36 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
37 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
38 |
nameCompleteList.add("Cercopagis pengoi"); |
|
39 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
40 |
|
|
41 |
|
|
42 |
ci = new ServiceProviderInfo(Species2000ColClient.ID, |
|
43 |
Species2000ColClient.LABEL, |
|
44 |
Species2000ColClient.URL, |
|
45 |
Species2000ColClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
46 |
} |
|
47 |
|
|
48 |
@Test |
|
49 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
50 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
51 |
System.out.println("Json : " + checklistInfoJson); |
|
52 |
} |
|
53 |
|
|
54 |
@Test |
|
55 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
56 |
parser = new DRFCSVInputParser(); |
|
57 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
58 |
|
|
59 |
Species2000ColClient scc = new Species2000ColClient(); |
|
60 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
61 |
while(tnrMsgItr.hasNext()) { |
|
62 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
63 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
64 |
scc.queryChecklist(tnrMsg); |
|
65 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
66 |
System.out.println(outputXML); |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
70 |
|
src/test/java/org/bgbm/biovel/drf/tnr/msg/WoRMSClientTest.java | ||
---|---|---|
1 |
package org.bgbm.biovel.drf.tnr.msg; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Iterator; |
|
5 |
import java.util.List; |
|
6 |
import java.util.logging.Level; |
|
7 |
import java.util.logging.Logger; |
|
8 |
|
|
9 |
import javax.xml.bind.JAXBException; |
|
10 |
|
|
11 |
import org.bgbm.biovel.drf.checklist.DRFChecklistException; |
|
12 |
import org.bgbm.biovel.drf.checklist.PESIClient; |
|
13 |
import org.bgbm.biovel.drf.checklist.SearchMode; |
|
14 |
import org.bgbm.biovel.drf.checklist.Species2000ColClient; |
|
15 |
import org.bgbm.biovel.drf.checklist.WoRMSClient; |
|
16 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
17 |
import org.bgbm.biovel.drf.input.DRFCSVInputParser; |
|
18 |
import org.bgbm.biovel.drf.input.DRFInputException; |
|
19 |
import org.bgbm.biovel.drf.utils.BiovelUtils; |
|
20 |
import org.bgbm.biovel.drf.utils.JSONUtils; |
|
21 |
import org.bgbm.biovel.drf.utils.TnrMsgException; |
|
22 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils; |
|
23 |
import org.junit.BeforeClass; |
|
24 |
import org.junit.Test; |
|
25 |
|
|
26 |
public class WoRMSClientTest { |
|
27 |
private static final Logger logger = Logger.getLogger(WoRMSClientTest.class.getName()); |
|
28 |
private static DRFCSVInputParser parser; |
|
29 |
private static List<String> nameCompleteList; |
|
30 |
|
|
31 |
private static ServiceProviderInfo ci; |
|
32 |
|
|
33 |
@BeforeClass |
|
34 |
public static void setup() { |
|
35 |
|
|
36 |
logger.setLevel(Level.INFO); |
|
37 |
parser = new DRFCSVInputParser(); |
|
38 |
|
|
39 |
nameCompleteList = new ArrayList<String>(); |
|
40 |
nameCompleteList.add("Ameira divagans"); |
|
41 |
nameCompleteList.add("Boccardi redeki"); |
|
42 |
nameCompleteList.add("Bougainvillia rugosa"); |
|
43 |
nameCompleteList.add("Branchiura sowerbyi"); |
|
44 |
nameCompleteList.add("Cercopagis pengoi"); |
|
45 |
nameCompleteList.add("Chelicorophium curvispinum"); |
|
46 |
|
|
47 |
|
|
48 |
ci = new ServiceProviderInfo(WoRMSClient.ID, |
|
49 |
WoRMSClient.LABEL, |
|
50 |
WoRMSClient.URL, |
|
51 |
WoRMSClient.DATA_AGR_URL, ServiceProviderInfo.DEFAULT_SEARCH_MODE); |
|
52 |
} |
|
53 |
|
|
54 |
@Test |
|
55 |
public void convertChecklistInfoToJson() throws DRFChecklistException { |
|
56 |
String checklistInfoJson = JSONUtils.convertObjectToJson(ci); |
|
57 |
logger.info("ChecklistInfo : " + checklistInfoJson); |
|
58 |
} |
|
59 |
|
|
60 |
@Test |
|
61 |
public void nameCompleteTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
62 |
parser = new DRFCSVInputParser(); |
|
63 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
64 |
|
|
65 |
WoRMSClient wormsc = new WoRMSClient(); |
|
66 |
Iterator<TnrMsg> tnrMsgItr = tnrMsgs.iterator(); |
|
67 |
while(tnrMsgItr.hasNext()) { |
|
68 |
TnrMsg tnrMsg = tnrMsgItr.next(); |
|
69 |
logger.info("Querying WoRMS for name : " + tnrMsg.getQuery().get(0).getRequest().getQueryString()); |
|
70 |
TnrMsgUtils.updateWithSearchMode(tnrMsg, SearchMode.scientificNameExact); |
|
71 |
wormsc.queryChecklist(tnrMsg); |
|
72 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
73 |
logger.info(outputXML); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
@Test |
|
78 |
public void resolveScientificNamesLikeTest() throws DRFChecklistException, DRFInputException, JAXBException, TnrMsgException { |
|
79 |
|
|
80 |
parser = new DRFCSVInputParser(); |
|
81 |
List<TnrMsg> tnrMsgs = parser.parse(BiovelUtils.getResourceAsString("/org/bgbm/biovel/drf/tnr/nameCompleteOnly.csv","UTF-8")); |
|
82 |
|
|
83 |
WoRMSClient wormsc = new WoRMSClient(); |
|
84 |
// strip off the last to characters of the names since we will do a like query |
|
85 |
for (TnrMsg tnrMsg : tnrMsgs) { |
|
86 |
String name = tnrMsg.getQuery().get(0).getRequest().getQueryString(); |
|
87 |
tnrMsg.getQuery().get(0).getRequest().setSearchMode(SearchMode.scientificNameExact.toString()); |
|
88 |
String nameTrunk = name.substring(0, name.length() - 2); |
|
89 |
logger.info("Querying WoRMS for name : " + nameTrunk); |
|
90 |
|
|
91 |
tnrMsg.getQuery().get(0).getRequest().setQueryString(nameTrunk); |
|
92 |
wormsc.resolveScientificNamesLike(tnrMsg); |
|
93 |
String outputXML = TnrMsgUtils.convertTnrMsgToXML(tnrMsg); |
|
94 |
logger.info(outputXML); |
|
95 |
} |
|
96 |
|
|
97 |
} |
|
98 |
} |
|
99 |
|
Also available in: Unified diff
moving checklist tests in own package