dnet-hadoop/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/sx/graph/ScholexplorerParserTest.java

64 lines
1.7 KiB
Java
Raw Normal View History

2020-03-27 13:48:44 +01:00
package eu.dnetlib.dhp.sx.graph;
2020-02-19 10:07:08 +01:00
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
2020-02-19 10:07:08 +01:00
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
2020-02-19 10:07:08 +01:00
import eu.dnetlib.dhp.schema.oaf.Oaf;
import eu.dnetlib.dhp.sx.graph.parser.DatasetScholexplorerParser;
2020-11-06 17:12:31 +01:00
import eu.dnetlib.dhp.sx.graph.parser.PublicationScholexplorerParser;
2020-03-13 09:13:20 +01:00
import eu.dnetlib.scholexplorer.relation.RelationMapper;
2020-02-19 10:07:08 +01:00
public class ScholexplorerParserTest {
@Test
public void testDataciteParser() throws Exception {
String xml = IOUtils.toString(this.getClass().getResourceAsStream("dmf.xml"));
2020-02-19 10:07:08 +01:00
DatasetScholexplorerParser p = new DatasetScholexplorerParser();
List<Oaf> oaves = p.parseObject(xml, RelationMapper.load());
2020-02-19 10:07:08 +01:00
ObjectMapper m = new ObjectMapper();
m.enable(SerializationFeature.INDENT_OUTPUT);
2020-02-19 10:07:08 +01:00
oaves
.forEach(
oaf -> {
try {
System.out.println(m.writeValueAsString(oaf));
System.out.println("----------------------------");
} catch (JsonProcessingException e) {
2020-02-19 10:07:08 +01:00
}
});
}
2020-11-06 17:12:31 +01:00
@Test
public void testPublicationParser() throws Exception {
String xml = IOUtils.toString(this.getClass().getResourceAsStream("pmf.xml"));
PublicationScholexplorerParser p = new PublicationScholexplorerParser();
List<Oaf> oaves = p.parseObject(xml, RelationMapper.load());
ObjectMapper m = new ObjectMapper();
m.enable(SerializationFeature.INDENT_OUTPUT);
oaves
.forEach(
oaf -> {
try {
System.out.println(m.writeValueAsString(oaf));
System.out.println("----------------------------");
} catch (JsonProcessingException e) {
}
});
}
2020-02-19 10:07:08 +01:00
}