Project

General

Profile

1
package eu.dnetlib.data.claims.parser;
2

    
3
import eu.dnetlib.data.claims.entity.Result;
4
import eu.dnetlib.data.claims.utils.ClaimUtils;
5
import org.apache.log4j.BasicConfigurator;
6
import org.junit.Assert;
7
import org.junit.Before;
8
import org.junit.Test;
9

    
10
/**
11
 * Created by kiatrop on 23/2/2016.
12
 */
13
public class ExternalParserTest {
14

    
15

    
16
    @Before
17
    public void init() throws Exception {
18
        BasicConfigurator.configure();
19
    }
20
    private String crossrefJson = "{\"status\":\"ok\",\"message-type\":\"work-list\",\"message-version\":\"1.0.0\",\"message\":" +
21
            "{\"query\":{\"search-terms\":null,\"start-index\":0},\"items-per-page\":20,\"items\":[{\"indexed\":" +
22
            "{\"date-parts\":[[2015,12,28]], \"date-time\":\"2015-12-28T17:45:59Z\",\"timestamp\":1451324759779}," +
23
            "\"reference-count\":0,\"publisher\":\"Society for Neuroscience\", \"issue\":\"17\"," +
24
            "\"published-print\":{\"date-parts\":[[2012,4,25]]},\"DOI\":\"10.1523\\/jneurosci.2900-11.2012\"," +
25
            "\"type\":\"journal-article\",\"created\": {\"date-parts\":[[2012,4,25]]," +
26
            "\"date-time\":\"2012-04-25T16:38:54Z\",\"timestamp\":1335371934000},\"page\":\"5728-5736\"," +
27
            "\"source\":\"CrossRef\",\"title\":[\"Imaging Microglial\\/Macrophage Activation in Spinal Cords of " +
28
            "Experimental Autoimmune Encephalomyelitis Rats by Positron Emission Tomography Using the Mitochondrial " +
29
            "18 kDa Translocator Protein Radioligand [18F]DPA-714\"]," +
30
            "\"prefix\":\"http:\\/\\/id.crossref.org\\/prefix\\/10.1523\",\"volume\":\"32\",\"author\":" +
31
            "[{\"affiliation\":[],\"family\":\"Abourbeh\",\"given\":\"G.\"},{\"affiliation\":[],\"family\":\"Theze\"," +
32
            "\"given\":\"B.\"},{\"affiliation\":[],\"family\":\"Maroy\",\"given\":\"R.\"},{\"affiliation\":[],\"family\":" +
33
            "\"Dubois\",\"given\":\"A.\"},{\"affiliation\":[],\"family\":\"Brulon\",\"given\":\"V.\"}," +
34
            "{\"affiliation\":[],\"family\":\"Fontyn\",\"given\":\"Y.\"},{\"affiliation\":[],\"family\":\"Dolle\"," +
35
            "\"given\":\"F.\"},{\"affiliation\":[],\"family\":\"Tavitian\",\"given\":\"B.\"},{\"affiliation\":[]," +
36
            "\"family\":\"Boisgard\",\"given\":\"R.\"}],\"member\":\"http:\\/\\/id.crossref.org\\/member\\/393\"," +
37
            "\"published-online\":{\"date-parts\":[[2012,4,25]]},\"container-title\":[\"Journal of Neuroscience\"]," +
38
            "\"deposited\":{\"date-parts\":[[2014,2,27]],\"date-time\":\"2014-02-27T06:42:02Z\",\"timestamp\":1393483322000}," +
39
            "\"score\":1.0,\"subtitle\":[],\"issued\":{\"date-parts\":[[2012,4,25]]}," +
40
            "\"URL\":\"http:\\/\\/dx.doi.org\\/10.1523\\/jneurosci.2900-11.2012\",\"ISSN\":[\"0270-6474\",\"1529-2401\"]," +
41
            "\"subject\":[\"Neuroscience(all)\"]}],\"total-results\":1,\"facets\":{}}}" +
42
            "";
43

    
44

    
45
    @Test
46
    public void crossref2ResultTest(){
47
        Result result = ExternalRecordParser.crossref2Result(crossrefJson);
48

    
49
        Assert.assertNull(result.getAccessRights());
50
        Assert.assertNull(result.getBestLicense());
51
        Assert.assertEquals("openaire____::crossref", result.getCollectedFrom());
52
        Assert.assertEquals("10.1523/jneurosci.2900-11.2012", result.getDoi());
53
        Assert.assertNull(result.getOai());
54
        Assert.assertNotNull(result.getOpenaireId());//        Assert.assertNull(result.getOpenaireId());
55
        Assert.assertNull(result.getPmcid());
56
        Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType());
57
        Assert.assertEquals("Imaging Microglial/Macrophage Activation in Spinal Cords of Experimental Autoimmune Encephalomyelitis Rats by Positron Emission Tomography Using the Mitochondrial 18 kDa Translocator Protein Radioligand [18F]DPA-714", result.getTitle());
58
        Assert.assertEquals("json", result.getRecordFormat());
59
        Assert.assertEquals("https://dx.doi.org/10.1523/jneurosci.2900-11.2012", result.getExternalUrl());
60
        Assert.assertNull(result.getEmbargoEndDate());
61
        Assert.assertNull(result.getOrcidworkid());
62

    
63
        Assert.assertEquals(9, result.getAuthors().size());
64
        Assert.assertEquals("G. Abourbeh", result.getAuthors().get(0+""));
65
        Assert.assertEquals("Y. Fontyn", result.getAuthors().get(5+""));
66
    }
