use of org.eol.globi.service.DOIResolver in project eol-globi-data by jhpoelen.
the class LinkerDOITest method addDOIToStudy.
@Test
public void addDOIToStudy() throws NodeFactoryException {
DOIResolver doiResolver = new DOIResolver() {
@Override
public Map<String, String> resolveDoiFor(Collection<String> references) throws IOException {
Map<String, String> doiMap = new HashMap<>();
for (String reference : references) {
doiMap.put(reference, resolveDoiFor(reference));
}
return doiMap;
}
@Override
public String resolveDoiFor(String reference) throws IOException {
return "doi:1234";
}
};
StudyNode study = getNodeFactory().getOrCreateStudy(new StudyImpl("my title", "some source", null, ExternalIdUtil.toCitation("my contr", "some description", null)));
new LinkerDOI(getGraphDb()).linkStudy(doiResolver, study);
assertThat(study.getDOI(), is("doi:1234"));
assertThat(study.getExternalId(), is("http://dx.doi.org/1234"));
assertThat(study.getCitation(), is("my contr. some description"));
study = getNodeFactory().getOrCreateStudy(new StudyImpl("my other title", "some source", null, ExternalIdUtil.toCitation("my contr", "some description", null)));
new LinkerDOI(getGraphDb()).linkStudy(new DOIResolverThatExplodes(), study);
assertThat(study.getDOI(), nullValue());
assertThat(study.getExternalId(), nullValue());
assertThat(study.getCitation(), is("my contr. some description"));
}
Aggregations