1
|
package eu.dnetlib.wds.resolver;
|
2
|
|
3
|
import com.google.gson.Gson;
|
4
|
import com.google.gson.GsonBuilder;
|
5
|
import eu.dnetlib.pid.resolver.model.ResolvedObject;
|
6
|
import eu.dnetlib.pid.resolver.store.ResolverStore;
|
7
|
|
8
|
import static org.junit.Assert.*;
|
9
|
import org.junit.Test;
|
10
|
import org.junit.runner.RunWith;
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
import org.springframework.test.context.ContextConfiguration;
|
13
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
14
|
|
15
|
|
16
|
@RunWith(SpringJUnit4ClassRunner.class)
|
17
|
@ContextConfiguration(classes = {ResolverConfiguration.class})
|
18
|
public class ResolverTest {
|
19
|
|
20
|
|
21
|
@Autowired
|
22
|
private DLIResolver dliResolver;
|
23
|
|
24
|
@Autowired
|
25
|
private OpenAireResolver openAireResolver;
|
26
|
|
27
|
@Autowired
|
28
|
private ResolverStore store;
|
29
|
|
30
|
|
31
|
@Test
|
32
|
public void testDLIResolveNullObject() throws Exception {
|
33
|
|
34
|
final WDSResolvedObject dli = dliResolver.resolve("https://spectradspace.lib.imperial.ac.uk:8443/metadata/handle/10042/to-7612/mets.xml", "url");
|
35
|
assertNull(dli);
|
36
|
|
37
|
}
|
38
|
|
39
|
@Test
|
40
|
public void testDLIResolvePublication() throws Exception {
|
41
|
|
42
|
final ResolvedObject openaire = dliResolver.retrievePID("10.1016/j.quascirev.2011.06.004", "doi");
|
43
|
|
44
|
final ResolvedObject doi_stored = store.getRecord("10.1016/j.quascirev.2011.06.004", "doi");
|
45
|
assertNotNull(doi_stored);
|
46
|
|
47
|
assertNotNull(openaire);
|
48
|
final Gson g = new GsonBuilder().setPrettyPrinting().create();
|
49
|
System.out.println("g.toJson(openaire) = " + g.toJson(openaire));
|
50
|
|
51
|
}
|
52
|
|
53
|
|
54
|
@Test
|
55
|
public void testOpenAireResolvePublication() throws Exception {
|
56
|
final ResolvedObject openaire = openAireResolver.retrievePID("10.1126/science.1141038", "DOI");
|
57
|
assertNotNull(openaire);
|
58
|
System.out.println(openaire.toJsonString());
|
59
|
final ResolvedObject doi_stored = store.getRecord("10.1126/science.1141038", "doi");
|
60
|
System.out.println(doi_stored.getType());
|
61
|
// final Gson g = new GsonBuilder().setPrettyPrinting().create();
|
62
|
// System.out.println("g.toJson(openaire) = " + g.toJson(openaire));
|
63
|
}
|
64
|
}
|