### Question:
DatasetImporterForMangal extends DatasetImporterWithListener { public static void appendReferenceToMap(JsonNode aReference, Map<String, Map<String, String>> refMap) { if (hasNonEmptyValueFor(aReference, "id")) { Map<String, String> props = new TreeMap<>(); if (hasNonEmptyValueFor(aReference, "doi")) { props.put(DatasetImporterForTSV.REFERENCE_DOI, aReference.get("doi").asText()); } if (hasNonEmptyValueFor(aReference, "bibtex")) { props.put(DatasetImporterForTSV.REFERENCE_CITATION, aReference.get("bibtex").asText()); } else { if (hasNonEmptyValueFor(aReference, "first_author") && hasNonEmptyValueFor(aReference, "year")) props.put(DatasetImporterForTSV.REFERENCE_CITATION, aReference.get("first_author").asText() + " " + aReference.get("year").asText()); } if (hasNonEmptyValueFor(aReference, "paper_url")) { props.put(DatasetImporterForTSV.REFERENCE_URL, aReference.get("paper_url").asText()); } String id = aReference.get("id").asText(); props.put(DatasetImporterForTSV.REFERENCE_ID, "mangal:ref:id:" + id); refMap.put(id, props); } } 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 buildReferenceMap() throws IOException { Map<String, Map<String, String>> refMap = new HashMap<>(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = objectMapper.readTree(getClass().getResourceAsStream("mangal-reference.json")); JsonNode singleReference = jsonNode.get(0); DatasetImporterForMangal.appendReferenceToMap(singleReference, refMap); assertThat(refMap.containsKey("36"), Is.is(true)); assertThat(refMap.get("36").get(DatasetImporterForTSV.REFERENCE_CITATION), CoreMatchers.containsString("The biology of Knysna estuary")); assertThat(refMap.get("36").get(DatasetImporterForTSV.REFERENCE_ID), Is.is("mangal:ref:id:36")); }