Revision 62628
Added by Alessia Bardi over 1 year ago
RestIteratorTest.java | ||
---|---|---|
17 | 17 |
*/ |
18 | 18 |
public class RestIteratorTest { |
19 | 19 |
|
20 |
private Map<String, String> requestHeader = Maps.newHashMap(); |
|
21 |
|
|
20 | 22 |
// private String baseUrl = "https://share.osf.io/api/v2/search/creativeworks/_search"; |
21 | 23 |
// private String resumptionType = "count"; |
22 | 24 |
// private String resumptionParam = "from"; |
... | ... | |
48 | 50 |
// private String query = "startDateFrom=2019-01-01&startDateTo=2019-12-31&pagination=true"; |
49 | 51 |
|
50 | 52 |
//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(); |
|
53 |
// private String baseUrl = "https://lab.idiap.ch/enermaps/api/datacite"; |
|
54 |
// private String authMethod = ""; |
|
55 |
// private String authToken = ""; |
|
56 |
// private String entityXpath = "//data"; |
|
57 |
// private String query = " "; |
|
58 |
// |
|
59 |
// |
|
60 |
// private String resultFormatParam = ""; |
|
61 |
// private String resultFormatValue = "json"; |
|
62 |
// private String resultOutputFormat = "json"; |
|
63 |
// private String resultSizeParam = ""; |
|
64 |
// private String resultSizeValue = "50"; |
|
65 |
// private String resultTotalXpath = "fake"; |
|
66 |
// private String resumptionParam = "fake"; |
|
67 |
// private String resumptionType = "discover"; |
|
68 |
// private String resumptionXpath = "/fake"; |
|
69 |
// private String idxpath = "//data/id"; |
|
57 | 70 |
|
71 |
//config for d4science |
|
72 |
private String baseUrl = "https://api.d4science.org/catalogue/items"; |
|
73 |
private String resumptionType = "discover"; |
|
74 |
private String resumptionParam = "offset"; |
|
75 |
private String resumptionXpath = ""; |
|
76 |
private String resultTotalXpath = "//unused"; |
|
77 |
private String entityXpath = "//*[local-name()='data']"; |
|
58 | 78 |
private String resultFormatParam = ""; |
59 |
private String resultFormatValue = "json";
|
|
79 |
private String resultFormatValue = ""; // Change from lowerCase to one UpperCase
|
|
60 | 80 |
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"; |
|
81 |
private String resultSizeParam = "limit"; |
|
82 |
private String resultSizeValue = "10"; |
|
83 |
private String authMethod = "bearer"; |
|
84 |
private String authToken = "keep-me-secret" ; |
|
85 |
private String query = "all_fields=true"; |
|
68 | 86 |
|
87 |
|
|
88 |
|
|
69 | 89 |
@Before |
70 | 90 |
public void setup(){ |
71 |
requestHeader.put("Accept", "application/vnd.pgrst.object+json");
|
|
91 |
requestHeader.put("Accept", "application/vnd.api+json");
|
|
72 | 92 |
} |
73 | 93 |
|
74 | 94 |
@Ignore |
... | ... | |
76 | 96 |
public void test(){ |
77 | 97 |
final RestIterator iterator = new RestIterator(baseUrl, resumptionType, resumptionParam, resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, |
78 | 98 |
resultSizeValue, query, entityXpath, authMethod, authToken, resultOutputFormat, requestHeader); |
79 |
int i =20;
|
|
99 |
int i =50;
|
|
80 | 100 |
while (iterator.hasNext() && i > 0) { |
81 | 101 |
String result = iterator.next(); |
82 | 102 |
System.out.println(result); |
83 | 103 |
i--; |
84 | 104 |
} |
85 | 105 |
} |
106 |
|
|
107 |
|
|
86 | 108 |
} |
87 | 109 |
|
Also available in: Unified diff
Added config for testing collection from D4Science gCat REST API