Revision 62880
Added by Michele Artini 10 months ago
OpenAIRESubmitterUtilsTest.java | ||
---|---|---|
3 | 3 |
import static org.mockito.Mockito.CALLS_REAL_METHODS; |
4 | 4 |
import static org.mockito.Mockito.doReturn; |
5 | 5 |
import static org.mockito.Mockito.mock; |
6 |
import static org.mockito.Mockito.when; |
|
6 | 7 |
import static org.mockito.Mockito.withSettings; |
7 | 8 |
|
8 | 9 |
import java.util.ArrayList; |
... | ... | |
22 | 23 |
import com.google.gson.Gson; |
23 | 24 |
|
24 | 25 |
import eu.dnetlib.openaire.directindex.objects.DatasourceEntry; |
26 |
import eu.dnetlib.openaire.directindex.utils.CorrectionUtils; |
|
25 | 27 |
|
26 | 28 |
/** |
27 | 29 |
* Created by Alessia Bardi on 26/05/2017. |
... | ... | |
42 | 44 |
"info:eu-repo/grantAgreement/EC/Horizon Europe Framework Programme - HORIZON-CSA\\HORIZON Action Grant Budget-Based/101058527/"; |
43 | 45 |
final String chistera = "info:eu-repo/grantAgreement/CHIST-ERA//CHIST-ERA-19-XAI-002/"; |
44 | 46 |
|
45 |
final String intelcomp = "info:eu-repo/grantAgreement/EC/H2020/101004870//A Competitive Intelligence Cloud%2FHPC Platform for AI-based STI Policy Making/IntelComp"; |
|
47 |
final String intelcomp = |
|
48 |
"info:eu-repo/grantAgreement/EC/H2020/101004870//A Competitive Intelligence Cloud%2FHPC Platform for AI-based STI Policy Making/IntelComp"; |
|
46 | 49 |
|
50 |
final String invalidProject = "info:eu-repo/grantAgreement/TEST//TEST01/"; |
|
51 |
|
|
47 | 52 |
@Before |
48 | 53 |
public void setup() { |
49 | 54 |
utils = mock(OpenAIRESubmitterUtils.class, withSettings().defaultAnswer(CALLS_REAL_METHODS)); |
... | ... | |
58 | 63 |
print(project); |
59 | 64 |
Assert.assertEquals("CHIST-ERA-19-XAI-002", project.get("code")); |
60 | 65 |
Assert.assertEquals("chistera____::289ec73ce0e9ece89a0cbdf74c445cd8", project.get("id")); |
61 |
|
|
62 | 66 |
} |
63 | 67 |
|
64 | 68 |
@Test |
... | ... | |
66 | 70 |
final Map<String, String> project = utils.calculateProjectInfo(onlyId); |
67 | 71 |
print(project); |
68 | 72 |
Assert.assertEquals("244909", project.get("code")); |
69 |
|
|
70 | 73 |
} |
71 | 74 |
|
72 | 75 |
@Test |
... | ... | |
84 | 87 |
Assert.assertEquals("101004870", project.get("code")); |
85 | 88 |
Assert.assertEquals("corda__h2020::8264fd9d5f5d59b1b76fc618f3a8af24", project.get("id")); |
86 | 89 |
Assert.assertEquals("IntelComp", project.get("acronym")); |
90 |
} |
|
87 | 91 |
|
92 |
@Test |
|
93 |
public void testCalculateProjectInfoWithCorrection() { |
|
94 |
final CorrectionUtils correctionUtils = mock(CorrectionUtils.class); |
|
95 |
when(correctionUtils.correctProjectId("test________::8b2a3c43f69cf490f26f88a3029b02d3")).thenReturn("test________::00000000000000000000000000000000"); |
|
96 |
|
|
97 |
final OpenAIRESubmitterUtils utils = new OpenAIRESubmitterUtils("", "https://services.openaire.eu/openaire/ds/", correctionUtils); |
|
98 |
|
|
99 |
final Map<String, String> project = utils.calculateProjectInfo(invalidProject); |
|
100 |
print(project); |
|
101 |
Assert.assertEquals("TEST01", project.get("code")); |
|
102 |
Assert.assertEquals("test________::00000000000000000000000000000000", project.get("id")); |
|
88 | 103 |
} |
89 | 104 |
|
90 | 105 |
@Test |
... | ... | |
174 | 189 |
@Test |
175 | 190 |
@Ignore |
176 | 191 |
public void testFindDatasource_01() { |
177 |
final OpenAIRESubmitterUtils utils = new OpenAIRESubmitterUtils("", "https://services.openaire.eu/openaire/ds/"); |
|
192 |
final OpenAIRESubmitterUtils utils = new OpenAIRESubmitterUtils("", "https://services.openaire.eu/openaire/ds/", null);
|
|
178 | 193 |
final DatasourceEntry res = utils.findDatasource("opendoar____::1112"); |
179 | 194 |
System.err.println(new Gson().toJson(res)); |
180 | 195 |
} |
... | ... | |
182 | 197 |
@Test |
183 | 198 |
@Ignore |
184 | 199 |
public void testFindDatasourceCrossref() { |
185 |
final OpenAIRESubmitterUtils utils = new OpenAIRESubmitterUtils("", "https://services.openaire.eu/openaire/ds/"); |
|
200 |
final OpenAIRESubmitterUtils utils = new OpenAIRESubmitterUtils("", "https://services.openaire.eu/openaire/ds/", null);
|
|
186 | 201 |
final DatasourceEntry res = utils.findDatasource("openaire____::crossref"); |
187 | 202 |
System.err.println(new Gson().toJson(res)); |
188 | 203 |
} |
Also available in: Unified diff
implement the project ids correction using map files