1
|
package eu.dnetlib.data.utils;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
|
5
|
import javax.xml.bind.JAXBException;
|
6
|
|
7
|
import org.apache.commons.io.IOUtils;
|
8
|
import org.junit.Ignore;
|
9
|
import org.junit.Test;
|
10
|
|
11
|
import com.google.gson.JsonSyntaxException;
|
12
|
|
13
|
import eu.dnetlib.data.mdstore.plugins.objects.MdRecord;
|
14
|
import eu.dnetlib.data.mdstore.plugins.objects.MdRecordConvertUtils;
|
15
|
|
16
|
public class BibTexConverterTest {
|
17
|
|
18
|
@Test
|
19
|
@Ignore
|
20
|
public void testAsBibTex_1() {
|
21
|
|
22
|
final MdRecord record = new MdRecord();
|
23
|
|
24
|
record.setId("1234");
|
25
|
record.setTitle("The D-NET software toolkit A framework for the realization, maintenance, and operation of aggregative infrastructures");
|
26
|
|
27
|
record.getCreators().add("Manghi P.");
|
28
|
record.getCreators().add("Artini M.");
|
29
|
|
30
|
record.setPublisher("Emerald, Bradford, Regno Unito");
|
31
|
record.getDois().add("10.1108/PROG-08-2013-0045");
|
32
|
record.setDate(2014);
|
33
|
record.setSource("Program (Lond., 1966) 48 (2014): 322–354. doi:10.1108/PROG-08-2013-0045");
|
34
|
record.setType("Article");
|
35
|
|
36
|
final String bib = BibTexConverter.asBibTex(record);
|
37
|
|
38
|
System.out.println(bib);
|
39
|
|
40
|
}
|
41
|
|
42
|
@Test
|
43
|
@Ignore
|
44
|
public void testAsBibTex_article_source_1() {
|
45
|
|
46
|
final MdRecord record = new MdRecord();
|
47
|
|
48
|
record.setId("1234");
|
49
|
record.setType("Article");
|
50
|
|
51
|
record.setSource("Internet of Things 13 (2020): 1–14");
|
52
|
|
53
|
final String bib = BibTexConverter.asBibTex(record);
|
54
|
|
55
|
System.out.println(bib);
|
56
|
|
57
|
}
|
58
|
|
59
|
@Test
|
60
|
public void testAsBibTex_file() throws JsonSyntaxException, IOException, JAXBException {
|
61
|
|
62
|
final String xml = IOUtils.toString(getClass().getResourceAsStream("record.xml"));
|
63
|
|
64
|
final MdRecord record = MdRecordConvertUtils.fromString(xml);
|
65
|
|
66
|
final String bib = BibTexConverter.asBibTex(record);
|
67
|
|
68
|
System.out.println(bib);
|
69
|
|
70
|
}
|
71
|
}
|