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