use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createAndIgnoreTermWithThrowingOnMapRetrieve.
@Test
public void createAndIgnoreTermWithThrowingOnMapRetrieve() 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"))).thenThrow(new IOException("kaboom!"));
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 createAndMapTerm.
@Test
public void createAndMapTerm() 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));
when(resourceService.retrieve(URI.create("interaction_types_mapping.csv"))).thenReturn(IOUtils.toInputStream(getTestMap(), StandardCharsets.UTF_8));
InteractTypeMapperFactoryImpl interactTypeMapperFactory = new InteractTypeMapperFactoryImpl(resourceService);
InteractTypeMapper interactTypeMapper = interactTypeMapperFactory.create();
assertThat(interactTypeMapper.getInteractType("shouldBeMapped"), is(InteractType.INTERACTS_WITH));
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createAndMapTermNoIgnore.
@Test
public void createAndMapTermNoIgnore() throws TermLookupServiceException, IOException {
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_ignored.csv"))).thenReturn(null).thenReturn(null);
when(resourceService.retrieve(URI.create("interaction_types_mapping.csv"))).thenReturn(IOUtils.toInputStream(getTestMap(), StandardCharsets.UTF_8));
InteractTypeMapperFactoryImpl interactTypeMapperFactory = new InteractTypeMapperFactoryImpl(resourceService);
InteractTypeMapper interactTypeMapper = interactTypeMapperFactory.create();
assertThat(interactTypeMapper.getInteractType("shouldBeMapped"), is(InteractType.INTERACTS_WITH));
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createAndFailedToAccessMappingResource.
@Test
public void createAndFailedToAccessMappingResource() 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)).thenReturn(IOUtils.toInputStream("interaction_type_ignored\nshouldBeIgnored", StandardCharsets.UTF_8));
when(resourceService.retrieve(URI.create("interaction_types_mapping.csv"))).thenReturn(null);
InteractTypeMapperFactory interactTypeMapperFactory = new InteractTypeMapperFactoryImpl(resourceService);
InteractTypeMapper interactTypeMapper = interactTypeMapperFactory.create();
assertTrue(interactTypeMapper.shouldIgnoreInteractionType("shouldBeIgnored"));
}
use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createAndNoIgnoreResource.
@Test
public void createAndNoIgnoreResource() throws TermLookupServiceException, IOException {
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_ignored.csv"))).thenThrow(new IOException("kaboom!"));
when(resourceService.retrieve(URI.create("interaction_types_mapping.csv"))).thenThrow(new IOException("kaboom!"));
InteractTypeMapperFactoryImpl interactTypeMapperFactory = new InteractTypeMapperFactoryImpl(resourceService);
final InteractTypeMapper interactTypeMapper = interactTypeMapperFactory.create();
assertNotNull(interactTypeMapper);
}
Aggregations