use of org.eol.globi.util.InteractTypeMapper in project eol-globi-data by jhpoelen.
the class InteractionListenerWithInteractionTypeMappingTest method withTaxonHierarchy.
@Test
public void withTaxonHierarchy() throws StudyImporterException {
final List<Map<String, String>> links = new ArrayList<Map<String, String>>();
InteractionListener listener = new InteractionListenerWithInteractionTypeMapping(links::add, new InteractTypeMapper() {
@Override
public boolean shouldIgnoreInteractionType(String nameOrId) {
return false;
}
@Override
public InteractType getInteractType(String nameOrId) {
return null;
}
}, new NullImportLogger());
listener.on(new HashMap<String, String>() {
{
put(INTERACTION_TYPE_NAME, "eats");
put(TaxonUtil.TARGET_TAXON_GENUS, "Donald");
put(TaxonUtil.TARGET_TAXON_SPECIFIC_EPITHET, "duck");
}
});
assertThat(links.size(), is(1));
assertThat(links.get(0).get(TaxonUtil.TARGET_TAXON_NAME), is("Donald duck"));
assertThat(links.get(0).get(TaxonUtil.TARGET_TAXON_PATH_NAMES), is("genus | species"));
assertThat(links.get(0).get(TaxonUtil.TARGET_TAXON_PATH), is("Donald | Donald duck"));
}
use of org.eol.globi.util.InteractTypeMapper in project eol-globi-data by jhpoelen.
the class DatasetImporterForPensoftIT method singleTableHostInColumnHeader.
@Test
public void singleTableHostInColumnHeader() throws IOException, TermLookupServiceException, StudyImporterException {
final JsonNode tableObj = getTableObj();
assertNotNull(tableObj);
tableObj.get("article_doi");
final JsonNode annotations = tableObj.get("annotations");
for (JsonNode annotation : annotations) {
final InteractTypeMapper interactTypeMapper = new InteractTypeMapperFactoryImpl().create();
if (annotation.has("id")) {
final InteractType interactType = interactTypeMapper.getInteractType(annotation.get("id").asText());
}
if (annotation.has("context")) {
String verbatimInteraction = annotation.get("context").asText();
}
annotation.get("row");
annotation.get("column");
annotation.get("possition");
}
tableObj.get("caption");
List<Map<String, String>> rowValues = new ArrayList<>();
InteractionListener listener = new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
rowValues.add(interaction);
}
};
parseRowsAndEnrich(tableObj, listener, getResourceServiceTest());
}
use of org.eol.globi.util.InteractTypeMapper in project eol-globi-data by jhpoelen.
the class InteractionListenerWithInteractionTypeMappingTest method withVerbatimInteractionType.
@Test
public void withVerbatimInteractionType() throws StudyImporterException {
final List<Map<String, String>> links = new ArrayList<>();
InteractionListener listener = new InteractionListenerWithInteractionTypeMapping(links::add, new InteractTypeMapper() {
@Override
public boolean shouldIgnoreInteractionType(String nameOrId) {
return false;
}
@Override
public InteractType getInteractType(String nameOrId) {
return InteractType.ATE;
}
}, new NullImportLogger());
listener.on(new HashMap<String, String>() {
{
put(INTERACTION_TYPE_NAME, "Donald");
put(INTERACTION_TYPE_ID, "duck");
}
});
assertThat(links.size(), is(1));
assertThat(links.get(0).get(INTERACTION_TYPE_ID_VERBATIM), is("duck"));
assertThat(links.get(0).get(INTERACTION_TYPE_NAME_VERBATIM), is("Donald"));
assertThat(links.get(0).get(INTERACTION_TYPE_ID), is("http://purl.obolibrary.org/obo/RO_0002470"));
assertThat(links.get(0).get(INTERACTION_TYPE_NAME), is("eats"));
}
use of org.eol.globi.util.InteractTypeMapper in project eol-globi-data by jhpoelen.
the class InteractionListenerWithInteractionTypeMappingTest method withBlankInteractionType.
@Test
public void withBlankInteractionType() throws StudyImporterException {
final List<Map<String, String>> links = new ArrayList<>();
InteractionListener listener = new InteractionListenerWithInteractionTypeMapping(links::add, new InteractTypeMapper() {
@Override
public boolean shouldIgnoreInteractionType(String nameOrId) {
return false;
}
@Override
public InteractType getInteractType(String nameOrId) {
return InteractType.ATE;
}
}, new NullImportLogger());
listener.on(new HashMap<String, String>() {
{
put(INTERACTION_TYPE_NAME, "");
put(INTERACTION_TYPE_ID, "");
}
});
assertThat(links.size(), is(1));
assertThat(links.get(0).get(INTERACTION_TYPE_ID), is("http://purl.obolibrary.org/obo/RO_0002470"));
assertThat(links.get(0).get(INTERACTION_TYPE_NAME), is("eats"));
assertThat(links.get(0).get(INTERACTION_TYPE_ID_VERBATIM), is(""));
assertThat(links.get(0).get(INTERACTION_TYPE_NAME_VERBATIM), is(""));
}
use of org.eol.globi.util.InteractTypeMapper in project eol-globi-data by jhpoelen.
the class InteractionListenerWithInteractionTypeMappingTest method withNullInteractionType.
@Test
public void withNullInteractionType() throws StudyImporterException {
final List<Map<String, String>> links = new ArrayList<>();
InteractionListener listener = new InteractionListenerWithInteractionTypeMapping(links::add, new InteractTypeMapper() {
@Override
public boolean shouldIgnoreInteractionType(String nameOrId) {
return false;
}
@Override
public InteractType getInteractType(String nameOrId) {
return InteractType.ATE;
}
}, new NullImportLogger());
listener.on(new HashMap<String, String>() {
{
put(INTERACTION_TYPE_NAME, null);
put(INTERACTION_TYPE_ID, null);
}
});
assertThat(links.size(), is(1));
assertThat(links.get(0).get(INTERACTION_TYPE_ID), is(nullValue()));
assertThat(links.get(0).get(INTERACTION_TYPE_NAME), is(nullValue()));
assertThat(links.get(0).get(INTERACTION_TYPE_ID_VERBATIM), is(nullValue()));
assertThat(links.get(0).get(INTERACTION_TYPE_NAME_VERBATIM), is(nullValue()));
}
Aggregations