### Question:
DatasetImporterForDwCA extends DatasetImporterWithListener { static Map<String, String> parseDynamicPropertiesForInteractionsOnly(String s) { Map<String, String> properties = new HashMap<>(); String[] parts = StringUtils.splitByWholeSeparator(s, ";"); for (String part : parts) { String[] propertyValue = StringUtils.split(part, ":=", 2); if (propertyValue.length == 2) { properties.put(StringUtils.trim(propertyValue[0]), StringUtils.trim(propertyValue[1])); } } return properties.containsKey(INTERACTION_TYPE_ID) || properties.containsKey(INTERACTION_TYPE_NAME) ? properties : Collections.emptyMap(); } DatasetImporterForDwCA(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); int importCore(Archive archive, InteractionListener interactionListener); void handleRecord(InteractionListener interactionListener, Record rec); static void addRoyalSaskatchewanMuseumOwlPelletCollectionStyleRemarks(List<Map<String, String>> interactionCandidates, String occurrenceRemarks); static Map<String, String> parseRoyalSaskatchewanMuseumOwlPelletCollectionStyleRemarks(String occurrenceRemarks); void addUSNMStyleHostOccurrenceRemarks(List<Map<String, String>> interactionCandidates, String occurrenceRemarks); static void mapCoreProperties(Record rec, Map<String, String> interactionProperties); static void mapLocationAndReferenceInfo(Record rec, Map<String, String> interactionProperties); static void mapSourceProperties(Record rec, Map<String, String> interactionProperties); static void mapIfAvailable(Record rec, Map<String, String> interactionProperties, String key, Term term); static void mapIfAvailable(Map<String, String> interactionProperties, String key, String value); static Map<String, String> parseUSNMStyleHostOccurrenceRemarks(String occurrenceRemarks); static Map<String, String> parseJsonChunk(String candidateJsonChunk); static final String EXTENSION_ASSOCIATED_TAXA; static final String EXTENSION_RESOURCE_RELATIONSHIP; static final String EXTENSION_TAXON; static final Pattern EX_NOTATION; static final Pattern REARED_EX_NOTATION; static final Pattern PATTERN_ASSOCIATED_TAXA_IDEA; static final Pattern PATTERN_ASSOCIATED_TAXA_EAE; }### Answer:
@Test public void dynamicProperties() { String s = "targetTaxonName: Homo sapiens; targetTaxonId: https: Map<String, String> properties = parseDynamicPropertiesForInteractionsOnly(s); assertThat(properties.get(TaxonUtil.TARGET_TAXON_NAME), is("Homo sapiens")); assertThat(properties.get(INTERACTION_TYPE_NAME), is("eats")); assertThat(properties.get(INTERACTION_TYPE_ID), is("http: }
@Test public void dynamicPropertiesEmptyOnNoInteractions() { String s = "targetTaxonName: Homo sapiens; targetTaxonId: https: Map<String, String> properties = parseDynamicPropertiesForInteractionsOnly(s); assertThat(properties.isEmpty(), is(true)); }
@Test public void dynamicProperties2() { String s = "sourceLifeStageName=pupae ; sourceLifeStageID= ; experimentalConditionName=in nature ; experimentalConditionID=http: Map<String, String> properties = parseDynamicPropertiesForInteractionsOnly(s); assertThat(properties.get(TaxonUtil.TARGET_TAXON_NAME), is("Mus")); assertThat(properties.get(INTERACTION_TYPE_NAME), is("inside")); assertThat(properties.get(DatasetImporterForTSV.SOURCE_LIFE_STAGE_NAME), is("pupae")); assertThat(properties.get(DatasetImporterForTSV.SOURCE_LIFE_STAGE_ID), is(nullValue())); assertThat(properties.get(INTERACTION_TYPE_ID), is("http: }