67

    
68
    private String orcidXml2 = "<orcid-message xmlns=\"http://www.orcid.org/ns/orcid\">\n" +
69
            "    <message-version>1.1</message-version>\n" +
70
            "    <orcid-profile type=\"user\">\n" +
71
            "        <orcid-identifier>\n" +
72
            "            <uri>http://orcid.org/0000-0002-9414-646X</uri>\n" +
73
            "            <path>0000-0002-9414-646X</path>\n" +
74
            "            <host>orcid.org</host>\n" +
75
            "        </orcid-identifier>\n" +
76
            "        <orcid-preferences>\n" +
77
            "            <locale>es</locale>\n" +
78
            "        </orcid-preferences>\n" +
79
            "        <orcid-history>\n" +
80
            "            <creation-method>website</creation-method>\n" +
81
            "            <completion-date>2013-01-11T14:07:54.194Z</completion-date>\n" +
82
            "            <submission-date>2013-01-11T13:27:46.558Z</submission-date>\n" +
83
            "            <last-modified-date>2016-01-27T16:06:13.543Z</last-modified-date>\n" +
84
            "            <claimed>true</claimed>\n" +
85
            "        </orcid-history>\n" +
86
            "        <orcid-activities>\n" +
87
            "            <orcid-works>\n" +
88
            "                <orcid-work put-code=\"21755327\" visibility=\"public\">\n" +
89
            "                    <work-title>\n" +
90
            "                        <title>Providing Ubiquitous Positioning in Outdoor Environments</title>\n" +
91
            "                    </work-title>\n" +
92
            "                    <journal-title>2015 IEEE International Conference on Systems, Man, and Cybernetics</journal-title>\n" +
93
            "                    <work-citation>\n" +
94
            "                        <work-citation-type>bibtex</work-citation-type>\n" +
95
            "                        <citation>@inproceedings{Moreno_2015,doi = {10.1109/smc.2015.229},url = {http://dx.doi.org/10.1109/smc.2015.229},year = 2015,month = {oct},publisher = {Institute of Electrical {\\&amp;} Electronics Engineers ({IEEE})},author = {Daniel Moreno and Sergio F. Ochoa and Roc Meseguer},title = {Providing Ubiquitous Positioning in Outdoor Environments},booktitle = {2015 {IEEE} International Conference on Systems, Man, and Cybernetics}}</citation>\n" +
96
            "                    </work-citation>\n" +
97
            "                    <work-type>conference-paper</work-type>\n" +
98
            "                    <publication-date>\n" +
99
            "                        <year>2015</year>\n" +
100
            "                        <month>10</month>\n" +
101
            "                    </publication-date>\n" +
102
            "                    <work-external-identifiers>\n" +
103
            "                        <work-external-identifier>\n" +
104
            "                            <work-external-identifier-type>doi</work-external-identifier-type>\n" +
105
            "                            <work-external-identifier-id>10.1109/smc.2015.229</work-external-identifier-id>\n" +
106
            "                        </work-external-identifier>\n" +
107
            "                    </work-external-identifiers>\n" +
108
            "                    <work-contributors>\n" +
109
            "                        <contributor>\n" +
110
            "                            <credit-name visibility=\"public\">Daniel Moreno</credit-name>\n" +
