Project

General

Profile

« Previous | Next » 

Revision 61055

#6720: added tests for enermaps API

View differences:

modules/dnet-collector-plugins/trunk/src/test/java/eu/dnetlib/data/collector/plugins/rest/RestCollectorPluginTest.java
4 4
package eu.dnetlib.data.collector.plugins.rest;
5 5

  
6 6
import java.util.HashMap;
7
import java.util.Map;
7 8

  
8 9
import org.junit.Assert;
9 10
import org.junit.Before;
......
22 23

  
23 24
	//Settings for FCT rest endpoint
24 25

  
25
	private String baseUrl = "https://etl.ptcris.pt/services/searches/projects";
26
	private String resumptionType = "page";
27
	private String resumptionParam = "page";
28
	private String resumptionXpath = "";
29
	private String resultTotalXpath = "//*[local-name()='paging']/*[local-name()='maxPages']";
30
	private String entityXpath = "//*[local-name()='ListRecords']/*[local-name()='record']";
31
	private String resultFormatParam = "";
32
	private String resultFormatValue = "xml";              //  Change from lowerCase to one UpperCase
33
	private String resultSizeParam = "recordsPerPage";
34
	private String resultSizeValue = "100";
35
	private String authMethod = "basic";
36
	private String authToken = "T1BFTkFJUkVfQURNSU46NC01ITM1NkZNOQ==";
37
	private String resultOffsetParam = "";
38
	private String query = "startDateFrom=1999-01-01&startDateTo=1999-12-31&pagination=true";
26
//	private String baseUrl = "https://etl.ptcris.pt/services/searches/projects";
27
//	private String resumptionType = "page";
28
//	private String resumptionParam = "page";
29
//	private String resumptionXpath = "";
30
//	private String resultTotalXpath = "//*[local-name()='paging']/*[local-name()='maxPages']";
31
//	private String entityXpath = "//*[local-name()='ListRecords']/*[local-name()='record']";
32
//	private String resultFormatParam = "";
33
//	private String resultFormatValue = "xml";              //  Change from lowerCase to one UpperCase
34
//	private String resultSizeParam = "recordsPerPage";
35
//	private String resultSizeValue = "100";
36
//	private String authMethod = "basic";
37
//	private String authToken = "T1BFTkFJUkVfQURNSU46NC01ITM1NkZNOQ==";
38
//	private String resultOffsetParam = "";
39
//	private String query = "startDateFrom=1999-01-01&startDateTo=1999-12-31&pagination=true";
40
//private String requestHeader = "";
39 41

  
40 42
	//private String baseUrl = "https://share.osf.io/api/v2/search/creativeworks/_search";
41 43
	//private String resumptionType = "count";
......
50 52
	//// private String query = "q=%28sources%3ASocArXiv+AND+type%3Apreprint%29";
51 53
	//private String query = "q=%28sources%3AengrXiv+AND+type%3Apreprint%29";
52 54
    //// private String query = "=(sources:engrXiv AND type:preprint)";
53
    
55
	//private String requestHeader = "";
56

  
57
	//config for Enermaps
58
	private String baseUrl = "https://lab.idiap.ch/enermaps/api/datacite";
59
	private String authMethod = "";
60
	private String authToken = "";
61
	private String entityXpath = "//data";
62
	private String query = " ";
63
	private String requestHeader = "{\"Accept\":\"application/vnd.pgrst.object+json\"}";
64
	private String resultFormatParam = "";
65
	private String resultFormatValue = "json";
66
	private String resultOutputFormat = "";
67
	private String resultSizeParam = "";
68
	private String resultSizeValue = "";
69
	private String resultTotalXpath = "fake";
70
	private String resumptionParam = "fake";
71
	private String resumptionType = "discover";
72
	private String resumptionXpath = "/fake";
73
	private String idxpath = "//data/id";
74

  
54 75
	private String protocolDescriptor = "rest_json2xml"; 
55 76
	private InterfaceDescriptor ifDesc = new InterfaceDescriptor();
56 77
	private RestCollectorPlugin rcp;
......
65 86
		params.put("resultFormatParam", resultFormatParam);
66 87
		params.put("resultFormatValue", resultFormatValue);
67 88
		params.put("resultSizeParam", resultSizeParam);
68
                params.put("resultSizeValue", resultSizeValue);
89
		params.put("resultSizeValue", resultSizeValue);
69 90
		params.put("queryParams", query);
70 91
		params.put("entityXpath", entityXpath);
71 92

  
72 93
		params.put("authMethod", authMethod);
73 94
		params.put("authToken", authToken);
95
		params.put("requestHeaderMap", requestHeader);
74 96
		
75 97
		ifDesc.setBaseUrl(baseUrl);
76 98
		ifDesc.setParams(params);
modules/dnet-collector-plugins/trunk/src/test/java/eu/dnetlib/data/collector/plugins/rest/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