1 |
41412
|
katerina.i
|
package eu.dnetlib.data.claims.migration.parser;
|
2 |
|
|
|
3 |
41791
|
argiro.kok
|
import eu.dnetlib.data.claims.migration.entity.Context;
|
4 |
|
|
import eu.dnetlib.data.claims.migration.entity.Result;
|
5 |
|
|
import eu.dnetlib.data.claims.migration.handler.DMFContextHandler;
|
6 |
41433
|
katerina.i
|
import org.junit.Assert;
|
7 |
|
|
import org.junit.Test;
|
8 |
|
|
import org.xml.sax.SAXException;
|
9 |
|
|
|
10 |
|
|
import javax.xml.parsers.ParserConfigurationException;
|
11 |
41791
|
argiro.kok
|
import javax.xml.xpath.XPathExpressionException;
|
12 |
41433
|
katerina.i
|
import java.io.IOException;
|
13 |
|
|
|
14 |
41412
|
katerina.i
|
/**
|
15 |
|
|
* Created by kiatrop on 23/2/2016.
|
16 |
|
|
*/
|
17 |
|
|
public class DMFParserTest {
|
18 |
|
|
|
19 |
|
|
private String publicationDmf= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
20 |
|
|
"<record xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:prov=\"http://www.openarchives.org/OAI/2.0/provenance\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\" xmlns:dr=\"http://www.driver-repository.eu/namespace/dr\" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" +
|
21 |
|
|
" <header xmlns=\"http://namespace.openaire.eu/\">\n" +
|
22 |
|
|
" <dri:objIdentifier>crossref____::47593e13b24bcdd0f3d5573499f1d3a9</dri:objIdentifier>\n" +
|
23 |
|
|
" <dri:recordIdentifier>10.1088/0004-637X/761/1/34</dri:recordIdentifier>\n" +
|
24 |
|
|
" <dri:dateOfCollection></dri:dateOfCollection>\n" +
|
25 |
|
|
" <dri:mdFormat></dri:mdFormat>\n" +
|
26 |
|
|
" <dri:mdFormatInterpretation></dri:mdFormatInterpretation>\n" +
|
27 |
|
|
" <dri:repositoryId></dri:repositoryId>\n" +
|
28 |
|
|
" <dr:objectIdentifier></dr:objectIdentifier>\n" +
|
29 |
|
|
" <dr:dateOfCollection>2014-10-10T14:59:49+00:00</dr:dateOfCollection>\n" +
|
30 |
|
|
" <oaf:datasourceprefix>crossref____</oaf:datasourceprefix>\n" +
|
31 |
|
|
" </header>\n" +
|
32 |
|
|
" <metadata xmlns=\"http://namespace.openaire.eu/\">\n" +
|
33 |
|
|
" <dc:dateAccepted>2012-01-01T00:00:00Z</dc:dateAccepted>\n" +
|
34 |
|
|
" <dc:identifier>http://stacks.iop.org/0004-637X/761/i=1/a=34?key=crossref.d14dae8ac205453af63561a69c108e13</dc:identifier>\n" +
|
35 |
|
|
" <dc:title>A THREE-DIMENSIONAL VIEW OF THE REMNANT OF NOVA PERSEI 1901 (GK Per)</dc:title>\n" +
|
36 |
|
|
" <oaf:collectedDatasourceid>openaire____::crossref</oaf:collectedDatasourceid>\n" +
|
37 |
|
|
" <oaf:accessrights></oaf:accessrights>\n" +
|
38 |
|
|
" <oaf:hostedBy name=\"Unknown Repository\" id=\"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\"/>\n" +
|
39 |
|
|
" <oaf:collectedFrom name=\"Crossref\" id=\"openaire____::crossref\" />\n" +
|
40 |
|
|
" \n" +
|
41 |
|
|
" <dc:creator>Liimets, T.</dc:creator>\n" +
|
42 |
|
|
" <dc:creator>Corradi, R. L. M.</dc:creator>\n" +
|
43 |
|
|
" <dc:creator>Santander-García, M.</dc:creator>\n" +
|
44 |
|
|
" <dc:creator>Villaver, E.</dc:creator>\n" +
|
45 |
|
|
" <dc:creator>Rodríguez-Gil, P.</dc:creator>\n" +
|
46 |
|
|
" <dc:creator>Verro, K.</dc:creator>\n" +
|
47 |
|
|
" <dc:creator>Kolka, I.</dc:creator>\n" +
|
48 |
|
|
" \n" +
|
49 |
|
|
" <dc:identifier identifierType=\"doi\">10.1088/0004-637X/761/1/34</dc:identifier>\n" +
|
50 |
|
|
//" <dr:CobjIdentifier>10.1088/0004-637X/761/1/34</dr:CobjIdentifier>\n" +
|
51 |
|
|
" <dc:identifier identifierType=\"orcidworkid\">0000-0002-1112-1292-12694010</dc:identifier>\n" +
|
52 |
|
|
//" <dr:CobjIdentifier>0000-0002-1112-1292-12694010</dr:CobjIdentifier>" +
|
53 |
|
|
" </metadata>\n" +
|
54 |
|
|
"</record>";
|
55 |
|
|
|
56 |
41433
|
katerina.i
|
@Test
|
57 |
|
|
public void dmf2PublicationTest() throws IOException, SAXException, ParserConfigurationException {
|
58 |
|
|
Result result = DMFParser.dmf2Result(publicationDmf);
|
59 |
41412
|
katerina.i
|
|
60 |
41433
|
katerina.i
|
Assert.assertNull(result.getAccessRights());
|
61 |
|
|
Assert.assertNull(result.getBestLicense());
|
62 |
|
|
Assert.assertEquals("openaire____::crossref", result.getCollectedFrom());
|
63 |
|
|
Assert.assertEquals("10.1088/0004-637X/761/1/34", result.getDoi());
|
64 |
|
|
Assert.assertEquals("0000-0002-1112-1292-12694010", result.getOrcidworkid());
|
65 |
|
|
Assert.assertNull(result.getOai());
|
66 |
|
|
Assert.assertEquals("crossref____::47593e13b24bcdd0f3d5573499f1d3a9", result.getOpenaireId());
|
67 |
|
|
Assert.assertNull(result.getPmcid());
|
68 |
|
|
Assert.assertEquals("A THREE-DIMENSIONAL VIEW OF THE REMNANT OF NOVA PERSEI 1901 (GK Per)", result.getTitle());
|
69 |
|
|
Assert.assertEquals("xml", result.getRecordFormat());
|
70 |
41444
|
argiro.kok
|
Assert.assertEquals("http://dx.doi.org/10.1088/0004-637X/761/1/34", result.getExternalUrl());
|
71 |
41433
|
katerina.i
|
Assert.assertNull(result.getEmbargoEndDate());
|
72 |
|
|
|
73 |
|
|
}
|
74 |
|
|
|
75 |
41412
|
katerina.i
|
private String contextDmf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
76 |
|
|
"<record xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:prov=\"http://www.openarchives.org/OAI/2.0/provenance\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\" xmlns:dr=\"http://www.driver-repository.eu/namespace/dr\" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" +
|
77 |
|
|
" <header xmlns=\"http://namespace.openaire.eu/\">\n" +
|
78 |
|
|
" <dri:objIdentifier>od______1031::ec6940963d90d1e275970ed2a0ac2508</dri:objIdentifier>\n" +
|
79 |
|
|
" <dri:recordIdentifier>od______1031::ec6940963d90d1e275970ed2a0ac2508</dri:recordIdentifier>\n" +
|
80 |
|
|
" <dri:dateOfCollection></dri:dateOfCollection>\n" +
|
81 |
|
|
" <dri:mdFormat></dri:mdFormat>\n" +
|
82 |
|
|
" <dri:mdFormatInterpretation></dri:mdFormatInterpretation>\n" +
|
83 |
|
|
" <dri:repositoryId></dri:repositoryId>\n" +
|
84 |
|
|
" <dr:objectIdentifier></dr:objectIdentifier>\n" +
|
85 |
|
|
" <dr:dateOfCollection>2015-01-22T11:40:51+00:00</dr:dateOfCollection>\n" +
|
86 |
|
|
" <oaf:datasourceprefix>openaire____</oaf:datasourceprefix>\n" +
|
87 |
|
|
" </header>\n" +
|
88 |
|
|
" <metadata xmlns=\"http://namespace.openaire.eu/\">\n" +
|
89 |
|
|
" <oaf:collectedDatasourceid></oaf:collectedDatasourceid>\n" +
|
90 |
|
|
" <oaf:hostedBy name=\"\" id=\"\"/>\n" +
|
91 |
|
|
" <oaf:collectedFrom name=\"\" id=\"\" />\n" +
|
92 |
|
|
" \n" +
|
93 |
|
|
" <oaf:concept id=\"egi::country::gr\" />\n" +
|
94 |
|
|
"\n" +
|
95 |
|
|
"\n" +
|
96 |
|
|
"\n" +
|
97 |
|
|
" </metadata>\n" +
|
98 |
|
|
"</record>";
|
99 |
|
|
|
100 |
41433
|
katerina.i
|
@Test
|
101 |
41791
|
argiro.kok
|
public void dmf2ContextTest() throws IOException, SAXException, ParserConfigurationException, XPathExpressionException {
|
102 |
|
|
DMFParser dmfParser= new DMFParser();
|
103 |
41793
|
argiro.kok
|
DMFContextHandler dmfContextHandler = new DMFContextHandler();
|
104 |
53031
|
argiro.kok
|
Context context = dmfContextHandler.extractContextFromDMF(contextDmf, false);
|
105 |
41433
|
katerina.i
|
|
106 |
|
|
Assert.assertEquals("egi::country::gr", context.getOpenaireId());
|
107 |
52274
|
argiro.kok
|
Assert.assertEquals("EGI Federation> EGI Countries> Greece", context.getTitle());
|
108 |
41433
|
katerina.i
|
}
|
109 |
|
|
|
110 |
41412
|
katerina.i
|
}
|