111
            "                            <contributor-attributes>\n" +
112
            "                                <contributor-role>author</contributor-role>\n" +
113
            "                            </contributor-attributes>\n" +
114
            "                        </contributor>\n" +
115
            "                        <contributor>\n" +
116
            "                            <credit-name visibility=\"public\">Sergio F. Ochoa</credit-name>\n" +
117
            "                            <contributor-attributes>\n" +
118
            "                                <contributor-role>author</contributor-role>\n" +
119
            "                            </contributor-attributes>\n" +
120
            "                        </contributor>\n" +
121
            "                        <contributor>\n" +
122
            "                            <credit-name visibility=\"public\">Roc Meseguer</credit-name>\n" +
123
            "                            <contributor-attributes>\n" +
124
            "                                <contributor-role>author</contributor-role>\n" +
125
            "                            </contributor-attributes>\n" +
126
            "                        </contributor>\n" +
127
            "                    </work-contributors>\n" +
128
            "                    <work-source>\n" +
129
            "                        <uri>http://orcid.org/0000-0002-3054-1567</uri>\n" +
130
            "                        <path>0000-0002-3054-1567</path>\n" +
131
            "                        <host>orcid.org</host>\n" +
132
            "                    </work-source>\n" +
133
            "                </orcid-work>\n" +
134
            "                <orcid-work put-code=\"19191618\" visibility=\"public\">\n" +
135
            "                    <work-title>\n" +
136
            "                        <title>A Context-Aware Model to Provide Positioning in Disaster Relief Scenarios</title>\n" +
137
            "                    </work-title>\n" +
138
            "                    <journal-title>Sensors</journal-title>\n" +
139
            "                    <work-citation>\n" +
140
            "                        <work-citation-type>bibtex</work-citation-type>\n" +
141
            "                        <citation>@article{Moreno_2015,doi = {10.3390/s151025176},url = {http://dx.doi.org/10.3390/s151025176},year = 2015,month = {sep},publisher = {{MDPI} {AG}},volume = {15},number = {10},pages = {25176--25207},author = {Daniel Moreno and Sergio Ochoa and Roc Meseguer},title = {A Context-Aware Model to Provide Positioning in Disaster Relief Scenarios},journal = {Sensors}}</citation>\n" +
142
            "                    </work-citation>\n" +
143
            "                    <work-type>journal-article</work-type>\n" +
144
            "                    <publication-date>\n" +
145
            "                        <year>2015</year>\n" +
146
            "                        <month>09</month>\n" +
147
            "                    </publication-date>\n" +
148
            "                    <work-external-identifiers>\n" +
149
            "                        <work-external-identifier>\n" +
150
            "                            <work-external-identifier-type>doi</work-external-identifier-type>\n" +
151
            "                            <work-external-identifier-id>10.3390/s151025176</work-external-identifier-id>\n" +
152
            "                        </work-external-identifier>\n" +
153
            "                    </work-external-identifiers>\n" +
154
            "                    <work-contributors>\n" +
155
            "                        <contributor>\n" +
156
            "                            <credit-name visibility=\"public\">Daniel Moreno</credit-name>\n" +
157
            "                            <contributor-attributes>\n" +
158
            "                                <contributor-role>author</contributor-role>\n" +
159
            "                            </contributor-attributes>\n" +
160
            "                        </contributor>\n" +
161
            "                        <contributor>\n" +
162
            "                            <credit-name visibility=\"public\">Sergio Ochoa</credit-name>\n" +
163
            "                            <contributor-attributes>\n" +
164
            "                                <contributor-role>author</contributor-role>\n" +
165
            "                            </contributor-attributes>\n" +
166
            "                        </contributor>\n" +
167
            "                        <contributor>\n" +
168
            "                            <credit-name visibility=\"public\">Roc Meseguer</credit-name>\n" +
169
            "                            <contributor-attributes>\n" +
170
            "                                <contributor-role>author</contributor-role>\n" +
171
            "                            </contributor-attributes>\n" +
172
            "                        </contributor>\n" +
173
            "                    </work-contributors>\n" +
174
            "                    <work-source>\n" +
175
            "                        <uri>http://orcid.org/0000-0002-3054-1567</uri>\n" +
176
            "                        <path>0000-0002-3054-1567</path>\n" +
177
            "                        <host>orcid.org</host>\n" +
178
            "                    </work-source>\n" +
179
            "                </orcid-work>" +
