1
|
package eu.dnetlib.data.claims.migration.parser;
|
2
|
|
3
|
import eu.dnetlib.data.claims.migration.entity.Result;
|
4
|
import eu.dnetlib.data.claimsDemo.ClaimUtils;
|
5
|
import org.junit.Assert;
|
6
|
import org.junit.Test;
|
7
|
|
8
|
/**
|
9
|
* Created by kiatrop on 23/2/2016.
|
10
|
*/
|
11
|
public class ExternalParserTest {
|
12
|
|
13
|
private String crossrefJson = "{\"status\":\"ok\",\"message-type\":\"work-list\",\"message-version\":\"1.0.0\",\"message\":" +
|
14
|
"{\"query\":{\"search-terms\":null,\"start-index\":0},\"items-per-page\":20,\"items\":[{\"indexed\":" +
|
15
|
"{\"date-parts\":[[2015,12,28]], \"date-time\":\"2015-12-28T17:45:59Z\",\"timestamp\":1451324759779}," +
|
16
|
"\"reference-count\":0,\"publisher\":\"Society for Neuroscience\", \"issue\":\"17\"," +
|
17
|
"\"published-print\":{\"date-parts\":[[2012,4,25]]},\"DOI\":\"10.1523\\/jneurosci.2900-11.2012\"," +
|
18
|
"\"type\":\"journal-article\",\"created\": {\"date-parts\":[[2012,4,25]]," +
|
19
|
"\"date-time\":\"2012-04-25T16:38:54Z\",\"timestamp\":1335371934000},\"page\":\"5728-5736\"," +
|
20
|
"\"source\":\"CrossRef\",\"title\":[\"Imaging Microglial\\/Macrophage Activation in Spinal Cords of " +
|
21
|
"Experimental Autoimmune Encephalomyelitis Rats by Positron Emission Tomography Using the Mitochondrial " +
|
22
|
"18 kDa Translocator Protein Radioligand [18F]DPA-714\"]," +
|
23
|
"\"prefix\":\"http:\\/\\/id.crossref.org\\/prefix\\/10.1523\",\"volume\":\"32\",\"author\":" +
|
24
|
"[{\"affiliation\":[],\"family\":\"Abourbeh\",\"given\":\"G.\"},{\"affiliation\":[],\"family\":\"Theze\"," +
|
25
|
"\"given\":\"B.\"},{\"affiliation\":[],\"family\":\"Maroy\",\"given\":\"R.\"},{\"affiliation\":[],\"family\":" +
|
26
|
"\"Dubois\",\"given\":\"A.\"},{\"affiliation\":[],\"family\":\"Brulon\",\"given\":\"V.\"}," +
|
27
|
"{\"affiliation\":[],\"family\":\"Fontyn\",\"given\":\"Y.\"},{\"affiliation\":[],\"family\":\"Dolle\"," +
|
28
|
"\"given\":\"F.\"},{\"affiliation\":[],\"family\":\"Tavitian\",\"given\":\"B.\"},{\"affiliation\":[]," +
|
29
|
"\"family\":\"Boisgard\",\"given\":\"R.\"}],\"member\":\"http:\\/\\/id.crossref.org\\/member\\/393\"," +
|
30
|
"\"published-online\":{\"date-parts\":[[2012,4,25]]},\"container-title\":[\"Journal of Neuroscience\"]," +
|
31
|
"\"deposited\":{\"date-parts\":[[2014,2,27]],\"date-time\":\"2014-02-27T06:42:02Z\",\"timestamp\":1393483322000}," +
|
32
|
"\"score\":1.0,\"subtitle\":[],\"issued\":{\"date-parts\":[[2012,4,25]]}," +
|
33
|
"\"URL\":\"http:\\/\\/dx.doi.org\\/10.1523\\/jneurosci.2900-11.2012\",\"ISSN\":[\"0270-6474\",\"1529-2401\"]," +
|
34
|
"\"subject\":[\"Neuroscience(all)\"]}],\"total-results\":1,\"facets\":{}}}" +
|
35
|
"";
|
36
|
|
37
|
|
38
|
@Test
|
39
|
public void crossref2ResultTest(){
|
40
|
Result result = ExternalRecordParser.crossref2Result(crossrefJson);
|
41
|
|
42
|
Assert.assertNull(result.getAccessRights());
|
43
|
Assert.assertNull(result.getBestLicense());
|
44
|
Assert.assertEquals("openaire____::crossref", result.getCollectedFrom());
|
45
|
Assert.assertEquals("10.1523/jneurosci.2900-11.2012", result.getDoi());
|
46
|
Assert.assertNull(result.getOai());
|
47
|
Assert.assertNull(result.getOpenaireId());
|
48
|
Assert.assertNull(result.getPmcid());
|
49
|
Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType());
|
50
|
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());
|
51
|
Assert.assertEquals("json", result.getRecordFormat());
|
52
|
Assert.assertEquals("http://dx.doi.org/10.1523/jneurosci.2900-11.2012", result.getExternalUrl());
|
53
|
Assert.assertNull(result.getEmbargoEndDate());
|
54
|
Assert.assertNull(result.getOrcidworkid());
|
55
|
}
|
56
|
|
57
|
private String orcidXml = "<orcid-message xmlns=\"http://www.orcid.org/ns/orcid\">\n" +
|
58
|
" <message-version>1.1</message-version>\n" +
|
59
|
" <orcid-profile type=\"user\">\n" +
|
60
|
" <orcid-identifier>\n" +
|
61
|
" <uri>http://orcid.org/0000-0002-9414-646X</uri>\n" +
|
62
|
" <path>0000-0002-9414-646X</path>\n" +
|
63
|
" <host>orcid.org</host>\n" +
|
64
|
" </orcid-identifier>\n" +
|
65
|
" <orcid-preferences>\n" +
|
66
|
" <locale>es</locale>\n" +
|
67
|
" </orcid-preferences>\n" +
|
68
|
" <orcid-history>\n" +
|
69
|
" <creation-method>website</creation-method>\n" +
|
70
|
" <completion-date>2013-01-11T14:07:54.194Z</completion-date>\n" +
|
71
|
" <submission-date>2013-01-11T13:27:46.558Z</submission-date>\n" +
|
72
|
" <last-modified-date>2016-01-27T16:06:13.543Z</last-modified-date>\n" +
|
73
|
" <claimed>true</claimed>\n" +
|
74
|
" </orcid-history>\n" +
|
75
|
" <orcid-activities>\n" +
|
76
|
" <orcid-works>\n" +
|
77
|
" <orcid-work put-code=\"21755327\" visibility=\"public\">\n" +
|
78
|
" <work-title>\n" +
|
79
|
" <title>Providing Ubiquitous Positioning in Outdoor Environments</title>\n" +
|
80
|
" </work-title>\n" +
|
81
|
" <journal-title>2015 IEEE International Conference on Systems, Man, and Cybernetics</journal-title>\n" +
|
82
|
" <work-citation>\n" +
|
83
|
" <work-citation-type>bibtex</work-citation-type>\n" +
|
84
|
" <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 {\\&} 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" +
|
85
|
" </work-citation>\n" +
|
86
|
" <work-type>conference-paper</work-type>\n" +
|
87
|
" <publication-date>\n" +
|
88
|
" <year>2015</year>\n" +
|
89
|
" <month>10</month>\n" +
|
90
|
" </publication-date>\n" +
|
91
|
" <work-external-identifiers>\n" +
|
92
|
" <work-external-identifier>\n" +
|
93
|
" <work-external-identifier-type>doi</work-external-identifier-type>\n" +
|
94
|
" <work-external-identifier-id>10.1109/smc.2015.229</work-external-identifier-id>\n" +
|
95
|
" </work-external-identifier>\n" +
|
96
|
" </work-external-identifiers>\n" +
|
97
|
" <work-contributors>\n" +
|
98
|
" <contributor>\n" +
|
99
|
" <credit-name visibility=\"public\">Daniel Moreno</credit-name>\n" +
|
100
|
" <contributor-attributes>\n" +
|
101
|
" <contributor-role>author</contributor-role>\n" +
|
102
|
" </contributor-attributes>\n" +
|
103
|
" </contributor>\n" +
|
104
|
" <contributor>\n" +
|
105
|
" <credit-name visibility=\"public\">Sergio F. Ochoa</credit-name>\n" +
|
106
|
" <contributor-attributes>\n" +
|
107
|
" <contributor-role>author</contributor-role>\n" +
|
108
|
" </contributor-attributes>\n" +
|
109
|
" </contributor>\n" +
|
110
|
" <contributor>\n" +
|
111
|
" <credit-name visibility=\"public\">Roc Meseguer</credit-name>\n" +
|
112
|
" <contributor-attributes>\n" +
|
113
|
" <contributor-role>author</contributor-role>\n" +
|
114
|
" </contributor-attributes>\n" +
|
115
|
" </contributor>\n" +
|
116
|
" </work-contributors>\n" +
|
117
|
" <work-source>\n" +
|
118
|
" <uri>http://orcid.org/0000-0002-3054-1567</uri>\n" +
|
119
|
" <path>0000-0002-3054-1567</path>\n" +
|
120
|
" <host>orcid.org</host>\n" +
|
121
|
" </work-source>\n" +
|
122
|
" </orcid-work>\n" +
|
123
|
" <orcid-work put-code=\"19191618\" visibility=\"public\">\n" +
|
124
|
" <work-title>\n" +
|
125
|
" <title>A Context-Aware Model to Provide Positioning in Disaster Relief Scenarios</title>\n" +
|
126
|
" </work-title>\n" +
|
127
|
" <journal-title>Sensors</journal-title>\n" +
|
128
|
" <work-citation>\n" +
|
129
|
" <work-citation-type>bibtex</work-citation-type>\n" +
|
130
|
" <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" +
|
131
|
" </work-citation>\n" +
|
132
|
" <work-type>journal-article</work-type>\n" +
|
133
|
" <publication-date>\n" +
|
134
|
" <year>2015</year>\n" +
|
135
|
" <month>09</month>\n" +
|
136
|
" </publication-date>\n" +
|
137
|
" <work-external-identifiers>\n" +
|
138
|
" <work-external-identifier>\n" +
|
139
|
" <work-external-identifier-type>doi</work-external-identifier-type>\n" +
|
140
|
" <work-external-identifier-id>10.3390/s151025176</work-external-identifier-id>\n" +
|
141
|
" </work-external-identifier>\n" +
|
142
|
" </work-external-identifiers>\n" +
|
143
|
" <work-contributors>\n" +
|
144
|
" <contributor>\n" +
|
145
|
" <credit-name visibility=\"public\">Daniel Moreno</credit-name>\n" +
|
146
|
" <contributor-attributes>\n" +
|
147
|
" <contributor-role>author</contributor-role>\n" +
|
148
|
" </contributor-attributes>\n" +
|
149
|
" </contributor>\n" +
|
150
|
" <contributor>\n" +
|
151
|
" <credit-name visibility=\"public\">Sergio Ochoa</credit-name>\n" +
|
152
|
" <contributor-attributes>\n" +
|
153
|
" <contributor-role>author</contributor-role>\n" +
|
154
|
" </contributor-attributes>\n" +
|
155
|
" </contributor>\n" +
|
156
|
" <contributor>\n" +
|
157
|
" <credit-name visibility=\"public\">Roc Meseguer</credit-name>\n" +
|
158
|
" <contributor-attributes>\n" +
|
159
|
" <contributor-role>author</contributor-role>\n" +
|
160
|
" </contributor-attributes>\n" +
|
161
|
" </contributor>\n" +
|
162
|
" </work-contributors>\n" +
|
163
|
" <work-source>\n" +
|
164
|
" <uri>http://orcid.org/0000-0002-3054-1567</uri>\n" +
|
165
|
" <path>0000-0002-3054-1567</path>\n" +
|
166
|
" <host>orcid.org</host>\n" +
|
167
|
" </work-source>\n" +
|
168
|
" </orcid-work>" +
|
169
|
"</orcid-works></orcid-activities></orcid-profile></orcid-message>";
|
170
|
|
171
|
@Test
|
172
|
public void orcid2ResultTest() {
|
173
|
Result result = ExternalRecordParser.orcid2Result(orcidXml, "0000-0002-9414-646X-21755327");
|
174
|
|
175
|
Assert.assertNull(result.getAccessRights());
|
176
|
Assert.assertNull(result.getBestLicense());
|
177
|
Assert.assertEquals("openaire____::orcid", result.getCollectedFrom());
|
178
|
Assert.assertEquals("10.1109/smc.2015.229", result.getDoi());
|
179
|
Assert.assertEquals("0000-0002-9414-646X-21755327", result.getOrcidworkid());
|
180
|
Assert.assertNull(result.getOai());
|
181
|
Assert.assertNull(result.getOpenaireId());
|
182
|
Assert.assertNull(result.getPmcid());
|
183
|
Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType());
|
184
|
Assert.assertEquals("Providing Ubiquitous Positioning in Outdoor Environments", result.getTitle());
|
185
|
Assert.assertEquals("xml", result.getRecordFormat());
|
186
|
Assert.assertEquals("http://dx.doi.org/10.1109/smc.2015.229", result.getExternalUrl());
|
187
|
Assert.assertNull(result.getEmbargoEndDate());
|
188
|
|
189
|
}
|
190
|
|
191
|
|
192
|
private String dataciteXml = "<rdf:RDF\n" +
|
193
|
" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" +
|
194
|
" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" +
|
195
|
" xmlns:j.0=\"http://purl.org/dc/terms/\" > \n" +
|
196
|
" <rdf:Description rdf:about=\"http://dx.doi.org/10.5060/D4RN35SD/USGS85K1_041\">\n" +
|
197
|
" <j.0:creator>Krimmel, Robert</j.0:creator>\n" +
|
198
|
" <j.0:publisher>National Snow and Ice Data Center/World Data Center for Glaciology, Boulder</j.0:publisher>\n" +
|
199
|
" <j.0:title>Chocolate Glacier</j.0:title>\n" +
|
200
|
" <j.0:date>2008</j.0:date>\n" +
|
201
|
" <owl:sameAs>doi:10.5060/D4RN35SD/USGS85K1_041</owl:sameAs>\n" +
|
202
|
" <owl:sameAs>info:doi/10.5060/D4RN35SD/USGS85K1_041</owl:sameAs>\n" +
|
203
|
" <j.0:identifier>10.5060/D4RN35SD/USGS85K1_041</j.0:identifier>\n" +
|
204
|
" </rdf:Description>\n" +
|
205
|
"</rdf:RDF>\n";
|
206
|
|
207
|
@Test
|
208
|
public void datacite2ResultTest() {
|
209
|
Result result = ExternalRecordParser.datacite2Result(dataciteXml);
|
210
|
|
211
|
Assert.assertNull(result.getAccessRights());
|
212
|
Assert.assertNull(result.getBestLicense());
|
213
|
Assert.assertEquals("openaire____::datacite", result.getCollectedFrom());
|
214
|
Assert.assertEquals("10.5060/D4RN35SD/USGS85K1_041", result.getDoi());
|
215
|
Assert.assertNull(result.getOrcidworkid());
|
216
|
Assert.assertNull(result.getOai());
|
217
|
Assert.assertNull(result.getOpenaireId());
|
218
|
Assert.assertNull(result.getPmcid());
|
219
|
Assert.assertEquals(ClaimUtils.DATASET, result.getResultType());
|
220
|
Assert.assertEquals("Chocolate Glacier", result.getTitle());
|
221
|
Assert.assertEquals("xml", result.getRecordFormat());
|
222
|
Assert.assertEquals("http://dx.doi.org/10.5060/D4RN35SD/USGS85K1_041", result.getExternalUrl());
|
223
|
Assert.assertNull(result.getEmbargoEndDate());
|
224
|
|
225
|
}
|
226
|
}
|