use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createDrinkingMapping.
@Test
public void createDrinkingMapping() throws TermLookupServiceException, IOException {
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_ignored.csv"))).thenReturn(null);
String mapping = "provided_interaction_type_label,provided_interaction_type_id,mapped_to_interaction_type_label,mapped_to_interaction_type_id\n" + "drinking,http://purl.obolibrary.org/obo/OMIT_0005582,eats,http://purl.obolibrary.org/obo/RO_0002470\n";
when(resourceService.retrieve(URI.create("interaction_types_mapping.csv"))).thenReturn(IOUtils.toInputStream(mapping, StandardCharsets.UTF_8));
InteractTypeMapperFactory interactTypeMapperFactory = new InteractTypeMapperFactoryImpl(resourceService);
InteractTypeMapper interactTypeMapper = interactTypeMapperFactory.create();
assertThat(interactTypeMapper.getInteractType("http://purl.obolibrary.org/obo/OMIT_0005582"), is(InteractType.ATE));
assertThat(interactTypeMapper.getInteractType("drinking"), is(InteractType.ATE));
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createInvalidTypeMape.
@Test()
public void createInvalidTypeMape() throws TermLookupServiceException, IOException {
// reproduce https://github.com/qgroom/Vespa-velutina/issues/3
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_mapping.csv"))).thenReturn(IOUtils.toInputStream("provided_interaction_type_label,provided_interaction_type_id,mapped_to_interaction_type_label,mapped_to_interaction_type_id\n" + "stings,,participates in a biotic-biotic interaction with,http://purl.obolibrary.org/obo/RO_0002574\n" + "reproductively interferes with,,participates in a biotic-biotic interaction with,http://purl.obolibrary.org/obo/RO_0002574\n", StandardCharsets.UTF_8));
InteractTypeMapperFactoryImpl interactTypeMapperFactory = new InteractTypeMapperFactoryImpl(resourceService);
InteractTypeMapper interactTypeMapper = interactTypeMapperFactory.create();
assertThat(interactTypeMapper.getInteractType("stings"), is(InteractType.INTERACTS_WITH));
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImpl method getResourceServiceForDefaultInteractionTypeMapping.
public static ResourceService getResourceServiceForDefaultInteractionTypeMapping(ResourceService service) {
return new ResourceService() {
@Override
public InputStream retrieve(URI resourceName) throws IOException {
URI supportedURI = getSupportedURI(resourceName);
return supportedURI == null || service == null ? null : service.retrieve(supportedURI);
}
URI getSupportedURI(URI resourceName) {
List<URI> supportedResources = Arrays.asList(TYPE_IGNORED_URI_DEFAULT, TYPE_MAP_URI_DEFAULT);
URI resource = URI.create("classpath:/org/globalbioticinteractions/" + resourceName);
return supportedResources.contains(resourceName) ? resource : null;
}
};
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractionListenerImplTest method processMessageWithTranslatedInteractionType.
@Test
public void processMessageWithTranslatedInteractionType() throws StudyImporterException, IOException {
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_ignored.csv"))).thenReturn(IOUtils.toInputStream("provided_interaction_type_id\nshouldBeIgnored", StandardCharsets.UTF_8)).thenReturn(IOUtils.toInputStream("provided_interaction_type_id\nshouldBeIgnored", StandardCharsets.UTF_8));
when(resourceService.retrieve(URI.create("interaction_types_mapping.csv"))).thenReturn(IOUtils.toInputStream(getTestMap(), StandardCharsets.UTF_8));
Dataset dataset = new DatasetImpl("bla", resourceService, URI.create("foo:bar"));
InteractionListenerImpl interactionListener = new InteractionListenerImpl(nodeFactory, null, null, dataset);
HashMap<String, String> interaction = new HashMap<>();
interaction.put(SOURCE_TAXON_NAME, "sourceName");
interaction.put(DatasetImporterForTSV.INTERACTION_TYPE_NAME, "shouldBeMapped");
interaction.put(TARGET_TAXON_NAME, "targetName");
interaction.put(REFERENCE_ID, "citation");
assertStudyCount(0L);
interactionListener.on(interaction);
assertStudyCount(1L);
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class SparqlClientCachingFactoryTest method expectCaching.
@Test
public void expectCaching() throws IOException {
final ResourceService resourceService = singleRequestResourceService();
final SparqlClient openBiodivClient = new SparqlClientCachingFactory().create(resourceService);
assertCitation(openBiodivClient);
assertCitation(openBiodivClient);
}
Aggregations