180
            "</orcid-works></orcid-activities></orcid-profile></orcid-message>";
181

    
182
    private String orcidXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
183
            "<activities:works path=\"/0000-0002-9414-646X/works\" xmlns:internal=\"http://www.orcid.org/ns/internal\" xmlns:funding=\"http://www.orcid.org/ns/funding\" xmlns:preferences=\"http://www.orcid.org/ns/preferences\" xmlns:address=\"http://www.orcid.org/ns/address\" xmlns:education=\"http://www.orcid.org/ns/education\" xmlns:work=\"http://www.orcid.org/ns/work\" xmlns:deprecated=\"http://www.orcid.org/ns/deprecated\" xmlns:other-name=\"http://www.orcid.org/ns/other-name\" xmlns:history=\"http://www.orcid.org/ns/history\" xmlns:employment=\"http://www.orcid.org/ns/employment\" xmlns:error=\"http://www.orcid.org/ns/error\" xmlns:common=\"http://www.orcid.org/ns/common\" xmlns:person=\"http://www.orcid.org/ns/person\" xmlns:activities=\"http://www.orcid.org/ns/activities\" xmlns:record=\"http://www.orcid.org/ns/record\" xmlns:researcher-url=\"http://www.orcid.org/ns/researcher-url\" xmlns:peer-review=\"http://www.orcid.org/ns/peer-review\" xmlns:personal-details=\"http://www.orcid.org/ns/personal-details\" xmlns:bulk=\"http://www.orcid.org/ns/bulk\" xmlns:keyword=\"http://www.orcid.org/ns/keyword\" xmlns:email=\"http://www.orcid.org/ns/email\" xmlns:external-identifier=\"http://www.orcid.org/ns/external-identifier\">\n" +
184
            "    <common:last-modified-date>2017-11-07T11:56:05.454Z</common:last-modified-date>\n" +
185

    
186
            "    <activities:group>\n" +
187
            "        <common:last-modified-date>2016-01-22T14:32:26.233Z</common:last-modified-date>\n" +
188
            "        <common:external-ids>\n" +
189
            "            <common:external-id>\n" +
190
            "                <common:external-id-type>doi</common:external-id-type>\n" +
191
            "                <common:external-id-value>10.1109/smc.2015.229</common:external-id-value>\n" +
192
            "                <common:external-id-relationship>self</common:external-id-relationship>\n" +
193
            "            </common:external-id>\n" +
194
            "        </common:external-ids>\n" +
195
            "        <work:work-summary put-code=\"21755327\" path=\"/0000-0002-9414-646X/work/21755327\" visibility=\"public\" display-index=\"0\">\n" +
196
            "            <common:created-date>2016-01-22T14:30:35.071Z</common:created-date>\n" +
197
            "            <common:last-modified-date>2016-01-22T14:32:26.233Z</common:last-modified-date>\n" +
198
            "            <common:source>\n" +
199
            "                <common:source-client-id>\n" +
200
            "                    <common:uri>https://orcid.org/client/0000-0002-3054-1567</common:uri>\n" +
201
            "                    <common:path>0000-0002-3054-1567</common:path>\n" +
202
            "                    <common:host>orcid.org</common:host>\n" +
203
            "                </common:source-client-id>\n" +
204
            "                <common:source-name>CrossRef Metadata Search</common:source-name>\n" +
205
            "            </common:source>\n" +
206
            "            <work:title>\n" +
207
            "                <common:title>Providing Ubiquitous Positioning in Outdoor Environments</common:title>\n" +
208
            "            </work:title>\n" +
209
            "            <common:external-ids>\n" +
210
            "                <common:external-id>\n" +
211
            "                    <common:external-id-type>doi</common:external-id-type>\n" +
212
            "                    <common:external-id-value>10.1109/smc.2015.229</common:external-id-value>\n" +
213
            "                    <common:external-id-relationship>self</common:external-id-relationship>\n" +
214
            "                </common:external-id>\n" +
215
            "            </common:external-ids>\n" +
216
            "            <work:type>conference-paper</work:type>\n" +
217
            "            <common:publication-date>\n" +
218
            "                <common:year>2015</common:year>\n" +
219
            "                <common:month>10</common:month>\n" +
220
            "            </common:publication-date>\n" +
221
            "        </work:work-summary>\n" +
222
            "    </activities:group>\n" +
