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
|
|