use of org.eol.globi.service.ResourceService in project eol-globi-data by jhpoelen.
the class InteractTypeMapperFactoryImplTest method createAndMapTermThrowOnMissingIgnore.
@Test
public void createAndMapTermThrowOnMissingIgnore() 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"))).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 duplicateProvidedLabelButSeparateProvidedIds.
@Test
public void duplicateProvidedLabelButSeparateProvidedIds() throws TermLookupServiceException, 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("provided_interaction_type_label,provided_interaction_type_id,mapped_to_interaction_type_label,mapped_to_interaction_type_id" + "\nshouldBeMapped,id1,interactsWith, http://purl.obolibrary.org/obo/RO_0002437\n" + "\nshouldBeMapped,id2," + InteractType.ATE.getLabel() + "," + InteractType.ATE.getIRI(), StandardCharsets.UTF_8));
InteractTypeMapperFactoryImpl interactTypeMapperFactory = new InteractTypeMapperFactoryImpl(resourceService);
InteractTypeMapper interactTypeMapper = interactTypeMapperFactory.create();
assertThat(interactTypeMapper.getInteractType("id1"), is(InteractType.INTERACTS_WITH));
assertThat(interactTypeMapper.getInteractType("id2"), is(InteractType.ATE));
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 createMappingWithQuotes.
@Test
public void createMappingWithQuotes() 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\\\"associates 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 createIgnoreServiceMock.
public InteractTypeMapperImpl createIgnoreServiceMock() throws IOException, TermLookupServiceException {
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));
TermLookupService ignoreTermService = InteractTypeMapperFactoryImpl.getIgnoredTermService(resourceService, "provided_interaction_type_id", URI.create("interaction_types_ignored.csv"));
TermLookupService termMapper = Mockito.mock(TermLookupService.class);
verify(termMapper, never()).lookupTermByName(anyString());
return new InteractTypeMapperImpl(ignoreTermService, termMapper);
}
Aggregations