223
            "<activities:group><common:last-modified-date>2018-04-18T14:40:54.953Z</common:last-modified-date><common:external-ids><common:external-id><common:external-id-type>arxiv</common:external-id-type><common:external-id-value>/oup/backfile/content_public/journal/icesjms/pap/10.1093_icesjms_fsy027/1/fsy027.pdf</common:external-id-value><common:external-id-relationship>self</common:external-id-relationship></common:external-id><common:external-id><common:external-id-type>doi</common:external-id-type><common:external-id-value>10.1093/icesjms/fsy027</common:external-id-value><common:external-id-relationship>self</common:external-id-relationship></common:external-id></common:external-ids>" +
224
            "<work:work-summary put-code=\"43079714\" path=\"/0000-0001-5264-4324/work/43079714\" visibility=\"public\" display-index=\"1\"><common:created-date>2018-03-29T08:12:17.179Z</common:created-date><common:last-modified-date>2018-03-29T08:12:17.179Z</common:last-modified-date><common:source><common:source-orcid><common:uri>https://orcid.org/0000-0001-5264-4324</common:uri><common:path>0000-0001-5264-4324</common:path><common:host>orcid.org</common:host></common:source-orcid><common:source-name>Bastien Mérigot</common:source-name></common:source>" +
225
            "<work:title><common:title>A three-dimensional view on biodiversity changes: spatial, temporal, and functional perspectives on fish communities in the Baltic Sea</common:title></work:title>" +
226
            "<common:external-ids><common:external-id><common:external-id-type>doi</common:external-id-type><common:external-id-value>10.1093/icesjms/fsy027</common:external-id-value><common:external-id-relationship>self</common:external-id-relationship></common:external-id><common:external-id><common:external-id-type>arxiv</common:external-id-type><common:external-id-value>/oup/backfile/content_public/journal/icesjms/pap/10.1093_icesjms_fsy027/1/fsy027.pdf</common:external-id-value><common:external-id-relationship>self</common:external-id-relationship></common:external-id></common:external-ids><work:type>journal-article</work:type><common:publication-date><common:year>2018</common:year></common:publication-date></work:work-summary><work:work-summary put-code=\"43766400\" path=\"/0000-0001-5264-4324/work/43766400\" visibility=\"public\" display-index=\"0\"><common:created-date>2018-04-18T14:40:54.953Z</common:created-date><common:last-modified-date>2018-04-18T14:40:54.953Z</common:last-modified-date><common:source><common:source-client-id><common:uri>https://orcid.org/client/0000-0003-1377-5676</common:uri><common:path>0000-0003-1377-5676</common:path><common:host>orcid.org</common:host></common:source-client-id><common:source-name>ResearcherID</common:source-name></common:source><work:title><common:title>A three-dimensional view on biodiversity changes: spatial, temporal, and functional perspectives on fish communities in the Baltic Sea</common:title></work:title><common:external-ids><common:external-id><common:external-id-type>doi</common:external-id-type><common:external-id-value>10.1093/icesjms/fsy027</common:external-id-value><common:external-id-relationship>self</common:external-id-relationship></common:external-id></common:external-ids><work:type>journal-article</work:type><common:publication-date><common:year>2018</common:year></common:publication-date></work:work-summary></activities:group>"+
227

    
228
            "</activities:works>\n";
229
    @Test
230
    public void orcid2ResultTest() {
231
        Result result = ExternalRecordParser.orcid2Result(orcidXml, "0000-0002-9414-646X-21755327");
232
        System.out.println(result.getTitle() + result.getAccessRights());
233
        Assert.assertNull(result.getAccessRights());
234
        Assert.assertNull(result.getBestLicense());
235
        Assert.assertEquals("openaire____::orcid", result.getCollectedFrom());
236
        Assert.assertEquals("10.1109/smc.2015.229", result.getDoi());
237
        Assert.assertEquals("0000-0002-9414-646X-21755327", result.getOrcidworkid());
238
        Assert.assertNull(result.getOai());
239
        Assert.assertNotNull(result.getOpenaireId());//        Assert.assertNull(result.getOpenaireId());
240
        Assert.assertNull(result.getPmcid());
241
        Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType());
242
        Assert.assertEquals("Providing Ubiquitous Positioning in Outdoor Environments", result.getTitle());
243
        Assert.assertEquals("xml", result.getRecordFormat());
244
        Assert.assertEquals("https://dx.doi.org/10.1109/smc.2015.229", result.getExternalUrl());
