### Question:
DatasetImporterForMangal extends DatasetImporterWithListener { public static boolean handlePagedResults(NodeListener listener, InputStream resource, int limit) throws StudyImporterException { try { ObjectMapper mapper = new ObjectMapper(); JsonNode array; array = mapper.readTree(resource); if (!array.isArray()) { throw new StudyImporterException("expected array, but got object"); } for (JsonNode datasetNode : array) { listener.onNode(datasetNode); } return array.size() >= limit; } catch (IOException e) { throw new StudyImporterException("error parsing json", e); } } DatasetImporterForMangal(ParserFactory parserFactory, NodeFactory nodeFactory); static URI getPagedUrl(String urlEndpoint, int page, int limit); static void retrievePagedResource(ResourceService resourceService, NodeListener listener, int pageSize, int pageNumber, String urlEndpoint); static boolean handlePagedResults(NodeListener listener, InputStream resource, int limit); static void appendNodeToMap(JsonNode singleNode, Map<String, Map<String, String>> nodeMap); static boolean hasNonEmptyValueFor(JsonNode jsonNode, String key); static void appendReferenceToMap(JsonNode aReference, Map<String, Map<String, String>> refMap); static void appendNetworkToMap(JsonNode singleNode,
                                          Map<String, Map<String, String>> networkMap,
                                          Map<String, Map<String, String>> datasetMap
    ); static void appendDatasetToMap(JsonNode aDataset, Map<String, Map<String, String>> datasetMap, Map<String, Map<String, String>> refMap); static Map<String, String> parseInteraction(JsonNode singleInteraction, Map<String, Map<String, String>> nodeMap, Map<String, Map<String, String>> networkMap); static void addNameLabel(Map<String, Map<String, String>> nodeMap, JsonNode singleInteraction, Map<String, String> interaction, String nodeLabel, String nameLabel); @Override void importStudy(); static final String MANGAL_API_ENDPOINT; static final Map<String, InteractType> INTERACTION_TYPE_MAP; }### Answer:
@Test public void parseDatasets() throws StudyImporterException { List<JsonNode> nodes = new ArrayList<>(); DatasetImporterForMangal.NodeListener listener = nodes::add; InputStream resource = getClass().getResourceAsStream("mangal-dataset.json"); int limit = 100; assertTrue(DatasetImporterForMangal.handlePagedResults(listener, resource, limit)); assertThat(nodes.size(), Is.is(100)); }