1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.dnetlib.data.collector.plugins.rest;
|
5
|
|
6
|
import com.google.common.collect.Maps;
|
7
|
import org.junit.Before;
|
8
|
import org.junit.Ignore;
|
9
|
import org.junit.Test;
|
10
|
|
11
|
import java.util.Map;
|
12
|
|
13
|
/**
|
14
|
*
|
15
|
* @author js, Andreas Czerniak
|
16
|
* @date 2020-04-08
|
17
|
*/
|
18
|
public class RestIteratorTest {
|
19
|
|
20
|
// private String baseUrl = "https://share.osf.io/api/v2/search/creativeworks/_search";
|
21
|
// private String resumptionType = "count";
|
22
|
// private String resumptionParam = "from";
|
23
|
// private String resumptionXpath = "";
|
24
|
// private String resultTotalXpath = "//hits/total";
|
25
|
// private String entityXpath = "//hits/hits";
|
26
|
// private String resultFormatParam = "format";
|
27
|
// private String resultFormatValue = "Json"; // Change from lowerCase to one UpperCase
|
28
|
// private String resultSizeParam = "size";
|
29
|
// private String resultSizeValue = "10";
|
30
|
// private String authMethod = "";
|
31
|
// private String authToken = "";
|
32
|
// private String resultOffsetParam = "cursor";
|
33
|
// private String query = "q=%28sources%3ASocArXiv+AND+type%3Apreprint%29";
|
34
|
|
35
|
// private String baseUrl = "https://etl.ptcris.pt/services/searches/projects";
|
36
|
// private String resumptionType = "page";
|
37
|
// private String resumptionParam = "page";
|
38
|
// private String resumptionXpath = "";
|
39
|
// private String resultTotalXpath = "//*[local-name()='paging']/*[local-name()='maxPages']";
|
40
|
// private String entityXpath = "//*[local-name()='ListRecords']/*[local-name()='record']";
|
41
|
// private String resultFormatParam = "";
|
42
|
// private String resultFormatValue = "xml"; // Change from lowerCase to one UpperCase
|
43
|
// private String resultSizeParam = "recordsPerPage";
|
44
|
// private String resultSizeValue = "100";
|
45
|
// private String authMethod = "basic";
|
46
|
// private String authToken = "T1BFTkFJUkVfQURNSU46NC01ITM1NkZNOQ==";
|
47
|
// private String resultOffsetParam = "";
|
48
|
// private String query = "startDateFrom=2019-01-01&startDateTo=2019-12-31&pagination=true";
|
49
|
|
50
|
//config for Enermaps
|
51
|
private String baseUrl = "https://lab.idiap.ch/enermaps/api/datacite";
|
52
|
private String authMethod = "";
|
53
|
private String authToken = "";
|
54
|
private String entityXpath = "//data";
|
55
|
private String query = " ";
|
56
|
private Map<String, String> requestHeader = Maps.newHashMap();
|
57
|
|
58
|
private String resultFormatParam = "";
|
59
|
private String resultFormatValue = "json";
|
60
|
private String resultOutputFormat = "json";
|
61
|
private String resultSizeParam = "";
|
62
|
private String resultSizeValue = "50";
|
63
|
private String resultTotalXpath = "fake";
|
64
|
private String resumptionParam = "fake";
|
65
|
private String resumptionType = "discover";
|
66
|
private String resumptionXpath = "/fake";
|
67
|
private String idxpath = "//data/id";
|
68
|
|
69
|
@Before
|
70
|
public void setup(){
|
71
|
requestHeader.put("Accept", "application/vnd.pgrst.object+json");
|
72
|
}
|
73
|
|
74
|
@Ignore
|
75
|
@Test
|
76
|
public void test(){
|
77
|
final RestIterator iterator = new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam,
|
78
|
resultSizeValue, query, entityXpath, authMethod, authToken, resultOutputFormat, requestHeader);
|
79
|
int i =20;
|
80
|
while (iterator.hasNext() && i > 0) {
|
81
|
String result = iterator.next();
|
82
|
System.out.println(result);
|
83
|
i--;
|
84
|
}
|
85
|
}
|
86
|
}
|
87
|
|