Revision 41433
Added by Katerina Iatropoulou over 8 years ago
modules/uoa-claims -demo/claims-demo/src/test/java/eu/dnetlib/data/claims/migration/parser/DMFParserTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.claims.migration.parser; |
2 | 2 |
|
3 |
import eu.dnetlib.data.claims.migration.Context; |
|
4 |
import eu.dnetlib.data.claims.migration.Result; |
|
5 |
import org.junit.Assert; |
|
6 |
import org.junit.Test; |
|
7 |
import org.xml.sax.SAXException; |
|
8 |
|
|
9 |
import javax.xml.parsers.ParserConfigurationException; |
|
10 |
import java.io.IOException; |
|
11 |
|
|
3 | 12 |
/** |
4 | 13 |
* Created by kiatrop on 23/2/2016. |
5 | 14 |
*/ |
... | ... | |
42 | 51 |
" </metadata>\n" + |
43 | 52 |
"</record>"; |
44 | 53 |
|
45 |
private String datasetDmf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
|
46 |
"<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" + |
|
47 |
" <header xmlns=\"http://namespace.openaire.eu/\">\n" + |
|
48 |
" <dri:objIdentifier>datacite____::f17ed62850888624de6afc5ccf7fa81f</dri:objIdentifier>\n" + |
|
49 |
" <dri:recordIdentifier>10.13140/2.1.4645.5364</dri:recordIdentifier>\n" + |
|
50 |
" <dri:dateOfCollection></dri:dateOfCollection>\n" + |
|
51 |
" <dri:mdFormat></dri:mdFormat>\n" + |
|
52 |
" <dri:mdFormatInterpretation></dri:mdFormatInterpretation>\n" + |
|
53 |
" <dri:repositoryId></dri:repositoryId>\n" + |
|
54 |
" <dr:objectIdentifier></dr:objectIdentifier>\n" + |
|
55 |
" <dr:dateOfCollection>2015-04-02T11:08:55+00:00</dr:dateOfCollection>\n" + |
|
56 |
" <oaf:datasourceprefix>datacite____</oaf:datasourceprefix>\n" + |
|
57 |
" </header>\n" + |
|
58 |
" <metadata xmlns=\"http://namespace.openaire.eu/\">\n" + |
|
59 |
" <dc:dateAccepted>2014-01-01T00:00:00Z</dc:dateAccepted>\n" + |
|
60 |
" <dc:identifier>http://dx.doi.org/10.13140%2F2.1.4645.5364</dc:identifier>\n" + |
|
61 |
" <dc:title>Valors i actituds sobre justícia distributiva: prestacions socials i fiscalitat</dc:title>\n" + |
|
62 |
" <dc:publisher>GSADI-UAB - Centre Estudis Opinió (CEO)</dc:publisher>\n" + |
|
63 |
" <oaf:collectedDatasourceid>openaire____::datacite</oaf:collectedDatasourceid>\n" + |
|
64 |
" <oaf:accessrights></oaf:accessrights>\n" + |
|
65 |
" <oaf:hostedBy name=\"Unknown Repository\" id=\"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\"/>\n" + |
|
66 |
" <oaf:collectedFrom name=\"Datacite\" id=\"openaire____::datacite\" />\n" + |
|
67 |
" \n" + |
|
68 |
" <dc:creator>Xavier Guijarro Rubinat</dc:creator>\n" + |
|
69 |
" <dc:creator>Jose A. Noguera</dc:creator>\n" + |
|
70 |
" <dc:creator>Eduardo Tapia</dc:creator>\n" + |
|
71 |
" <dc:creator>Jordi Tena-Sánchez</dc:creator>\n" + |
|
72 |
" <dc:creator>FJ Miquel Quesada</dc:creator>\n" + |
|
73 |
" <dc:creator>Mercedes Vinagre</dc:creator>\n" + |
|
74 |
" <dc:creator>FJ León</dc:creator>\n" + |
|
75 |
" <dc:creator>Toni Llàcer</dc:creator>\n" + |
|
76 |
" \n" + |
|
77 |
" <oaf:identifier identifierType=\"doi\">10.13140/2.1.4645.5364</oaf:identifier>\n" + |
|
78 |
" <dr:CobjIdentifier>10.13140/2.1.4645.5364</dr:CobjIdentifier>\n" + |
|
79 |
"\n" + |
|
80 |
"\n" + |
|
81 |
" </metadata>\n" + |
|
82 |
"</record>"; |
|
54 |
@Test |
|
55 |
public void dmf2PublicationTest() throws IOException, SAXException, ParserConfigurationException { |
|
56 |
Result result = DMFParser.dmf2Result(publicationDmf); |
|
83 | 57 |
|
58 |
Assert.assertNull(result.getAccessRights()); |
|
59 |
Assert.assertNull(result.getBestLicense()); |
|
60 |
Assert.assertEquals("openaire____::crossref", result.getCollectedFrom()); |
|
61 |
Assert.assertEquals("10.1088/0004-637X/761/1/34", result.getDoi()); |
|
62 |
Assert.assertEquals("0000-0002-1112-1292-12694010", result.getOrcidworkid()); |
|
63 |
Assert.assertNull(result.getOai()); |
|
64 |
Assert.assertEquals("crossref____::47593e13b24bcdd0f3d5573499f1d3a9", result.getOpenaireId()); |
|
65 |
Assert.assertNull(result.getPmcid()); |
|
66 |
Assert.assertEquals("A THREE-DIMENSIONAL VIEW OF THE REMNANT OF NOVA PERSEI 1901 (GK Per)", result.getTitle()); |
|
67 |
Assert.assertEquals("xml", result.getRecordFormat()); |
|
68 |
Assert.assertEquals("http://dx.doi.org/0000-0002-1112-1292-12694010", result.getExternalUrl()); |
|
69 |
Assert.assertNull(result.getEmbargoEndDate()); |
|
70 |
|
|
71 |
} |
|
72 |
|
|
84 | 73 |
private String contextDmf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
85 | 74 |
"<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" + |
86 | 75 |
" <header xmlns=\"http://namespace.openaire.eu/\">\n" + |
... | ... | |
106 | 95 |
" </metadata>\n" + |
107 | 96 |
"</record>"; |
108 | 97 |
|
98 |
@Test |
|
99 |
public void dmf2ContextTest() throws IOException, SAXException, ParserConfigurationException { |
|
100 |
Context context = DMFParser.dmf2Context(contextDmf); |
|
101 |
|
|
102 |
Assert.assertEquals("egi::country::gr", context.getOpenaireId()); |
|
103 |
Assert.assertEquals("EGI> EGI Countries> Greece", context.getTitle()); |
|
104 |
} |
|
105 |
|
|
109 | 106 |
} |
Also available in: Unified diff
DMFParserTest tests added