use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class SparqlClientOpenBiodivFactoryTest method expectNonCaching.
@Test(expected = IOException.class)
public void expectNonCaching() throws IOException {
final ResourceService resourceService = SparqlClientCachingFactoryTest.singleRequestResourceService();
final SparqlClient openBiodivClient = new OpenBiodivClientImpl(resourceService);
DatasetImporterForPensoft.findCitationByDoi("10.3897/zookeys.306.5455", openBiodivClient);
try {
DatasetImporterForPensoft.findCitationByDoi("10.3897/zookeys.306.5455", openBiodivClient);
} catch (IOException ex) {
assertThat(ex.getCause().getMessage(), is("should not ask twice"));
throw ex;
}
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createOverrideMappingEmptyMapping.
@Test
public void createOverrideMappingEmptyMapping() throws TermLookupServiceException, IOException {
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_ignored.csv"))).thenReturn(IOUtils.toInputStream("interaction_type_ignored\nshouldBeIgnored", StandardCharsets.UTF_8));
String mapping = "provided_interaction_type_label,provided_interaction_type_id,mapped_to_interaction_type_label,mapped_to_interaction_type_id";
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();
final InteractType interactType = interactTypeMapper.getInteractType("associated with");
assertThat(interactType, is(InteractType.INTERACTS_WITH));
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createAndIgnoreTermNoMap.
@Test
public void createAndIgnoreTermNoMap() throws TermLookupServiceException, IOException {
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_ignored.csv"))).thenReturn(IOUtils.toInputStream("interaction_type_ignored\neats", StandardCharsets.UTF_8)).thenReturn(IOUtils.toInputStream("interaction_type_ignored\neats", StandardCharsets.UTF_8));
when(resourceService.retrieve(URI.create("interaction_types_mappings.csv"))).thenReturn(null);
InteractTypeMapperFactoryImpl interactTypeMapperFactory = new InteractTypeMapperFactoryImpl(resourceService);
InteractTypeMapper interactTypeMapper = interactTypeMapperFactory.create();
assertThat(interactTypeMapper.getInteractType("eats"), is(nullValue()));
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createMappingWithQuotes2.
@Test
public void createMappingWithQuotes2() throws TermLookupServiceException, IOException {
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_ignored.csv"))).thenReturn(IOUtils.toInputStream("interaction_type_ignored\nshouldBeIgnored", StandardCharsets.UTF_8));
String mapping = "provided_interaction_type_label,provided_interaction_type_id,mapped_to_interaction_type_label,mapped_to_interaction_type_id" + "\nassociates\"\" with\"\",,testing123,http://purl.obolibrary.org/obo/RO_0002437";
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();
final InteractType interactType = interactTypeMapper.getInteractType("\\\"associates with\\\"");
assertThat(interactType, is(InteractType.INTERACTS_WITH));
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createOverrideNonBlankMapping.
@Test
public void createOverrideNonBlankMapping() throws TermLookupServiceException, IOException {
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_ignored.csv"))).thenReturn(IOUtils.toInputStream("interaction_type_ignored\nshouldBeIgnored", StandardCharsets.UTF_8));
String mapping = "provided_interaction_type_label,provided_interaction_type_id,mapped_to_interaction_type_label,mapped_to_interaction_type_id\n" + "associated with,,pollinates,http://purl.obolibrary.org/obo/RO_0002455";
when(resourceService.retrieve(URI.create("interaction_types_mapping.csv"))).thenReturn(IOUtils.toInputStream(mapping, StandardCharsets.UTF_8));
InteractTypeMapperFactory interactTypeMapperFactory = new InteractTypeMapperFactoryImpl(resourceService);
InteractTypeMapper mapper = interactTypeMapperFactory.create();
assertThat(mapper.getInteractType("associated with"), is(InteractType.POLLINATES));
assertThat(mapper.getInteractType("pollinates"), is(InteractType.POLLINATES));
}
Aggregations