Revision 60372
Added by Miriam Baglioni about 3 years ago
modules/dnet-collector-plugins/trunk/src/test/java/eu/dnetlib/data/collector/plugins/rest/RestIteratorTest.java | ||
---|---|---|
13 | 13 |
*/ |
14 | 14 |
public class RestIteratorTest { |
15 | 15 |
|
16 |
private String baseUrl = "https://share.osf.io/api/v2/search/creativeworks/_search"; |
|
17 |
private String resumptionType = "count"; |
|
18 |
private String resumptionParam = "from"; |
|
16 |
// private String baseUrl = "https://share.osf.io/api/v2/search/creativeworks/_search"; |
|
17 |
// private String resumptionType = "count"; |
|
18 |
// private String resumptionParam = "from"; |
|
19 |
// private String resumptionXpath = ""; |
|
20 |
// private String resultTotalXpath = "//hits/total"; |
|
21 |
// private String entityXpath = "//hits/hits"; |
|
22 |
// private String resultFormatParam = "format"; |
|
23 |
// private String resultFormatValue = "Json"; // Change from lowerCase to one UpperCase |
|
24 |
// private String resultSizeParam = "size"; |
|
25 |
// private String resultSizeValue = "10"; |
|
26 |
// private String authMethod = ""; |
|
27 |
// private String authToken = ""; |
|
28 |
// private String resultOffsetParam = "cursor"; |
|
29 |
// private String query = "q=%28sources%3ASocArXiv+AND+type%3Apreprint%29"; |
|
30 |
|
|
31 |
private String baseUrl = "https://etl.ptcris.pt/services/searches/projects"; |
|
32 |
private String resumptionType = "page"; |
|
33 |
private String resumptionParam = "page"; |
|
19 | 34 |
private String resumptionXpath = ""; |
20 |
private String resultTotalXpath = "//hits/total"; |
|
21 |
private String entityXpath = "//hits/hits"; |
|
22 |
private String resultFormatParam = "format"; |
|
23 |
private String resultFormatValue = "Json"; // Change from lowerCase to one UpperCase |
|
24 |
private String resultSizeParam = "size"; |
|
25 |
private String resultSizeValue = "10"; |
|
26 |
private String authMethod = ""; |
|
27 |
private String authToken = ""; |
|
28 |
private String resultOffsetParam = "cursor"; |
|
29 |
private String query = "q=%28sources%3ASocArXiv+AND+type%3Apreprint%29"; |
|
30 |
|
|
31 |
|
|
35 |
private String resultTotalXpath = "//*[local-name()='paging']/*[local-name()='maxPages']"; |
|
36 |
private String entityXpath = "//*[local-name()='ListRecords']/*[local-name()='record']"; |
|
37 |
private String resultFormatParam = ""; |
|
38 |
private String resultFormatValue = "xml"; // Change from lowerCase to one UpperCase |
|
39 |
private String resultSizeParam = "recordsPerPage"; |
|
40 |
private String resultSizeValue = "100"; |
|
41 |
private String authMethod = "basic"; |
|
42 |
private String authToken = "T1BFTkFJUkVfQURNSU46NC01ITM1NkZNOQ=="; |
|
43 |
private String resultOffsetParam = ""; |
|
44 |
private String query = "startDateFrom=2019-01-01&startDateTo=2019-12-31&pagination=true"; |
|
32 | 45 |
@Ignore |
33 | 46 |
@Test |
34 | 47 |
public void test(){ |
35 |
final RestIterator iterator = new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, resultSizeValue, query, entityXpath, authMethod, authToken, resultOffsetParam); |
|
48 |
//final RestIterator iterator = new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, resultSizeValue, query, entityXpath, authMethod, authToken, resultOffsetParam); |
|
49 |
final RestIterator iterator = new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, resultSizeValue, query, entityXpath, authMethod, authToken); |
|
36 | 50 |
int i =20; |
37 | 51 |
while (iterator.hasNext() && i > 0) { |
38 | 52 |
String result = iterator.next(); |
39 |
|
|
53 |
System.out.println(result); |
|
40 | 54 |
i--; |
41 | 55 |
} |
42 | 56 |
} |
Also available in: Unified diff
changed properties value for FCT REST api