1
|
package eu.dnetlib.msro.openaireplus.api;
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.List;
|
5
|
import java.util.Map;
|
6
|
import java.util.Map.Entry;
|
7
|
|
8
|
import org.junit.Assert;
|
9
|
import org.junit.Test;
|
10
|
|
11
|
import eu.dnetlib.openaire.directindex.api.OpenAIRESubmitterUtils;
|
12
|
|
13
|
/**
|
14
|
* Created by Alessia Bardi on 26/05/2017.
|
15
|
*
|
16
|
* @author Alessia Bardi
|
17
|
*/
|
18
|
public class OpenAIRESubmitterUtilsTest {
|
19
|
|
20
|
private OpenAIRESubmitterUtils utils = new OpenAIRESubmitterUtils(
|
21
|
"http://beta.services.openaire.eu/openaire/community/"
|
22
|
);
|
23
|
|
24
|
final String fullProject = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble";
|
25
|
final String minimalProject = "info:eu-repo/grantAgreement/EC/FP7/244909///WorkAble";
|
26
|
final String onlyId = "info:eu-repo/grantAgreement/EC/FP7/244909/";
|
27
|
final String onlyTitle = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work";
|
28
|
final String escapedId = "info:eu-repo/grantAgreement/RCUK//NE%2FL003066%2F1/";
|
29
|
|
30
|
@Test
|
31
|
public void testCalculateProjectInfoEscaped() {
|
32
|
final Map<String, String> project = utils.calculateProjectInfo(escapedId);
|
33
|
print(project);
|
34
|
}
|
35
|
|
36
|
@Test
|
37
|
public void testCalculateProjectInfoFull() {
|
38
|
final Map<String, String> project = utils.calculateProjectInfo(fullProject);
|
39
|
print(project);
|
40
|
}
|
41
|
|
42
|
@Test
|
43
|
public void testCalculateProjectInfoOnlyId() {
|
44
|
final Map<String, String> project = utils.calculateProjectInfo(onlyId);
|
45
|
print(project);
|
46
|
}
|
47
|
|
48
|
@Test
|
49
|
public void testCalculateProjectInfoMinimalAcro() {
|
50
|
final Map<String, String> project = utils.calculateProjectInfo(minimalProject);
|
51
|
print(project);
|
52
|
}
|
53
|
|
54
|
@Test
|
55
|
public void testCalculateProjectInfoOnlyTitle() {
|
56
|
final Map<String, String> project = utils.calculateProjectInfo(onlyTitle);
|
57
|
print(project);
|
58
|
}
|
59
|
|
60
|
@Test
|
61
|
public void testJerusalem(){
|
62
|
String s = "info:eu-repo/grantAgreement/EC/FP7/337895/EU/Opening Jerusalem Archives: For a connected History of ‘Citadinité’ in the Holy City (1840-1940)/OPEN-JERUSALEM";
|
63
|
final Map<String, String> project = utils.calculateProjectInfo(s);
|
64
|
print(project);
|
65
|
}
|
66
|
|
67
|
private void print(final Map<String, String> map) {
|
68
|
for (final Entry e : map.entrySet()) {
|
69
|
System.out.println(e.getKey() + " = " + e.getValue());
|
70
|
}
|
71
|
}
|
72
|
|
73
|
@Test
|
74
|
public void testContext(){
|
75
|
List<String> contexts = new ArrayList<>();
|
76
|
contexts.add("https://zenodo.org/communities/dimpo");
|
77
|
contexts.add("https://zenodo.org/communities/aoo_beopen");
|
78
|
List<OpenAIRESubmitterUtils.ContextInfo> tmp = utils.processContexts(contexts);
|
79
|
|
80
|
Assert.assertEquals(2, tmp.size());
|
81
|
|
82
|
Assert.assertTrue(tmp.get(0).getId().equals("dh-ch") || tmp.get(1).getId().equalsIgnoreCase("dh-ch"));
|
83
|
Assert.assertTrue(tmp.get(0).getId().equals("dariah") || tmp.get(1).getId().equalsIgnoreCase("dariah"));
|
84
|
}
|
85
|
}
|