245
        Assert.assertNull(result.getEmbargoEndDate());
246

    
247
    }
248
    @Test
249
    public void orcid2Result2Test() {
250
        Result result = ExternalRecordParser.orcid2Result(orcidXml, "0000-0001-5264-4324-43079714");
251
        System.out.println(result);
252
        Assert.assertNull(result.getAccessRights());
253
        Assert.assertNull(result.getBestLicense());
254
        Assert.assertEquals("openaire____::orcid", result.getCollectedFrom());
255
        Assert.assertEquals("10.1093/icesjms/fsy027", result.getDoi());
256
        Assert.assertEquals("0000-0001-5264-4324-43079714", result.getOrcidworkid());
257
        Assert.assertNull(result.getOai());
258
        Assert.assertNotNull(result.getOpenaireId());//        Assert.assertNull(result.getOpenaireId());
259
        Assert.assertNull(result.getPmcid());
260
        Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType());
261
        Assert.assertEquals("A three-dimensional view on biodiversity changes: spatial, temporal, and functional perspectives on fish communities in the Baltic Sea", result.getTitle());
262
        Assert.assertEquals("xml", result.getRecordFormat());
263
        Assert.assertEquals("https://dx.doi.org/10.1093/icesjms/fsy027", result.getExternalUrl());
264
        Assert.assertNull(result.getEmbargoEndDate());
265

    
266
    }
267

    
268

    
269
    private String dataciteXml = "<rdf:RDF\n" +
270
            "    xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" +
271
            "    xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" +
272
            "    xmlns:j.0=\"http://purl.org/dc/terms/\" > \n" +
273
            "  <rdf:Description rdf:about=\"http://dx.doi.org/10.5060/D4RN35SD/USGS85K1_041\">\n" +
274
            "    <j.0:creator>Krimmel, Robert</j.0:creator>\n" +
275
            "    <j.0:publisher>National Snow and Ice Data Center/World Data Center for Glaciology, Boulder</j.0:publisher>\n" +
276
            "    <j.0:title>Chocolate Glacier</j.0:title>\n" +
277
            "    <j.0:date>2008</j.0:date>\n" +
278
            "    <owl:sameAs>doi:10.5060/D4RN35SD/USGS85K1_041</owl:sameAs>\n" +
279
            "    <owl:sameAs>info:doi/10.5060/D4RN35SD/USGS85K1_041</owl:sameAs>\n" +
280
            "    <j.0:identifier>10.5060/D4RN35SD/USGS85K1_041</j.0:identifier>\n" +
281
            "  </rdf:Description>\n" +
282
            "</rdf:RDF>\n";
