1 |
1 |
package eu.dnetlib.api.client;
|
2 |
2 |
|
3 |
|
import static org.junit.Assert.assertEquals;
|
4 |
|
import static org.junit.Assert.assertNotNull;
|
5 |
|
import static org.junit.Assert.assertTrue;
|
6 |
|
|
7 |
|
import java.io.UnsupportedEncodingException;
|
8 |
3 |
import java.net.URI;
|
9 |
4 |
import java.net.URISyntaxException;
|
10 |
5 |
import java.text.SimpleDateFormat;
|
11 |
6 |
import java.util.Date;
|
12 |
7 |
import java.util.List;
|
13 |
8 |
|
|
9 |
import eu.dnetlib.api.utils.OpenAireDocumentPage;
|
|
10 |
import eu.dnetlib.api.utils.ResponseHeader;
|
14 |
11 |
import org.apache.http.client.utils.URIBuilder;
|
15 |
12 |
import org.dom4j.Document;
|
16 |
13 |
import org.dom4j.DocumentException;
|
17 |
14 |
import org.dom4j.DocumentHelper;
|
18 |
15 |
import org.junit.Before;
|
|
16 |
import org.junit.Ignore;
|
19 |
17 |
import org.junit.Test;
|
20 |
18 |
|
21 |
|
import eu.dnetlib.api.utils.OpenAireDocumentPage;
|
22 |
|
import eu.dnetlib.api.utils.ResponseHeader;
|
|
19 |
import static org.junit.Assert.*;
|
23 |
20 |
|
|
21 |
@Ignore
|
24 |
22 |
public class OpenairePublicationsApiClientTest extends OpenaireApiClientTest {
|
25 |
23 |
|
26 |
24 |
String today = "";
|
... | ... | |
107 |
105 |
assertEquals(100, pageHeader.getPageSize());
|
108 |
106 |
}
|
109 |
107 |
|
|
108 |
//Ignored just because it takes long time...
|
|
109 |
@Ignore
|
110 |
110 |
@Test
|
111 |
111 |
public void testMaxPageSizePublication() throws URISyntaxException, DocumentException {
|
112 |
112 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("size", "" + MAX_PAGE_SIZE + 1);
|
... | ... | |
153 |
153 |
System.out.println(uri);
|
154 |
154 |
String results = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri);
|
155 |
155 |
OpenAireDocumentPage page = new OpenAireDocumentPage(DocumentHelper.parseText(results));
|
156 |
|
assertTrue(page.allWithECFundng());
|
|
156 |
assertTrue(page.allWithECFunding());
|
157 |
157 |
}
|
158 |
158 |
|
159 |
159 |
@Test
|
160 |
|
public void testPublicationsUKFunding() throws URISyntaxException, DocumentException {
|
|
160 |
public void testPublicationsWTFunding() throws URISyntaxException, DocumentException {
|
161 |
161 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
162 |
|
builder.addParameter("hasUKFunding", "true");
|
|
162 |
builder.addParameter("hasWTFunding", "true");
|
163 |
163 |
URI uri = builder.build();
|
164 |
164 |
System.out.println(uri);
|
165 |
165 |
String results = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri);
|
166 |
166 |
OpenAireDocumentPage page = new OpenAireDocumentPage(DocumentHelper.parseText(results));
|
167 |
|
assertTrue(page.allWithUKFundng());
|
|
167 |
assertTrue(page.allWithWTFunding());
|
168 |
168 |
}
|
169 |
169 |
|
170 |
170 |
@Test
|
... | ... | |
175 |
175 |
System.out.println(uri1);
|
176 |
176 |
String results = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri1);
|
177 |
177 |
OpenAireDocumentPage pageWT = new OpenAireDocumentPage(DocumentHelper.parseText(results));
|
178 |
|
assertTrue(pageWT.allWithUKFundng());
|
|
178 |
assertTrue(pageWT.allWithWTFunding());
|
179 |
179 |
|
180 |
180 |
URIBuilder builderUK = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
181 |
|
builderUK.addParameter("hasUKFunding", "true");
|
|
181 |
builderUK.addParameter("hasWTFunding", "true");
|
182 |
182 |
URI uri2 = builderUK.build();
|
183 |
183 |
System.out.println(uri2);
|
184 |
184 |
String resultsUK = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri2);
|
... | ... | |
188 |
188 |
}
|
189 |
189 |
|
190 |
190 |
@Test
|
191 |
|
public void testPublicationsECFunders() throws URISyntaxException, DocumentException {
|
192 |
|
URIBuilder builderFP7 = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
193 |
|
builderFP7.addParameter("funder", "fp7");
|
194 |
|
URI uri1 = builderFP7.build();
|
195 |
|
System.out.println(uri1);
|
196 |
|
String resultsFP7 = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri1);
|
197 |
|
OpenAireDocumentPage pageFP7 = new OpenAireDocumentPage(DocumentHelper.parseText(resultsFP7));
|
198 |
|
assertTrue(pageFP7.allWithECFundng());
|
199 |
|
|
200 |
|
URIBuilder builderH2020 = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
201 |
|
builderH2020.addParameter("funder", "h2020");
|
202 |
|
URI uri2 = builderH2020.build();
|
203 |
|
System.out.println(uri2);
|
204 |
|
String resultsH2020 = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri2);
|
205 |
|
OpenAireDocumentPage pageH2020 = new OpenAireDocumentPage(DocumentHelper.parseText(resultsH2020));
|
206 |
|
assertTrue(pageH2020.allWithECFundng());
|
207 |
|
|
208 |
|
URIBuilder builderEC = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
209 |
|
builderEC.addParameter("hasECFunding", "true");
|
210 |
|
URI uri3 = builderEC.build();
|
211 |
|
System.out.println(uri3);
|
212 |
|
String resultsUK = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri3);
|
213 |
|
OpenAireDocumentPage pageEC = new OpenAireDocumentPage(DocumentHelper.parseText(resultsUK));
|
214 |
|
|
215 |
|
assertTrue(pageEC.getResponseHeader().getTotal() == (pageFP7.getResponseHeader().getTotal() + pageH2020.getResponseHeader().getTotal()));
|
216 |
|
}
|
217 |
|
|
218 |
|
@Test
|
219 |
|
public void testPublicationsSingleOpenaireID() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
220 |
|
String testRecordId = "dedup_wf_001::d1bb389d90e0a4393f7ea00c457a62b5";
|
|
191 |
public void testPublicationsSingleOpenaireID() throws URISyntaxException, DocumentException {
|
|
192 |
String testRecordId = "od________18::f055e1a3188aa57b454b1bfc0b882ed2";
|
221 |
193 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
222 |
194 |
builder.addParameter("openairePublicationID", testRecordId);
|
223 |
195 |
URI uri = builder.build();
|
... | ... | |
231 |
203 |
}
|
232 |
204 |
|
233 |
205 |
@Test
|
234 |
|
public void testPublicationsMultipleOpenaireIDs1() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
235 |
|
String testRecordId1 = "dedup_wf_001::d1bb389d90e0a4393f7ea00c457a62b5";
|
|
206 |
public void testPublicationsMultipleOpenaireIDs1() throws URISyntaxException, DocumentException {
|
|
207 |
String testRecordId1 = "od________18::f055e1a3188aa57b454b1bfc0b882ed2";
|
236 |
208 |
String testRecordId2 = "od________18::5ea480618e9ab9e7db827fa498422075";
|
237 |
209 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
238 |
210 |
builder.addParameter("openairePublicationID", testRecordId1 + "," + testRecordId2);
|
... | ... | |
248 |
220 |
}
|
249 |
221 |
|
250 |
222 |
@Test
|
251 |
|
public void testPublicationsMultipleOpenaireIDs2() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
252 |
|
String testRecordId1 = "dedup_wf_001::d1bb389d90e0a4393f7ea00c457a62b5";
|
|
223 |
public void testPublicationsMultipleOpenaireIDs2() throws URISyntaxException, DocumentException {
|
|
224 |
String testRecordId1 = "od________18::f055e1a3188aa57b454b1bfc0b882ed2";
|
253 |
225 |
String testRecordId2 = "od________18::5ea480618e9ab9e7db827fa498422075";
|
254 |
226 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
255 |
227 |
builder.addParameter("openairePublicationID", testRecordId1);
|
... | ... | |
266 |
238 |
}
|
267 |
239 |
|
268 |
240 |
@Test
|
269 |
|
public void testPublicationsUnexistingOpenaireID() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
|
241 |
public void testPublicationsUnexistingOpenaireID() throws URISyntaxException, DocumentException {
|
270 |
242 |
String testRecordId = "foo::d1bb389d90e0a4393f7ea00c457a62b5";
|
271 |
243 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
272 |
244 |
builder.addParameter("openairePublicationID", testRecordId);
|
... | ... | |
277 |
249 |
assertEquals(0, page.getResponseHeader().getTotal());
|
278 |
250 |
}
|
279 |
251 |
|
|
252 |
//TODO: Unignore the test when the path to the pid is fixed on the index side
|
|
253 |
@Ignore
|
280 |
254 |
@Test
|
281 |
|
public void testPublicationsSingleDOI() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
282 |
|
String testRecordId = "dedup_wf_001::d1bb389d90e0a4393f7ea00c457a62b5";
|
283 |
|
String doi = "10.3389/fnhum.2013.00107";
|
|
255 |
public void testPublicationsSingleDOI() throws URISyntaxException, DocumentException {
|
|
256 |
String testRecordId = "dedup_wf_001::fc4c3a6c233f478586f5fb3259b25bc4";
|
|
257 |
String doi = "10.1143/JPSJ.74.1954";
|
284 |
258 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
285 |
259 |
builder.addParameter("doi", doi);
|
286 |
260 |
URI uri = builder.build();
|
287 |
261 |
System.out.println(uri);
|
288 |
262 |
String results = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri);
|
289 |
263 |
OpenAireDocumentPage page = new OpenAireDocumentPage(DocumentHelper.parseText(results));
|
290 |
|
assertEquals(page.getResponseHeader().getTotal(), 1);
|
|
264 |
assertEquals(1, page.getResponseHeader().getTotal());
|
291 |
265 |
List<String> objIds = page.getObjIdentifiers();
|
292 |
266 |
assertEquals(1, objIds.size());
|
293 |
267 |
assertTrue(objIds.contains(testRecordId));
|
294 |
268 |
}
|
295 |
269 |
|
296 |
270 |
@Test
|
297 |
|
public void testPublicationsMultipleDOIs1() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
298 |
|
String testRecordId1 = "dedup_wf_001::d1bb389d90e0a4393f7ea00c457a62b5";
|
299 |
|
String testRecordId2 = "od________18::5ea480618e9ab9e7db827fa498422075";
|
300 |
|
String doi1 = "10.3389/fnhum.2013.00107";
|
301 |
|
String doi2 = "10.1016/j.jmb.2010.12.024";
|
|
271 |
public void testPublicationsMultipleDOIs1() throws URISyntaxException, DocumentException {
|
|
272 |
String testRecordId1 = "dedup_wf_001::fc4c3a6c233f478586f5fb3259b25bc4";
|
|
273 |
String testRecordId2 = "dedup_wf_001::eb22f16c808595b58c277ba95bc96275";
|
|
274 |
String doi1 = "10.1143/JPSJ.74.1954";
|
|
275 |
String doi2 = "10.1103/physrevlett.116.116401";
|
302 |
276 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
303 |
277 |
builder.addParameter("doi", doi1 + "," + doi2);
|
304 |
278 |
URI uri = builder.build();
|
... | ... | |
313 |
287 |
}
|
314 |
288 |
|
315 |
289 |
@Test
|
316 |
|
public void testPublicationsMultipleDOIs2() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
317 |
|
String testRecordId1 = "dedup_wf_001::d1bb389d90e0a4393f7ea00c457a62b5";
|
318 |
|
String testRecordId2 = "od________18::5ea480618e9ab9e7db827fa498422075";
|
319 |
|
String doi1 = "10.3389/fnhum.2013.00107";
|
320 |
|
String doi2 = "10.1016/j.jmb.2010.12.024";
|
321 |
|
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath);
|
322 |
|
builder.addParameter("doi", doi1);
|
323 |
|
builder.addParameter("doi", doi2);
|
324 |
|
URI uri = builder.build();
|
325 |
|
System.out.println(uri);
|
326 |
|
String results = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri);
|
327 |
|
OpenAireDocumentPage page = new OpenAireDocumentPage(DocumentHelper.parseText(results));
|
328 |
|
assertTrue(page.getResponseHeader().getTotal() >= 2);
|
329 |
|
List<String> objIds = page.getObjIdentifiers();
|
330 |
|
assertEquals(page.getResponseHeader().getTotal(), objIds.size());
|
331 |
|
assertTrue(objIds.contains(testRecordId1));
|
332 |
|
assertTrue(objIds.contains(testRecordId2));
|
333 |
|
}
|
334 |
|
|
335 |
|
@Test
|
336 |
|
public void testPublicationsFromDate() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
|
290 |
public void testPublicationsFromDate() throws URISyntaxException, DocumentException {
|
337 |
291 |
String date = "2012-03-15";
|
338 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (resultdateofacceptance within \"2012-03-15 "
|
339 |
|
+ today + "\")";
|
|
292 |
String expectedQuery = publicationsQuery + " and (resultdateofacceptance within \"2012-03-15 "+today+"\")";
|
340 |
293 |
|
341 |
294 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("fromDateAccepted", date);
|
342 |
295 |
URI uri = builder.build();
|
... | ... | |
348 |
301 |
}
|
349 |
302 |
|
350 |
303 |
@Test
|
351 |
|
public void testPublicationsToDate() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
|
304 |
public void testPublicationsToDate() throws URISyntaxException, DocumentException {
|
352 |
305 |
String date = "2013-03-15";
|
353 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (resultdateofacceptance within \"* 2013-03-15\")";
|
|
306 |
String expectedQuery = publicationsQuery + " and (resultdateofacceptance within \"* 2013-03-15\")";
|
354 |
307 |
|
355 |
308 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("toDateAccepted", date);
|
356 |
309 |
URI uri = builder.build();
|
... | ... | |
363 |
316 |
}
|
364 |
317 |
|
365 |
318 |
@Test
|
366 |
|
public void testPublicationsByTitle() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
|
319 |
public void testPublicationsByTitle() throws URISyntaxException, DocumentException {
|
367 |
320 |
String title = "Enhanced Publications";
|
368 |
|
String expectedQuery = "((((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (resulttitle = Enhanced)) and (resulttitle = Publications)";
|
|
321 |
String expectedQuery = publicationsQuery + " and (resulttitle = \"Enhanced\") and (resulttitle = \"Publications\")";
|
369 |
322 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("title", title);
|
370 |
323 |
URI uri = builder.build();
|
371 |
324 |
System.out.println(uri);
|
... | ... | |
376 |
329 |
}
|
377 |
330 |
|
378 |
331 |
@Test
|
379 |
|
public void testPublicationsByAuthor() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
|
332 |
public void testPublicationsByAuthor() throws URISyntaxException, DocumentException {
|
380 |
333 |
String author = "bardi alessia manghi";
|
381 |
|
String expectedQuery = "(((((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (relperson = bardi)) and (relperson = alessia)) and (relperson = manghi)";
|
|
334 |
String expectedQuery = publicationsQuery + " and (relperson = \"bardi\") and (relperson = \"alessia\") and (relperson = \"manghi\")";
|
382 |
335 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("author", author);
|
383 |
336 |
URI uri = builder.build();
|
384 |
337 |
System.out.println(uri);
|
... | ... | |
388 |
341 |
assertEquals(expectedQuery, page.getResponseHeader().getQuery());
|
389 |
342 |
}
|
390 |
343 |
|
391 |
|
@Test
|
392 |
|
public void testPublicationsByAuthorId() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
|
344 |
|
|
345 |
// Expect exception because the openaireAuthorID field must not be accepted
|
|
346 |
@Test(expected=IllegalArgumentException.class)
|
|
347 |
public void testPublicationsByAuthorId() throws URISyntaxException, DocumentException{
|
393 |
348 |
String authorId = "od______2367::3fbd0b3533bd0e6089c1fe68b115f772";
|
394 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (relpersonid exact od______2367::3fbd0b3533bd0e6089c1fe68b115f772)";
|
395 |
349 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("openaireAuthorID", authorId);
|
396 |
350 |
URI uri = builder.build();
|
397 |
351 |
System.out.println(uri);
|
398 |
352 |
String results = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri);
|
399 |
353 |
OpenAireDocumentPage page = new OpenAireDocumentPage(DocumentHelper.parseText(results));
|
400 |
354 |
assertNotNull(page);
|
401 |
|
assertEquals(expectedQuery, page.getResponseHeader().getQuery());
|
402 |
355 |
}
|
403 |
356 |
|
404 |
357 |
@Test
|
405 |
|
public void testPublicationsByMultipleAuthorId() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
406 |
|
String authorId1 = "od______2367::3fbd0b3533bd0e6089c1fe68b115f772";
|
407 |
|
String authorId2 = "od______2367::3fbd0b3533bd0e6089c1fe68b115f772";
|
408 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (relpersonid exact od______2367::3fbd0b3533bd0e6089c1fe68b115f772 or (relpersonid exact od______2367::3fbd0b3533bd0e6089c1fe68b115f772)";
|
409 |
|
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("openaireAuthorID", authorId1)
|
410 |
|
.addParameter("openaireAuthorID", authorId2);
|
411 |
|
URI uri = builder.build();
|
412 |
|
System.out.println(uri);
|
413 |
|
String results = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri);
|
414 |
|
OpenAireDocumentPage page = new OpenAireDocumentPage(DocumentHelper.parseText(results));
|
415 |
|
assertNotNull(page);
|
416 |
|
assertEquals(expectedQuery, page.getResponseHeader().getQuery());
|
417 |
|
}
|
418 |
|
|
419 |
|
@Test
|
420 |
|
public void testPublicationsByProviderId() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
|
358 |
public void testPublicationsByProviderId() throws URISyntaxException, DocumentException {
|
421 |
359 |
// this is PUMA
|
422 |
360 |
String providerId = "opendoar____::300891a62162b960cf02ce3827bb363c";
|
423 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (resulthostingdatasourceid exact opendoar____::300891a62162b960cf02ce3827bb363c)";
|
|
361 |
String expectedQuery = publicationsQuery + " and (resulthostingdatasourceid exact \"opendoar____::300891a62162b960cf02ce3827bb363c\")";
|
424 |
362 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("openaireProviderID", providerId);
|
425 |
363 |
URI uri = builder.build();
|
426 |
364 |
System.out.println(uri);
|
... | ... | |
431 |
369 |
}
|
432 |
370 |
|
433 |
371 |
@Test
|
434 |
|
public void testPublicationsByMultipleProviderIds() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
|
372 |
public void testPublicationsByMultipleProviderIds() throws URISyntaxException, DocumentException {
|
435 |
373 |
// this is PUMA
|
436 |
374 |
String providerId1 = "opendoar____::300891a62162b960cf02ce3827bb363c";
|
437 |
375 |
String providerId2 = "opendoar____::300891a62162b960cf02ce3827bb363c";
|
438 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (resulthostingdatasourceid exact opendoar____::300891a62162b960cf02ce3827bb363c or resulthostingdatasourceid exact opendoar____::300891a62162b960cf02ce3827bb363c)";
|
|
376 |
String expectedQuery = publicationsQuery + " and (resulthostingdatasourceid exact \"opendoar____::300891a62162b960cf02ce3827bb363c\") or (resulthostingdatasourceid exact \"opendoar____::300891a62162b960cf02ce3827bb363c\")";
|
439 |
377 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("openaireProviderID", providerId1 + "," + providerId2);
|
440 |
378 |
URI uri = builder.build();
|
441 |
379 |
System.out.println(uri);
|
... | ... | |
446 |
384 |
}
|
447 |
385 |
|
448 |
386 |
@Test
|
449 |
|
public void testPublicationsBy2ProviderId() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
|
387 |
public void testPublicationsBy2ProviderId() throws URISyntaxException, DocumentException {
|
450 |
388 |
// this is PUMA
|
451 |
389 |
String providerId1 = "opendoar____::300891a62162b960cf02ce3827bb363c";
|
452 |
390 |
// this is UTL Repository
|
453 |
391 |
String providerId2 = "opendoar____::0c8ce55163055c4da50a81e0a273468c";
|
454 |
|
// String expectedQuery =
|
455 |
|
// "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (resulthostingdatasourceid exact opendoar____::300891a62162b960cf02ce3827bb363c)";
|
|
392 |
String expectedQuery = publicationsQuery + " and (resulthostingdatasourceid exact \"opendoar____::300891a62162b960cf02ce3827bb363c\") or (resulthostingdatasourceid exact \"opendoar____::0c8ce55163055c4da50a81e0a273468c\")";
|
456 |
393 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("openaireProviderID", providerId1)
|
457 |
394 |
.addParameter("openaireProviderID", providerId2);
|
458 |
395 |
URI uri = builder.build();
|
... | ... | |
460 |
397 |
String results = getApiClient().doRequest(EntityType.publication, ApiModel.openaire, uri);
|
461 |
398 |
OpenAireDocumentPage page = new OpenAireDocumentPage(DocumentHelper.parseText(results));
|
462 |
399 |
assertNotNull(page);
|
463 |
|
// assertEquals(expectedQuery, page.getResponseHeader().getQuery());
|
|
400 |
assertEquals(expectedQuery, page.getResponseHeader().getQuery());
|
464 |
401 |
}
|
465 |
402 |
|
466 |
403 |
@Test
|
... | ... | |
486 |
423 |
}
|
487 |
424 |
|
488 |
425 |
@Test
|
489 |
|
public void testPublicationsWithProjects() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
490 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (relprojectid = *)";
|
|
426 |
public void testPublicationsWithProjects() throws URISyntaxException, DocumentException {
|
|
427 |
String expectedQuery = publicationsQuery + " and (relprojectid = \"*\")";
|
491 |
428 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("hasProject", "true");
|
492 |
429 |
URI uri = builder.build();
|
493 |
430 |
System.out.println(uri);
|
... | ... | |
498 |
435 |
}
|
499 |
436 |
|
500 |
437 |
@Test
|
501 |
|
public void testPublicationsWithoutProjects() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
502 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) not (relprojectid = *)";
|
|
438 |
public void testPublicationsWithoutProjects() throws URISyntaxException, DocumentException {
|
|
439 |
String expectedQuery = publicationsQuery + " not (relprojectid = \"*\")";
|
503 |
440 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("hasProject", "false");
|
504 |
441 |
URI uri = builder.build();
|
505 |
442 |
System.out.println(uri);
|
... | ... | |
510 |
447 |
}
|
511 |
448 |
|
512 |
449 |
@Test
|
513 |
|
public void testPublicationsOA() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
514 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (resultbestlicense exact \"Open Access\")";
|
|
450 |
public void testPublicationsOA() throws URISyntaxException, DocumentException {
|
|
451 |
String expectedQuery = publicationsQuery + " and (resultbestaccessright exact \"Open Access\")";
|
515 |
452 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("OA", "true");
|
516 |
453 |
URI uri = builder.build();
|
517 |
454 |
System.out.println(uri);
|
... | ... | |
522 |
459 |
}
|
523 |
460 |
|
524 |
461 |
@Test
|
525 |
|
public void testPublicationsNonOA() throws URISyntaxException, DocumentException, UnsupportedEncodingException {
|
526 |
|
String expectedQuery = "(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (resultbestlicense <> \"Open Access\")";
|
|
462 |
public void testPublicationsNonOA() throws URISyntaxException, DocumentException {
|
|
463 |
String expectedQuery = publicationsQuery + " and (resultbestaccessright <> \"Open Access\")";
|
527 |
464 |
URIBuilder builder = new URIBuilder(requestBaseURL).setPath(publicationsPath).addParameter("OA", "false");
|
528 |
465 |
URI uri = builder.build();
|
529 |
466 |
System.out.println(uri);
|
Migrated from dnet40 and adapted to current version of the OpenAIRE Search API.