1
|
package eu.dnetlib.data.transform.xml.vtd;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.util.function.Function;
|
5
|
|
6
|
import eu.dnetlib.data.proto.OafProtos.Oaf;
|
7
|
import eu.dnetlib.data.transform.xml2.DatasetToProto;
|
8
|
import eu.dnetlib.data.transform.xml2.PublicationToProto;
|
9
|
import org.apache.commons.io.IOUtils;
|
10
|
import org.apache.commons.logging.Log;
|
11
|
import org.apache.commons.logging.LogFactory;
|
12
|
import org.junit.Test;
|
13
|
|
14
|
import static org.junit.Assert.assertNotNull;
|
15
|
|
16
|
public class VtdParserToProtoTest {
|
17
|
|
18
|
private static final Log log = LogFactory.getLog(VtdParserToProtoTest.class);
|
19
|
|
20
|
@Test
|
21
|
public void testParsePublication() throws IOException {
|
22
|
doTest("/eu/dnetlib/data/transform/publication.xml", new PublicationToProto());
|
23
|
}
|
24
|
|
25
|
@Test
|
26
|
public void testParseDataset() throws IOException {
|
27
|
doTest("/eu/dnetlib/data/transform/dataset.xml", new DatasetToProto());
|
28
|
}
|
29
|
|
30
|
@Test
|
31
|
public void testParseDataset2() throws IOException {
|
32
|
doTest("/eu/dnetlib/data/transform/dataset2.xml", new DatasetToProto());
|
33
|
}
|
34
|
|
35
|
private void doTest(final String filePath, Function<String, Oaf> f) throws IOException {
|
36
|
final String xml = IOUtils.toString(getClass().getResourceAsStream(filePath));
|
37
|
|
38
|
assertNotNull(xml);
|
39
|
|
40
|
final Oaf oaf = f.apply(xml);
|
41
|
|
42
|
assertNotNull(oaf);
|
43
|
|
44
|
log.info(oaf.toString());
|
45
|
}
|
46
|
|
47
|
}
|