283

    
284
    private String dataciteJson = "{\"data\":{\"id\":\"https://doi.org/10.5281/ZENODO.54730\",\"type\":\"works\",\"attributes\":{\"doi\":\"10.5281/ZENODO.54730\",\"url\":null,\"author\":[{\"family\":\"Manola\",\"given\":\"Natalia\"}],\"title\":\"From Open Access to Open Science\",\"container-title\":\"Zenodo\",\"description\":\"Presentation given at the PASTEUR4OA conference - Green Light for Open Access: Aligning Europe’s OA Policies, Amsterdam, 17th-18th May 2016.\",\"resource-type-subtype\":\"Presentation\",\"data-center-id\":\"cern.zenodo\",\"member-id\":\"cern\",\"resource-type-id\":\"text\",\"version\":null,\"license\":\"https://creativecommons.org/licenses/by/4.0/\",\"schema-version\":\"3\",\"results\":[],\"related-identifiers\":[],\"published\":\"2016\",\"deposited\":\"2016-06-03T17:03:51Z\",\"updated\":\"2016-06-03T17:03:51Z\",\"media\":null,\"xml\":\"PHJlc291cmNlIHhtbG5zPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtMyIgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZSIgeHNpOnNjaGVtYUxvY2F0aW9uPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtMyBodHRwOi8vc2NoZW1hLmRhdGFjaXRlLm9yZy9tZXRhL2tlcm5lbC0zL21ldGFkYXRhLnhzZCI+CiAgPGlkZW50aWZpZXIgaWRlbnRpZmllclR5cGU9IkRPSSI+MTAuNTI4MS96ZW5vZG8uNTQ3MzA8L2lkZW50aWZpZXI+CiAgPGNyZWF0b3JzPgogICAgPGNyZWF0b3I+CiAgICAgIDxjcmVhdG9yTmFtZT5NYW5vbGEsIE5hdGFsaWEgPC9jcmVhdG9yTmFtZT4KICAgICAgPGFmZmlsaWF0aW9uPk9wZW5BSVJFPC9hZmZpbGlhdGlvbj4KICAgIDwvY3JlYXRvcj4KICA8L2NyZWF0b3JzPgogIDx0aXRsZXM+CiAgICA8dGl0bGU+RnJvbSBPcGVuIEFjY2VzcyB0byBPcGVuIFNjaWVuY2U8L3RpdGxlPgogIDwvdGl0bGVzPgogIDxwdWJsaXNoZXI+WmVub2RvPC9wdWJsaXNoZXI+CiAgPHB1YmxpY2F0aW9uWWVhcj4yMDE2PC9wdWJsaWNhdGlvblllYXI+CiAgPHN1YmplY3RzPgogICAgPHN1YmplY3Q+UEFTVEVVUjRPQTwvc3ViamVjdD4KICAgIDxzdWJqZWN0Pk9wZW4gQWNjZXNzPC9zdWJqZWN0PgogICAgPHN1YmplY3Q+UHJlc2VudGF0aW9uPC9zdWJqZWN0PgogIDwvc3ViamVjdHM+CiAgPGNvbnRyaWJ1dG9ycz4KICAgIDxjb250cmlidXRvciBjb250cmlidXRvclR5cGU9IkZ1bmRlciI+CiAgICAgIDxjb250cmlidXRvck5hbWU+RXVyb3BlYW4gQ29tbWlzc2lvbjwvY29udHJpYnV0b3JOYW1lPgogICAgICA8bmFtZUlkZW50aWZpZXIgbmFtZUlkZW50aWZpZXJTY2hlbWU9ImluZm8iPmluZm86ZXUtcmVwby9ncmFudEFncmVlbWVudC9FQy9GUDcvNjExNzQyPC9uYW1lSWRlbnRpZmllcj4KICAgIDwvY29udHJpYnV0b3I+CiAgPC9jb250cmlidXRvcnM+CiAgPGRhdGVzPgogICAgPGRhdGUgZGF0ZVR5cGU9Iklzc3VlZCI+MjAxNi0wNS0xODwvZGF0ZT4KICA8L2RhdGVzPgogIDxyZXNvdXJjZVR5cGUgcmVzb3VyY2VUeXBlR2VuZXJhbD0iVGV4dCI+UHJlc2VudGF0aW9uPC9yZXNvdXJjZVR5cGU+CiAgPGFsdGVybmF0ZUlkZW50aWZpZXJzPgogICAgPGFsdGVybmF0ZUlkZW50aWZpZXIgYWx0ZXJuYXRlSWRlbnRpZmllclR5cGU9IlVSTCI+aHR0cDovL3plbm9kby5vcmcvcmVjb3JkLzU0NzMwPC9hbHRlcm5hdGVJZGVudGlmaWVyPgogICAgPGFsdGVybmF0ZUlkZW50aWZpZXIgYWx0ZXJuYXRlSWRlbnRpZmllclR5cGU9IlVSTCI+aHR0cDovL3d3dy5wYXN0ZXVyNG9hLmV1L3NpdGVzL3Bhc3RldXI0b2EvZmlsZXMvZ2VuZXJpYy9OYXRhbGlhJTIwTWFub2xhJTIwUERGLnBkZjwvYWx0ZXJuYXRlSWRlbnRpZmllcj4KICA8L2FsdGVybmF0ZUlkZW50aWZpZXJzPgogIDxyZWxhdGVkSWRlbnRpZmllcnM+CiAgICA8cmVsYXRlZElkZW50aWZpZXIgcmVsYXRpb25UeXBlPSJIYXNQYXJ0IiByZWxhdGVkSWRlbnRpZmllclR5cGU9IlVSTCI+aHR0cHM6Ly96ZW5vZG8ub3JnL3JlY29yZC81NDczMC9maWxlcy8xOF9OYXRhbGlhX01hbm9sYV9QREYucGRmPC9yZWxhdGVkSWRlbnRpZmllcj4KICA8L3JlbGF0ZWRJZGVudGlmaWVycz4KICA8cmlnaHRzTGlzdD4KICAgIDxyaWdodHMgcmlnaHRzVVJJPSJpbmZvOmV1LXJlcG8vc2VtYW50aWNzL29wZW5BY2Nlc3MiPk9wZW4gQWNjZXNzPC9yaWdodHM+CiAgICA8cmlnaHRzIHJpZ2h0c1VSST0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbGljZW5zZXMvYnkvNC4wLyI+Q3JlYXRpdmUgQ29tbW9ucyBBdHRyaWJ1dGlvbiA0LjAgSW50ZXJuYXRpb25hbDwvcmlnaHRzPgogIDwvcmlnaHRzTGlzdD4KICA8ZGVzY3JpcHRpb25zPgogICAgPGRlc2NyaXB0aW9uIGRlc2NyaXB0aW9uVHlwZT0iQWJzdHJhY3QiPiZsdDtwJmd0O1ByZXNlbnRhdGlvbiBnaXZlbiBhdCB0aGUgUEFTVEVVUjRPQSBjb25mZXJlbmNlIC0mYW1wO25ic3A7R3JlZW4gTGlnaHQgZm9yIE9wZW4gQWNjZXNzOiBBbGlnbmluZyBFdXJvcGUmYW1wO3JzcXVvO3MgT0EgUG9saWNpZXMsIEFtc3RlcmRhbSwgMTd0aC0xOHRoIE1heSAyMDE2LiZsdDsvcCZndDs8L2Rlc2NyaXB0aW9uPgogIDwvZGVzY3JpcHRpb25zPgo8L3Jlc291cmNlPgo=\"},\"relationships\":{\"data-center\":{\"meta\":{}},\"member\":{\"meta\":{}},\"resource-type\":{\"meta\":{}}}}}";
