2021-03-08 09:44:09 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
package eu.dnetlib.dhp.collection.plugin.rest;
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Disabled;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import eu.dnetlib.dhp.collection.HttpClientParams;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author js, Andreas Czerniak
|
|
|
|
* @date 2020-04-08
|
|
|
|
*/
|
|
|
|
public class RestIteratorTest {
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(RestIteratorTest.class);
|
|
|
|
|
2021-05-14 10:58:12 +02:00
|
|
|
private final String baseUrl = "https://share.osf.io/api/v2/search/creativeworks/_search";
|
|
|
|
private final String resumptionType = "count";
|
|
|
|
private final String resumptionParam = "from";
|
|
|
|
private final String resumptionXpath = "";
|
|
|
|
private final String resultTotalXpath = "//hits/total";
|
|
|
|
private final String entityXpath = "//hits/hits";
|
|
|
|
private final String resultFormatParam = "format";
|
|
|
|
private final String resultFormatValue = "Json"; // Change from lowerCase to one UpperCase
|
|
|
|
private final String resultSizeParam = "size";
|
|
|
|
private final String resultSizeValue = "10";
|
|
|
|
private final String authMethod = "";
|
|
|
|
private final String authToken = "";
|
|
|
|
private final String resultOffsetParam = "cursor";
|
|
|
|
private final String query = "q=%28sources%3ASocArXiv+AND+type%3Apreprint%29";
|
2021-03-08 09:44:09 +01:00
|
|
|
|
|
|
|
@Disabled
|
|
|
|
@Test
|
|
|
|
public void test() {
|
|
|
|
|
|
|
|
HttpClientParams clientParams = new HttpClientParams();
|
|
|
|
|
|
|
|
final RestIterator iterator = new RestIterator(clientParams, baseUrl, resumptionType, resumptionParam,
|
|
|
|
resumptionXpath, resultTotalXpath, resultFormatParam, resultFormatValue, resultSizeParam, resultSizeValue,
|
|
|
|
query, entityXpath, authMethod, authToken, resultOffsetParam);
|
|
|
|
int i = 20;
|
|
|
|
while (iterator.hasNext() && i > 0) {
|
|
|
|
String result = iterator.next();
|
|
|
|
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|