@Test public void paginate() throws IOException, StudyImporterException { AtomicInteger counter = new AtomicInteger(0); final DatasetImporterForZenodoMetadata studyImporterForZenodoMetadata = new DatasetImporterForZenodoMetadata(null, null); studyImporterForZenodoMetadata.setInteractionListener(new InteractionListener() { @Override public void newLink(Map<String, String> link) throws StudyImporterException { } }); final DatasetImpl dataset = new DatasetImpl("name/space", URI.create("some:uri"), in -> in) { @Override public InputStream retrieve(URI resourceName) throws IOException { counter.incrementAndGet(); InputStream is = null; if (URI.create("https: .equals(resourceName)) { is = DatasetImporterForZenodoMetadataTest.class.getResourceAsStream("zenodo/search-results-page-2.json"); } else if (URI.create("https: .equals(resourceName)) { is = DatasetImporterForZenodoMetadataTest.class.getResourceAsStream("zenodo/search-results-page-1.json"); } else { throw new IOException("kaboom!"); } return is; } }; studyImporterForZenodoMetadata.setDataset(dataset); studyImporterForZenodoMetadata.importStudy(); assertThat(counter.get(), Is.is(2)); }
@Override public void importStudy() throws StudyImporterException { final String zenodoSearchURI = getDataset() .getOrDefault("url", "https: URI uri = URI.create(zenodoSearchURI); while (uri != null) { try (InputStream is = getDataset().retrieve(uri)) { uri = parseSearchResults(is, getInteractionListener()); } catch (IOException e) { throw new StudyImporterException("failed to access Zenodo api", e); } } }
DatasetImporterForZenodoMetadata extends DatasetImporterWithListener { @Override public void importStudy() throws StudyImporterException { final String zenodoSearchURI = getDataset() .getOrDefault("url", "https: URI uri = URI.create(zenodoSearchURI); while (uri != null) { try (InputStream is = getDataset().retrieve(uri)) { uri = parseSearchResults(is, getInteractionListener()); } catch (IOException e) { throw new StudyImporterException("failed to access Zenodo api", e); } } } }
DatasetImporterForZenodoMetadata extends DatasetImporterWithListener { @Override public void importStudy() throws StudyImporterException { final String zenodoSearchURI = getDataset() .getOrDefault("url", "https: URI uri = URI.create(zenodoSearchURI); while (uri != null) { try (InputStream is = getDataset().retrieve(uri)) { uri = parseSearchResults(is, getInteractionListener()); } catch (IOException e) { throw new StudyImporterException("failed to access Zenodo api", e); } } } DatasetImporterForZenodoMetadata(ParserFactory parserFactory, NodeFactory nodeFactory); }
DatasetImporterForZenodoMetadata extends DatasetImporterWithListener { @Override public void importStudy() throws StudyImporterException { final String zenodoSearchURI = getDataset() .getOrDefault("url", "https: URI uri = URI.create(zenodoSearchURI); while (uri != null) { try (InputStream is = getDataset().retrieve(uri)) { uri = parseSearchResults(is, getInteractionListener()); } catch (IOException e) { throw new StudyImporterException("failed to access Zenodo api", e); } } } DatasetImporterForZenodoMetadata(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); static URI parseSearchResults(InputStream searchResultStream, InteractionListener interactionListener); }
DatasetImporterForZenodoMetadata extends DatasetImporterWithListener { @Override public void importStudy() throws StudyImporterException { final String zenodoSearchURI = getDataset() .getOrDefault("url", "https: URI uri = URI.create(zenodoSearchURI); while (uri != null) { try (InputStream is = getDataset().retrieve(uri)) { uri = parseSearchResults(is, getInteractionListener()); } catch (IOException e) { throw new StudyImporterException("failed to access Zenodo api", e); } } } DatasetImporterForZenodoMetadata(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); static URI parseSearchResults(InputStream searchResultStream, InteractionListener interactionListener);  }