285

    
286
    @Test
287
    public void datacite2ResultTest() {
288
        Result result = ExternalRecordParser.datacite2Result(dataciteXml);
289

    
290
        Assert.assertNull(result.getAccessRights());
291
        Assert.assertNull(result.getBestLicense());
292
        Assert.assertEquals("openaire____::datacite", result.getCollectedFrom());
293
        Assert.assertEquals("10.5060/D4RN35SD/USGS85K1_041", result.getDoi());
294
        Assert.assertNull(result.getOrcidworkid());
295
        Assert.assertNull(result.getOai());
296
        Assert.assertNotNull(result.getOpenaireId());//        Assert.assertNull(result.getOpenaireId());
297
        Assert.assertNull(result.getPmcid());
298
        Assert.assertEquals(ClaimUtils.DATASET, result.getResultType());
299
        Assert.assertEquals("Chocolate Glacier", result.getTitle());
300
        Assert.assertEquals("xml", result.getRecordFormat());
301
        Assert.assertEquals("http://dx.doi.org/10.5060/D4RN35SD/USGS85K1_041", result.getExternalUrl());
302
        Assert.assertNull(result.getEmbargoEndDate());
303

    
304
    }
305

    
306
    @Test
307
    public void dataciteJsonResultTest() {
308
        Result result = ExternalRecordParser.dataciteJson2Result(dataciteJson);
309

    
310
        Assert.assertNull(result.getAccessRights());
311
        Assert.assertNull(result.getBestLicense());
312
        Assert.assertEquals("openaire____::datacite", result.getCollectedFrom());
313
        Assert.assertEquals("10.5281/ZENODO.54730", result.getDoi());
314
        Assert.assertNull(result.getOrcidworkid());
315
        Assert.assertNull(result.getOai());
316
        Assert.assertNotNull(result.getOpenaireId());//        Assert.assertNull(result.getOpenaireId());
317
        Assert.assertNull(result.getPmcid());
318
        Assert.assertEquals(ClaimUtils.DATASET, result.getResultType());
319
        Assert.assertEquals("From Open Access to Open Science", result.getTitle());
320
        Assert.assertEquals("json", result.getRecordFormat());
321
        Assert.assertEquals("https://dx.doi.org/10.5281/ZENODO.54730", result.getExternalUrl());
322
        Assert.assertNull(result.getEmbargoEndDate());
323

    
324
    }
325
    @Test
326
    public void testMD5() throws Exception {
327
        String id = "10.1016/j.engstruct.2013.03.014";
328
        String createdId = ExternalRecordParser.createOpenaireId(id);
329
        String openaireId = "userclaim___::07ec9eb2278a11e352e3fa93a621411d";
330
        Assert.assertEquals(createdId,openaireId);
331

    
332
    }
333
}
(2-2/3)