Revision 61055
Added by Alessia Bardi almost 3 years ago
RestIteratorTest.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package eu.dnetlib.data.collector.plugins.rest; |
5 | 5 |
|
6 |
import com.google.common.collect.Maps; |
|
7 |
import org.junit.Before; |
|
6 | 8 |
import org.junit.Ignore; |
7 | 9 |
import org.junit.Test; |
8 | 10 |
|
11 |
import java.util.Map; |
|
12 |
|
|
9 | 13 |
/** |
10 | 14 |
* |
11 | 15 |
* @author js, Andreas Czerniak |
... | ... | |
28 | 32 |
// private String resultOffsetParam = "cursor"; |
29 | 33 |
// private String query = "q=%28sources%3ASocArXiv+AND+type%3Apreprint%29"; |
30 | 34 |
|
31 |
private String baseUrl = "https://etl.ptcris.pt/services/searches/projects"; |
|
32 |
private String resumptionType = "page"; |
|
33 |
private String resumptionParam = "page"; |
|
34 |
private String resumptionXpath = ""; |
|
35 |
private String resultTotalXpath = "//*[local-name()='paging']/*[local-name()='maxPages']"; |
|
36 |
private String entityXpath = "//*[local-name()='ListRecords']/*[local-name()='record']"; |
|
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 |
|
|
37 | 58 |
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"; |
|
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 |
|
|
45 | 74 |
@Ignore |
46 | 75 |
@Test |
47 | 76 |
public void test(){ |
48 |
final RestIterator iterator = new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, resultSizeValue, query, entityXpath, authMethod, authToken, resultOffsetParam, null); |
|
77 |
final RestIterator iterator = new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, |
|
78 |
resultSizeValue, query, entityXpath, authMethod, authToken, resultOutputFormat, requestHeader); |
|
49 | 79 |
int i =20; |
50 | 80 |
while (iterator.hasNext() && i > 0) { |
51 | 81 |
String result = iterator.next(); |
Also available in: Unified diff
#6720: added tests for enermaps API