### Question:
DatasetImporterForMangal extends DatasetImporterWithListener { public static Map<String, String> parseInteraction(JsonNode singleInteraction, Map<String, Map<String, String>> nodeMap, Map<String, Map<String, String>> networkMap) throws StudyImporterException { Map<String, String> interaction = new TreeMap<>(); addNameLabel(nodeMap, singleInteraction, interaction, "node_from", TaxonUtil.SOURCE_TAXON_NAME); addNameLabel(nodeMap, singleInteraction, interaction, "node_to", TaxonUtil.TARGET_TAXON_NAME); if (hasNonEmptyValueFor(singleInteraction, "date")) { interaction.put(DatasetImporterForMetaTable.EVENT_DATE, singleInteraction.get("date").asText()); } String interactionTypeName = singleInteraction.get("type").asText(); interaction.put(DatasetImporterForTSV.INTERACTION_TYPE_NAME, interactionTypeName); String basisOfRecord = singleInteraction.get("method").asText(); interaction.put(DatasetImporterForTSV.BASIS_OF_RECORD_NAME, basisOfRecord); String networkId = singleInteraction.get("network_id").asText(); Map<String, String> networkProps = networkMap.get(networkId); if (networkProps == null) { throw new StudyImporterException("failed to find network with id [" + networkId + "]"); } interaction.putAll(networkProps); interaction.put("mangal:network:id", networkId); return interaction; } 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 parseInteraction() throws IOException, StudyImporterException { Map<String, Map<String, String>> nodeMap = new TreeMap<>(); nodeMap.put("20742", new HashMap<String, String>() {{ put("original_name", "donald duck"); }}); nodeMap.put("20751", new HashMap<String, String>() {{ put("original_name", "mickey mouse"); }}); Map<String, Map<String, String>> networkMap = new TreeMap<String, Map<String, String>>() {{ put("1334", new HashMap<String, String>() {{ }}); }}; ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = objectMapper.readTree(getClass().getResourceAsStream("mangal-interaction.json")); JsonNode singleInteraction = jsonNode.get(0); Map<String, String> interaction = DatasetImporterForMangal.parseInteraction(singleInteraction, nodeMap, networkMap); assertThat(interaction.get(TaxonUtil.SOURCE_TAXON_NAME), Is.is("donald duck")); assertThat(interaction.get(TaxonUtil.TARGET_TAXON_NAME), Is.is("mickey mouse")); }