Project

General

Profile

1
/**
2
 * 
3
 */
4
package eu.dnetlib.data.collector.plugins.rest;
5

    
6
import org.junit.Ignore;
7
import org.junit.Test;
8

    
9
/**
10
 * 
11
 * @author js, Andreas Czerniak
12
 * @date 2020-04-08
13
 */
14
public class RestIteratorTest {
15

    
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";
34
	private String resumptionXpath = "";
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";
45
	@Ignore
46
	@Test
47
	public void test(){
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);
50
		int i =20;
51
		while (iterator.hasNext() && i > 0) {
52
			String result = iterator.next();
53
			System.out.println(result);
54
			i--;
55
		}
56
	}
57
}
58

    
(2-2/2)