2020-03-31 14:41:35 +02:00
|
|
|
package eu.dnetlib.dhp.provision;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import eu.dnetlib.dhp.provision.scholix.Scholix;
|
2020-04-08 13:18:20 +02:00
|
|
|
import eu.dnetlib.dhp.provision.scholix.ScholixResource;
|
2020-04-14 17:47:36 +02:00
|
|
|
import eu.dnetlib.dhp.provision.update.CrossrefClient;
|
|
|
|
import eu.dnetlib.dhp.provision.update.Datacite2Scholix;
|
|
|
|
import eu.dnetlib.dhp.provision.update.DataciteClient;
|
2020-04-15 15:23:54 +02:00
|
|
|
import eu.dnetlib.dhp.provision.update.DataciteClientIterator;
|
2020-03-31 14:41:35 +02:00
|
|
|
import eu.dnetlib.scholexplorer.relation.RelationMapper;
|
|
|
|
import org.apache.commons.io.IOUtils;
|
2020-04-08 13:18:20 +02:00
|
|
|
import org.junit.jupiter.api.Assertions;
|
2020-03-31 14:41:35 +02:00
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
2020-04-15 15:23:54 +02:00
|
|
|
import java.io.IOException;
|
2020-03-31 14:41:35 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class DataciteClientTest {
|
|
|
|
@Test
|
|
|
|
public void dataciteSCholixTest() throws Exception {
|
|
|
|
final String json = IOUtils.toString(getClass().getResourceAsStream("datacite.json"));
|
|
|
|
final RelationMapper mapper = RelationMapper.load();
|
|
|
|
|
|
|
|
Datacite2Scholix ds = new Datacite2Scholix(mapper);
|
|
|
|
final List<Scholix> s = ds.generateScholixFromJson(json);
|
|
|
|
System.out.println(new ObjectMapper().writeValueAsString(s));
|
|
|
|
}
|
|
|
|
|
2020-04-08 13:18:20 +02:00
|
|
|
public void testResolveDataset() throws Exception {
|
2020-04-14 17:47:36 +02:00
|
|
|
DataciteClient dc = new DataciteClient("ip-90-147-167-25.ct1.garrservices.it");
|
2020-04-08 13:18:20 +02:00
|
|
|
ScholixResource datasetByDOI = dc.getDatasetByDOI("10.17182/hepdata.15392.v1/t5");
|
|
|
|
Assertions.assertNotNull(datasetByDOI);
|
|
|
|
System.out.println(new ObjectMapper().writeValueAsString(datasetByDOI));
|
2020-03-31 14:41:35 +02:00
|
|
|
|
|
|
|
|
2020-04-08 13:18:20 +02:00
|
|
|
CrossrefClient cr = new CrossrefClient("ip-90-147-167-25.ct1.garrservices.it");
|
2020-04-14 17:47:36 +02:00
|
|
|
ScholixResource crossrefByDOI = cr.getResourceByDOI("10.26850/1678-4618eqj.v35.1.2010.p41-46");
|
2020-04-08 13:18:20 +02:00
|
|
|
Assertions.assertNotNull(crossrefByDOI);
|
|
|
|
System.out.println(new ObjectMapper().writeValueAsString(crossrefByDOI));
|
2020-03-31 14:41:35 +02:00
|
|
|
}
|
|
|
|
}
|