2020-02-19 10:07:08 +01:00
|
|
|
package eu.dnetlib.dhp.graph.scholexplorer;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
|
|
import eu.dnetlib.dhp.graph.scholexplorer.parser.DatasetScholexplorerParser;
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.Oaf;
|
2020-03-13 09:13:20 +01:00
|
|
|
import eu.dnetlib.scholexplorer.relation.RelationMapper;
|
2020-02-19 10:07:08 +01:00
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class ScholexplorerParserTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
2020-03-13 09:13:20 +01:00
|
|
|
public void testDataciteParser() throws Exception {
|
2020-02-19 10:07:08 +01:00
|
|
|
String xml = IOUtils.toString(this.getClass().getResourceAsStream("dmf.xml"));
|
|
|
|
|
|
|
|
DatasetScholexplorerParser p = new DatasetScholexplorerParser();
|
2020-03-13 09:13:20 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
oaves.forEach(oaf -> {
|
|
|
|
try {
|
|
|
|
System.out.println(m.writeValueAsString(oaf));
|
|
|
|
System.out.println("----------------------------");
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|