1
|
package eu.dnetlib.data.collector.plugins.doiresolver;
|
2
|
|
3
|
import org.junit.Assert;
|
4
|
import org.junit.Before;
|
5
|
import org.junit.Test;
|
6
|
import org.junit.runner.RunWith;
|
7
|
import org.mockito.Mock;
|
8
|
import org.mockito.junit.MockitoJUnitRunner;
|
9
|
|
10
|
import static org.mockito.Mockito.when;
|
11
|
|
12
|
@RunWith(MockitoJUnitRunner.class)
|
13
|
public class DOIResolverIteratorTest {
|
14
|
|
15
|
@Mock
|
16
|
CrossrefResolver resolver;
|
17
|
DOIResolverIterator it;
|
18
|
|
19
|
@Before
|
20
|
public void setup(){
|
21
|
when(resolver.resolve("1")).thenReturn("RECORD1");
|
22
|
when(resolver.resolve("2")).thenReturn(null);
|
23
|
when(resolver.resolve("3")).thenReturn("RECORD3");
|
24
|
String file = getClass().getResource("/eu/dnetlib/data/collector/plugins/doiresolver/doi_list.csv").getFile();
|
25
|
it = new DOIResolverIterator(file, resolver);
|
26
|
}
|
27
|
|
28
|
@Test
|
29
|
public void test(){
|
30
|
while(it.hasNext()){
|
31
|
System.out.println(it.next());
|
32
|
}
|
33
|
}
|
34
|
|
35
|
@Test
|
36
|
public void testCleanOk(){
|
37
|
String doi = "10.1234/1234";
|
38
|
Assert.assertEquals(doi, it.cleanDOI(doi));
|
39
|
}
|
40
|
|
41
|
@Test
|
42
|
public void testCleanHttp(){
|
43
|
String doi = "10.1234/1234";
|
44
|
String doiURL = "http://dx.doi.org/"+doi;
|
45
|
Assert.assertEquals(doi, it.cleanDOI(doiURL));
|
46
|
}
|
47
|
|
48
|
@Test
|
49
|
public void testCleanHttps(){
|
50
|
String doi = "10.1234/1234";
|
51
|
String doiURL = "https://dx.doi.org/"+doi;
|
52
|
Assert.assertEquals(doi, it.cleanDOI(doiURL));
|
53
|
}
|
54
|
}
|