mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
datacite api test for no results count
This commit is contained in:
@@ -146,4 +146,23 @@ public class DataCiteImportMetadataSourceServiceIT extends AbstractLiveImportInt
|
||||
return records;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dataCiteImportMetadataNoResultsTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
CloseableHttpClient originalHttpClient = liveImportClientImpl.getHttpClient();
|
||||
CloseableHttpClient httpClient = Mockito.mock(CloseableHttpClient.class);
|
||||
try (InputStream dataciteResp = getClass().getResourceAsStream("dataCite-noResults.json")) {
|
||||
String dataciteTextResp = IOUtils.toString(dataciteResp, Charset.defaultCharset());
|
||||
liveImportClientImpl.setHttpClient(httpClient);
|
||||
CloseableHttpResponse response = mockResponse(dataciteTextResp, 200, "OK");
|
||||
when(httpClient.execute(ArgumentMatchers.any())).thenReturn(response);
|
||||
context.restoreAuthSystemState();
|
||||
int tot = dataCiteServiceImpl.getRecordsCount("nocontent");
|
||||
assertEquals(0, tot);
|
||||
Collection<ImportRecord> importRecords = dataCiteServiceImpl.getRecords("nocontent", 0 , -1);
|
||||
assertEquals(0, importRecords.size());
|
||||
} finally {
|
||||
liveImportClientImpl.setHttpClient(originalHttpClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
{"data":[],"meta":{"total":0,"totalPages":0,"page":1},"links":{"self":"https://api.datacite.org/dois?query=nocontent"}}
|
Reference in New Issue
Block a user