Skip to content

Commit

Permalink
CrossRefImportMetadataSourceServiceIT: Test empty responses don't res…
Browse files Browse the repository at this point in the history
…ult in ... results.
  • Loading branch information
philipprumpf committed Nov 16, 2023
1 parent 9f3f517 commit a68755e
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ public class CrossRefImportMetadataSourceServiceIT extends AbstractLiveImportInt
@Autowired
private CrossRefImportMetadataSourceServiceImpl crossRefServiceImpl;

@Test
public void crossRefImportMetadataGetNoRecordsTest() throws Exception {
context.turnOffAuthorisationSystem();
CloseableHttpClient originalHttpClient = liveImportClientImpl.getHttpClient();
CloseableHttpClient httpClient = Mockito.mock(CloseableHttpClient.class);
try {
liveImportClientImpl.setHttpClient(httpClient);
CloseableHttpResponse response = mockResponse("" , 404, "Not Found");
when(httpClient.execute(ArgumentMatchers.any())).thenReturn(response);

context.restoreAuthSystemState();
Collection<ImportRecord> recordsImported = crossRefServiceImpl.getRecords("test query", 0, 2);
assertEquals(0, recordsImported.size());
} finally {
liveImportClientImpl.setHttpClient(originalHttpClient);
}
}

@Test
public void crossRefImportMetadataGetRecordsTest() throws Exception {
context.turnOffAuthorisationSystem();
Expand Down

0 comments on commit a68755e

Please sign in to comment.