1
|
package eu.dnetlib.api.client;
|
2
|
|
3
|
import java.net.URI;
|
4
|
import java.net.URISyntaxException;
|
5
|
|
6
|
import eu.dnetlib.api.utils.OpenAireDocumentPage;
|
7
|
import org.apache.http.client.utils.URIBuilder;
|
8
|
import org.dom4j.DocumentException;
|
9
|
import org.dom4j.DocumentHelper;
|
10
|
import org.junit.Ignore;
|
11
|
import org.junit.Test;
|
12
|
|
13
|
import static org.junit.Assert.assertNotNull;
|
14
|
|
15
|
@Ignore
|
16
|
public class OpenaireProjectsApiClientTest extends OpenaireApiClientTest {
|
17
|
|
18
|
@Test
|
19
|
public void testProjectsOpenaire() throws URISyntaxException, DocumentException {
|
20
|
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(projectsPath);
|
21
|
String results = getApiClient().doRequest(EntityType.project, ApiModel.none, builder.build());
|
22
|
OpenAireDocumentPage page = new OpenAireDocumentPage(DocumentHelper.parseText(results));
|
23
|
assertNotNull("page is null", page);
|
24
|
}
|
25
|
|
26
|
@Test
|
27
|
public void testProjectParameters() throws URISyntaxException, DocumentException {
|
28
|
for (String param : commonParameters) {
|
29
|
if (!param.equals("model") && !param.equals("format") && !param.equals("page") && !param.equals("size") && !param.equals("sortBy")) {
|
30
|
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(projectsPath).addParameter(param, "test");
|
31
|
URI uri = builder.build();
|
32
|
System.out.println(uri);
|
33
|
String results = getApiClient().doRequest(EntityType.project, ApiModel.none, uri);
|
34
|
checkNotException(results);
|
35
|
}
|
36
|
}
|
37
|
for (String param : projectParameters) {
|
38
|
if (!param.equals("startYear") && !param.equals("endYear")) {
|
39
|
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(projectsPath).addParameter(param, "test");
|
40
|
URI uri = builder.build();
|
41
|
System.out.println(uri);
|
42
|
String results = getApiClient().doRequest(EntityType.project, ApiModel.none, uri);
|
43
|
checkNotException(results);
|
44
|
}
|
45
|
}
|
46
|
}
|
47
|
|
48
|
@Test
|
49
|
public void testSortByProjectsParameters() throws URISyntaxException, DocumentException {
|
50
|
checkSortByParamaters(EntityType.project);
|
51
|
}
|
52
|
}
|